We help IT Professionals succeed at work.

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

arasburn
arasburn asked
on
Medium Priority
519 Views
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?
Comment
Watch Question

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

Warm Regards
Deepanjan Das

Author

Commented:
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;
trace(n);

---
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.

Cheers,
Ady
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Deepanjan,
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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.