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

Movie clip added by addChild won't start immediately.

Explorer ,
Jun 10, 2013 Jun 10, 2013

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?

TOPICS
ActionScript
2.0K
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 ,
Jun 10, 2013 Jun 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);

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

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

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 ,
Jun 10, 2013 Jun 10, 2013

did you add two traces?

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

yes. What sould I do to fix this?

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 ,
Jun 10, 2013 Jun 10, 2013

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?

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

Maybe I am wrong? I still get dual frame 1.

I uploaded my fla file.Please check it.

http://www.2shared.com/file/94V1m1Cs/addChild_test.html

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 ,
Jun 10, 2013 Jun 10, 2013

that's a spam site.

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

Ok. How about this site? I reuploaded. It's clean I guess.

http://fast-uploader.com/start/6926452337251/?fileId=6926452337251

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 ,
Jun 10, 2013 Jun 10, 2013

doesn't work for me.

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
Explorer ,
Jun 10, 2013 Jun 10, 2013

http://fast-uploader.com/file/6926452337251/

sorry. try this and click the link at the bottom of the page.

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 ,
Jun 10, 2013 Jun 10, 2013

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

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
Explorer ,
Jun 12, 2013 Jun 12, 2013

so what should I do to start it immediately ? I need to add gotoAndStart or something?

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 ,
Jun 12, 2013 Jun 12, 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.

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
Explorer ,
Jun 13, 2013 Jun 13, 2013

Ok. thank you.

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 ,
Jun 13, 2013 Jun 13, 2013
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