Is it possible to access the parent frame label from code on a timeline inside a movieclip in AS3?

Posted on 2011-04-27
Last Modified: 2012-05-11
I'm familiar and comfortable AS2 but only just beginning to move to AS3.

I have a situation where I regretably have to nest code inside a movieclip and as such I really want/need to access the master timeline frame label.

I have found how to access the FrameLabel in AS3 and have had limited success when working on the same timeline; however as soon as I try and access the data from inside a movieclip I experience errrors.

Please can someone help?
Question by:arasburn
    LVL 17

    Expert Comment

    Try this: MovieClip( root ).gotoAndStop("frameLabel");

    Warm Regards
    Deepanjan Das
    LVL 1

    Author Comment

    Hi Deepanjan,

    No joy.

    More detail...

    On frame 65 of my master timeline I have a movieclip of a thermometer. Frame 65 of master timeline has a frame label of "a_rise_04".

    Inside the movieclip of the thermometer on the main timeline I have code that currently reads:

    import flash.display.FrameLabel;

    var n:Number = this.currentFrame;

    The above when compiled gives no surprises and duly returns a '1' as the trace output.

    If I modify my code to read:
    var n:Number = root.currentFrame;
    var n:Number = this.root.currentFrame;
    var n:Number = this.parent.currentFrame;
    var n:Number = parent.currentFrame;

    I get errors with all the above. I know this code is not going to return a frame label, I decided to try and simplify what I was asking AS3 to do as I feel i have scoping or similar issues.

    Do I need to add an event listener somewhere?

    I used to be able to do all of this sort of thing so easily in AS2, I'm really frustrated as I know it will be something simple.

    Final point, I don't want the master timeline to gotoAndPlay anything, I want the movieclip to query the master timeline frame label so it knows what it should be doing.

    I know this is very much 'cart before the horse' but I am exporting individual image SWF files and they ignore code on the master timeline but seem to pick it up inside the timelines of movieclips.

    LVL 17

    Accepted Solution

    so try this:

    MovieClip( root ).currentFrame;

    Warm Regards
    Deepanjan Das
    LVL 1

    Author Closing Comment

    Thank you so much for your help, you have been invaluable once again.

    Apologies for not following your first comment properly, I was interpreting what you wrote and trying to fit my code knowledge into it, rather than taking it at face value and literally writing what you suggested.

    It works, I'm very happy!

    Thank you again

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now