flash - how to make life movie clip using actionscript 2.0 -


i using actionscript 2.0 project. have movie clip moving along x-axis. problem is, if movie clip reaches given boundary, should automatically deduct 1 life. codes doesn't work.

here's code timeline:

var life:number = 5;  lives = 3;  boundary = 280;     var speed:number = 1;  var boundary:number = 280;      this.onenterframe = function():void {      if (clip._x > boundary) {          clip._x -= speed;      } else {          clip._x = boundary;          delete this.onenterframe;	      }  }  if(lives == 0){  	gotoandstop(132);  }

here's code moving mc:

onclipevent (load) {      speed = 1;      boundary = 280; 	  }  onclipevent (enterframe) {      if (this._x > boundary) {          this._x -= speed;		      }   	else {          this._x = boundary;          this._visible = false;  		life -= 1;          lifebox.text = life.tostring();      }  }

first, don't need have code timeline , code movie clip.

on other hand, if want movie clip disappear, should remove or put elsewhere, because hittest run continuously.

main timeline code

var lifes:number = 5; var speed:number = 1; var boundary:number = 280; var startx:number = 320; clip._x = startx;  this.onenterframe = function():void {     if (clip._x > boundary) {         clip._x -= speed;     } else {         lifes--;         clip._x = startx;         if (lifes == 0) {             gotoandstop(132);             delete this.onenterframe;         }     } } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -