geeem
01-01-2010, 06:13 PM
Hi
I hope someone can help...
I have a mc which plays a frame-by-frame animation over several frames and results in the chraracter walking a few steps (left to right). If this is placed just off-stage (stage-left) the character appears to walk on when the movie is tested.
Now I want to script the movie (AS3) so he appears to walk all the way across the stage and disappear (stage-right).
I have achieved this is a very tedious way, by duplicating frames in the mc, but I would like to do it in script.
I have got partial success with the code below. The first mc (instance name, mach_mc) has been physically placed stage-left. He does his walk, then the code adds a duplicate from the Lib, just where the first walk ends. This works fine, as he appears to walk that bit further across the stage. Trouble is, when I now try to repeat the main section of code, to add another duplicate, it all goes wrong.
Here is the code I have so far...
var myTimer:Timer=new Timer(20);
myTimer.addEventListener(TimerEvent.TIMER,loadmc);
myTimer.start();
function loadmc(event:Event) {
if (mach_mc.currentFrame==mach_mc.totalFrames) {
var mach1_mc:machWalk = new machWalk();
mach1_mc.x=140;
mach1_mc.y=230;
addChild(mach1_mc);
mach_mc.visible=false
myTimer.stop();
}
}
I am now trying to get the desired result with an array and a loop, but have hit problems.
What is the simplest way of getting this to work?
Thank you very much in advance for any help.
I hope someone can help...
I have a mc which plays a frame-by-frame animation over several frames and results in the chraracter walking a few steps (left to right). If this is placed just off-stage (stage-left) the character appears to walk on when the movie is tested.
Now I want to script the movie (AS3) so he appears to walk all the way across the stage and disappear (stage-right).
I have achieved this is a very tedious way, by duplicating frames in the mc, but I would like to do it in script.
I have got partial success with the code below. The first mc (instance name, mach_mc) has been physically placed stage-left. He does his walk, then the code adds a duplicate from the Lib, just where the first walk ends. This works fine, as he appears to walk that bit further across the stage. Trouble is, when I now try to repeat the main section of code, to add another duplicate, it all goes wrong.
Here is the code I have so far...
var myTimer:Timer=new Timer(20);
myTimer.addEventListener(TimerEvent.TIMER,loadmc);
myTimer.start();
function loadmc(event:Event) {
if (mach_mc.currentFrame==mach_mc.totalFrames) {
var mach1_mc:machWalk = new machWalk();
mach1_mc.x=140;
mach1_mc.y=230;
addChild(mach1_mc);
mach_mc.visible=false
myTimer.stop();
}
}
I am now trying to get the desired result with an array and a loop, but have hit problems.
What is the simplest way of getting this to work?
Thank you very much in advance for any help.