PDA

View Full Version : Access of undefined property



kritikal
October 30th, 2008, 04:11 PM
Hey guys,

still pretty new to AS3 so go easy on me :P

I was wondering how do you change the properties of a movie clip from a class that isn't the Document Class.

say I have text_mc on the stage and I want to change it's alpha to 0
If I do text_mc.alpha = 0; inside of the Document Class it works fine but if I do it in another class I get this error
1120: Access of undefined property text_mc

any ideas how to fix this?

kritikal
October 30th, 2008, 04:24 PM
ok well passing the instance name to my constructor inside of my other class did the trick but I have quite a few instances that are on the stage already... any other way of doing that?

HMPoweredMan
October 30th, 2008, 09:29 PM
Well not saying you should, because this goes agains the fundamentals of OOP, but you CAN do this.


MovieClip(root).text_mc.alpha = 0

I personally prefer .visible = false

kritikal
October 30th, 2008, 09:55 PM
well only reason I'm using alpha is to be able to fade it in.

haven't really touched actionscript for a while, been working a lot of C++ and php projects so I'm pretty comfortable with OOP but I'm also used to AS2 and I need to use AS3 on this project.. this whole thing is getting me frustrated....

theCodeBot
October 30th, 2008, 11:08 PM
You could pass the stage to the external class' constructor, and then that class has full access just as the document class does, now that is has access to the stage variable.

kritikal
October 30th, 2008, 11:30 PM
You could pass the stage to the external class' constructor, and then that class has full access just as the document class does, now that is has access to the stage variable.

thanks theCodeBot but I'm not sure how to do that

I tried passing this.stage to the constructor which received it as stageRef:Stage
but that doesn't seem to work... any suggestions?