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

Getting frame number of movieclip within movieclip

Guest
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

Hey guys, really simple question--how do I get the frame number of a movieclip within a movieclip? Say I have mc2 nested within mc1. Whenever i try to say mc1.mc2.currentFrame, I get


TypeError: Error #1010: A term is undefined and has no properties.

at blobgame2_fla::MainTimeline/loop()


I would attach my fla if this forum would let me.

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

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
LEGEND ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

It depends on how you added mc2 to mc1.  If you did it manually, then what you show would be correct as long as you assigned those instance names to the movieclips via the Properties panel.

If you added mc2 to mc1 dynamically, then you either need to target it directly (mc2.currentFrame) or via using 'getChild...'-type targeting... such as in mc1.getChildAt(0).currentFrame (might need to cast it as a MovieClip)

Votes

Translate

Translate

Report

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
Guide ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

You shouldn't be doing this. For one thing, you're likely to wind up with race conditions that mean you can never be sure what exists yet and what doesn't. For another, if you need to change the way mc1 is built, then everything with a "hard" reference to mc2 will break until you dig around and fix it. You should build mc1 to do whatever needs to be done or generate an event (depending on your real end goal).

What are you trying to do that you need the frame number for?

Votes

Translate

Translate

Report

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
Guest
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

LATEST

Either mc1 or mc2 is undefined. Trace them to see... and Ned's answer is spot on as well.

Votes

Translate

Translate

Report

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