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?