Skip navigation
Currently Being Moderated

Getting frame number of movieclip within movieclip

Jul 3, 2012 1:54 PM

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.

  • Currently Being Moderated
    Jul 3, 2012 2:37 PM   in reply to the.hams

    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)

    Mark as:
  • Currently Being Moderated
    Jul 3, 2012 4:56 PM   in reply to the.hams

    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?

    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 2:24 PM   in reply to the.hams

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

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points