[OOP] Help with this simple code

Hey guys. So I am trying to get my head around OOP these days. You know trying to keep up with the times. So i wrote this simple class

class buttonUI {
[COLOR=#000087]var[/COLOR] btnLabel:[COLOR=#000087]String[/COLOR];
[COLOR=#000087]var[/COLOR] page:[COLOR=#000087]String[/COLOR];
[COLOR=#000087]var[/COLOR] [COLOR=#000087]target[/COLOR]:[COLOR=#000087]MovieClip[/COLOR]

    static [COLOR=#000087]function[/COLOR] loadPage (btnLabel, page, [COLOR=#000087]target[/COLOR]):Void {
            btnLabel.[COLOR=#000087]text[/COLOR] = btnLabel;
            [COLOR=#000087]target[/COLOR].[COLOR=#000087]loadMovie[/COLOR](page);
    }

}

and in my flash movie I have a dynamic text field with an instance name
of btnLabel and an empty movie clip with an instance name of targetMC.
so in my flash file I use my class like this.

buttonUI.loadPage("[COLOR=blue]Name[/COLOR]", “[COLOR=blue]load.swf[/COLOR]”, targetMC);

the load.swf works and the targetMC works but the label wont change to Name.

here is the example. Al you will see is a black square cus that what it
loads but you will also notice that my text field doesnt change to

“Name”

http://www.creativescientist.com/OOP/test.html

Thanks for your help.

Rob

A) You cannot access non-static variables from a static function. You would want to use static variables with static functions.

B) You cannot access properties of an object using a string to reference that object. You would need an object reference, not just a string. For example, btnLabel is a string, yet you attempt to access btnLabel.text which is not a property of a string (presumably, the property of a label object). Instead use a label in place of that

:slight_smile: