Copy link to clipboard
Copied
Hello. I am using Flash CS6.
I added 2 frames long movieclip by addChild, but it plays 3 frames.
Main timeline has 10 frames and I wrote this AS on frame 5.
var test= new test_lib();
test.x = stage.stageWidth/2;
test.y = stage.stageHeight/2;
Object(root).addChild(test);
but It starts to play one frame after added, so it starts to play not on frame 5,but on frame 6.
So it looks like playing "frame 1","frame 1","frame 2".
I need to start the movieclip immediately after adding it(I need it to start on frame 5) by addChild.
What should I do?
Copy link to clipboard
Copied
your explanation is not consistant with the default behavior of flash.
when you create your movieclip (the var test=new test_lib() line), test is at frame 1 and if that code is on your main timeline's frame 5, then test will be at frame 1 when your main timeline is at frame 5.
if there is no other code (ie, stops, gotos etc), test will be at its frame 2 when the main timeline is at frame 6. to confirm, add a keyframe to test's 2nd frame and attach the following code to test's 2nd frame:
trace(this.currentFrame,this.parent.currentFrame);
Copy link to clipboard
Copied
I got 1,5 and 2,7. It seems 1 frame of test mc shows twice on frame 5 and 6.
Copy link to clipboard
Copied
did you add two traces?
Copy link to clipboard
Copied
yes. What sould I do to fix this?
Copy link to clipboard
Copied
i don't see that.
create a new fla.
add a new movieclip that has 3 frames. add the code i suggested to keyframes 1 and 2.
add that movieclip to keyframe 5 of the main timeline and extend the main timeline to 10 frames.
test.
any problem?
Copy link to clipboard
Copied
Maybe I am wrong? I still get dual frame 1.
I uploaded my fla file.Please check it.
Copy link to clipboard
Copied
that's a spam site.
Copy link to clipboard
Copied
Ok. How about this site? I reuploaded. It's clean I guess.
http://fast-uploader.com/start/6926452337251/?fileId=6926452337251
Copy link to clipboard
Copied
doesn't work for me.
Copy link to clipboard
Copied
http://fast-uploader.com/file/6926452337251/
sorry. try this and click the link at the bottom of the page.
Copy link to clipboard
Copied
ok.
it does start right away but it takes an extra clock cycle to play its 2nd frame. from there both play one frame per clock cycle.
here's the result of using code to create and instance vs an instance added to the ide when the following is on the first 6 frames of the movieclip and both are created in the parent's first frame and fps is 10:
trace(this.name,this.currentFrame, MovieClip(this.parent).currentFrame, getTimer())
ide 1 1 3
coded 1 1 5
ide 2 2 110
ide 3 3 212
coded 2 3 212
ide 4 4 312
coded 3 4 312
ide 5 5 412
coded 4 5 412
ide 6 6 512
coded 5 6 512
coded 6 6 612
Copy link to clipboard
Copied
so what should I do to start it immediately ? I need to add gotoAndStart or something?
Copy link to clipboard
Copied
no.
if you're trying to sync animation/sound in test and animation/sound on the timeline where you're adding test, move the animation/sound from test's parent to another movieclip and create them both with code.
Copy link to clipboard
Copied
Ok. thank you.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now