# \[OOP\] Help with this simple code

**URL:** <https://forum.kirupa.com/t/oop-help-with-this-simple-code/186524>\
**Category:** Uncategorized\
**Created:** [April 21, 2006, 10:58pm UTC](https://forum.kirupa.com/t/oop-help-with-this-simple-code/186524 "2006-04-21T22:58:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artofacks1](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Artofacks1](https://forum.kirupa.com/u/Artofacks1)\
**Post date:** [April 21, 2006, 10:58pm UTC](https://forum.kirupa.com/t/oop-help-with-this-simple-code/186524/1 "2006-04-21T22:58:06Z")

</div>

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](http://www.creativescientist.com/OOP/test.html)

Thanks for your help.

Rob

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [April 21, 2006, 11:36pm UTC](https://forum.kirupa.com/t/oop-help-with-this-simple-code/186524/2 "2006-04-21T23:36:19Z")

</div>

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

🙂
