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

Posted on 2011-04-27
Medium Priority
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
  • 2
  • 2
LVL 17

Expert Comment

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

Warm Regards
Deepanjan Das

Author Comment

ID: 35482183
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

deepanjandas earned 2000 total points
ID: 35482428
so try this:

MovieClip( root ).currentFrame;

Warm Regards
Deepanjan Das

Author Closing Comment

ID: 35482776
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 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