PDA

View Full Version : _root replacement for AS3 for object referencing



Toiletfreak
January 20th, 2008, 09:24 PM
Hello,

I am having some problems with accessing objects on the main timeline.

I am calling this function registerMenuButtons() from a function getDimensions() in AS3:

function getDimensions():void {
registerMenuButtons();
}

and registerMenuButtons accesses a textfield in a movieclip on the main timeline:

function registerMenuButtons():void {
graphics_gr.start_txt.text = "start"
}
however it seems to be a null object reference, text does not change.

In AS 2 I would have used _root to reference graphics_gr.start_txt.text. However I understand that it does not exist anymore. So I defined a variable called ref = this.root, and when I trace ref.graphics_gr it gives me "[object] point1. However this does not apply for start_txt, and instead when i try ref.graphics_gr.start_txt it gives me a null reference.

Is there any way to use a similar method like _root in AS2 to access an MC? Really don't know what's the problem, and I am not using any custom Document Class at the moment. Thanks!

Toiletfreak
January 20th, 2008, 11:33 PM
After doing a bit of experimenting I think it is a problem with gotoAndStop(2), when i "jump" to a new frame in an MC, i can't seem to reference the objects on that frame, why is this so ? thanks!

springframework
January 21st, 2008, 06:04 AM
ive noticed that if an object doesnt exist in every frame of a MovieClip, then you cant refference it with "getChildByName()"



*̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡ ̴̡ı̴̴̡
actionscript 3.0 vancouver jesse couch (http://www.jessecouch.com)

Toiletfreak
January 21st, 2008, 09:26 AM
ive noticed that if an object doesnt exist in every frame of a MovieClip, then you cant refference it with "getChildByName()"



*̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡ ̴̡ı̴̴̡
actionscript 3.0 vancouver jesse couch (http://www.jessecouch.com)


okay ty, will try it tomorrow :)