Link to home
Start Free TrialLog in
Avatar of arasburn
arasburnFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

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?
Avatar of deepanjandas
deepanjandas
Flag of India image

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

Warm Regards
Deepanjan Das
Avatar of arasburn

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of deepanjandas
deepanjandas
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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