Skip to main content
Inspiring
June 10, 2013
Question

Movie clip added by addChild won't start immediately.

  • June 10, 2013
  • 1 reply
  • 2186 views

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?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 10, 2013

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);

Inspiring
June 10, 2013

I got 1,5 and 2,7. It seems 1 frame of test mc shows twice on frame 5 and 6.

Inspiring
June 13, 2013

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.


Ok. thank you.