# Var not passing from custom class

**URL:** <https://forum.kirupa.com/t/var-not-passing-from-custom-class/318655>\
**Category:** flash\
**Created:** [January 26, 2011, 2:21pm UTC](https://forum.kirupa.com/t/var-not-passing-from-custom-class/318655 "2011-01-26T14:21:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mightyhokie](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mightyhokie](https://forum.kirupa.com/u/mightyhokie)\
**Post date:** [January 26, 2011, 2:21pm UTC](https://forum.kirupa.com/t/var-not-passing-from-custom-class/318655/1 "2011-01-26T14:21:24Z")

</div>

I have created a custom class. It seems to work (at least no errors), but when I create a button in the actual FLA that calls on the class, it doesn’t change what I want it to change.

Here is the class:  
package visuals{

```
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.navigateToURL;
import flash.net.URLRequest;

public class Icons extends MovieClip{
    
        private var _myIcon:String;

            public function Icons(myIcon:String = "images/default.png") {
                
                            _myIcon = myIcon;
                            // constructor code
                            //trace ("icons class");
                            
                            buttonMode = true;
                            mouseChildren = false;
                            
                            draw();
            }
            
            private function draw():void{
                            loadImage();
            }
            
            private function loadImage():void {
                            var imgRequest:URLRequest = new URLRequest(_myIcon);
                            var imgLoader:Loader = new Loader();
                            imgLoader.load(imgRequest);
                            imgLoader.contentLoaderInfo.addEventListener(Event.OPEN, imgLoaderOpen);
                            imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaderComplete);
                            this.addChild (imgLoader);
                            //trace ("load image");
            }
                                                                    
            private function imgLoaderOpen(e:Event):void {
                            //trace("imgLoader load started");
            }
                                                                    
            private function imgLoaderComplete(e:Event):void {
                            //trace("imgLoader load completed");
            }

}

```

}

========================  
And here is the code in the FLA that calls the class:

import visuals.Icons;

var icon\_retrofit:Square = new Square();  
icon\_retrofit.myIcon = “images/b.png”;  
addChild(icon\_retrofit);

=========================  
When I call for the class to make the button, it works. It also successfull calls the default.png from the class, but in the FLA the icon\_retrofit.myIcon doesn’t change the image to ‘images/b.png’.

what have I done wrong?
