actionscript 3 - AS3 MOVING OBJECT ON SPECIFIC FRAME -


so i've been working on game week , dont have coding background @ im trying find tutorial here , there.. come problem ...

so wanna move object (chara) right when hit frame 80 inside (chara,which nested movieclip 99 frames btw ) move original position when hit frame 99... problem doesn't make object move @ (movieclip still played btw) did wrong here? did put code @ wrong position ?? (char moved if put code x= directly inside frame 80 try using class here)

here code,sorry know messy first code try best here

package {      public class main extends movieclip {          public var chara:char = new char;//my main char         public var rasen:rasen_button = new rasen_button;//the skill button         public var npcs:npc = new npc;// npc          public function main() {             var ally:array = [265,296];//where me , ally should             var jutsu:array = [330,180];// buttons should             var enemy:array = [450,294];//where enemies should              addchild(npcs);             npcs.x = enemy[0];             npcs.y = enemy[1];             npcs.scalex *=  -1;              addchild(rasen);             rasen.x = jutsu[1];             rasen.y = jutsu[0];              addchild(chara);             chara.x = ally[0];             chara.y = ally[1];             rasen.addeventlistener(mouseevent.click, f2_mouseoverhandler);             function f2_mouseoverhandler(event:mouseevent):void {                 chara.gotoandplay(46); //here problem                 if (chara.frame == 80)                 {                     chara.x = ally[1]; //just random possition                 }              }         }     } } 

any suggestions?

your if statement inside click handler (f2_mouseoverhandler), gets executed when user clicks rasen, not when playback reaches frame 80. common beginner mistake related timing , code execution. straight forward solution write code execute every frame using enter_frame handler:

        rasen.addeventlistener(mouseevent.click, f2_mouseoverhandler);         function f2_mouseoverhandler(event:mouseevent):void {             chara.gotoandplay(46); //here problem              // add enter_frame handler check every frame             chara.addeventlistener(event.enter_frame, chara_enterframehandler)         }         function chara_enterframehandler(event:event):void {             if (chara.currentframe == 80)             {                 chara.x = ally[1]; //just random possition                  // remove enter_frame after condition met                 // stops executing each frame                 chara.removeeventlistener(event.enter_frame, chara_enterframehandler);             }         } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -