Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

backward movement animation in flash with as3

New Here ,
Sep 19, 2015 Sep 19, 2015

hi, first of let me say that I very new to action scripting and with some tutorial I was able to learn a few things. With that being said, I was charged to make an animation using only action scripting, no motion tween in flash all on one frame. The idea was to move an object along the four corners of the stage. But I have a problem, I figured out how to move the object towards the right and down, but I can't get it to move left and up. here's what I have....and yes I know it's a mess.

import flash.events.Event;

addEventListener(Event.ENTER_FRAME,ballgo)
function ballgo(e:Event):void{
pacmanMc.x += 10;
}
stage.addEventListener(Event.ENTER_FRAME,dontmove);


       function dontmove(e:Event):void{

         if(pacmanMc.x>500){
       pacmanMc.x=500
     }


if(pacmanMc.x>490){
  pacmanMc.y+=10;
}
}
   
stage.addEventListener(Event.ENTER_FRAME,freeze);
      
    function freeze(e:Event):void{
     if(pacmanMc.y>335){
      pacmanMc.y=335
     }
    }

If anyone could help me before Sunday night it will be greatly appreciated.

TOPICS
ActionScript
378
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 19, 2015 Sep 19, 2015

if pacmanMc has reg point at the upper left use:

import flash.events.Event;

var leg:int = 1;

addEventListener(Event.ENTER_FRAME, pacmanGo);


function pacmanGo(e:Event):void{

if(leg==1){

pacmanMc.x+=10;

if(pacmanMc.x>=stage.stageWidth-pacmanMc.width){

leg=2;

pacmanMc.x=stage.stageWidth-pacmanMc.width;

}

} else if(leg==2){

pacmanMc.y+=10;

if(pacmanMc.y>=stage.stageHeight-pacmanMc.height){

pacmanMc.y=stage.stageHeight-pacmanMc.height;

leg=3;

}

} else if(leg==3){

pacmanMc.x-=10;

if(pacmanMc.x<=0){

pa

...
Translate
Community Expert ,
Sep 19, 2015 Sep 19, 2015

if pacmanMc has reg point at the upper left use:

import flash.events.Event;

var leg:int = 1;

addEventListener(Event.ENTER_FRAME, pacmanGo);


function pacmanGo(e:Event):void{

if(leg==1){

pacmanMc.x+=10;

if(pacmanMc.x>=stage.stageWidth-pacmanMc.width){

leg=2;

pacmanMc.x=stage.stageWidth-pacmanMc.width;

}

} else if(leg==2){

pacmanMc.y+=10;

if(pacmanMc.y>=stage.stageHeight-pacmanMc.height){

pacmanMc.y=stage.stageHeight-pacmanMc.height;

leg=3;

}

} else if(leg==3){

pacmanMc.x-=10;

if(pacmanMc.x<=0){

pacmanMc.x=0;

leg=4;

}

} else if(leg==4){

pacmanMc.y-=10;

if(pacmanMc.y<=0){

pacmanMc.y=0;

removeEventListener(Event.ENTER_FRAME, pacmanGo);

}

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2015 Sep 19, 2015

Thank you very much. But the code I have moves pacmanMc from the upper left to the upper right and then lower right. The problem is moving him from the lower right to the lower left and then to the upper left.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2015 Sep 19, 2015

use the code i suggested.

it's easy to understand and does exactly that.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2015 Sep 19, 2015

thank you very much for helping

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2015 Sep 19, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines