I know this has been answered for several different errors but I can’t find one to match my problem (which seems to be the simplest of all the people who have had this issue).
Basically I am calling a custom class from the FLA. When I test it it works…ie the image and text pop up no problem. However, in the output window it is calling that error (Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.).
I’ve moved the image to check if it is the path but it is not the problem. I’m stumped.
Here is the code in the FLA:
import visuals.MyImages;
var icon_retrofit:MyImages = new MyImages();
icon_retrofit.theLabel = "moose knuckle";
icon_retrofit.myIcon = "images/w.png";
addChild(icon_retrofit);
here is the code for the class that is set up for the image and text:
package visuals{
import flash.display.MovieClip;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.MouseEvent;
import flash.events.Event;
public class MyImages extends MovieClip{
private var _theLabel:String;
private var _myIcon:String;
private var _fontName:String;
private var _fontSize:int;
private var _fontColor:uint;
private var _embedFonts:Boolean;
private var _width:Number;
private var _height:Number;
public function MyImages(
theLabel:String = "",
myIcon:String = "",
// images/default.png
fontName:String = "Arial",
fontSize:int = 14,
fontColor:uint = 0x000000,
embedFonts:Boolean = false,
width:Number = 100,
height:Number = 100) {
_theLabel = theLabel;
_myIcon = myIcon;
_fontName = fontName;
_fontSize = fontSize;
_fontColor = fontColor;
_embedFonts = embedFonts;
_width = width;
_height = height;
buttonMode = true;
mouseChildren = false;
draw();
//trace("code");
}
private function draw():void{
// this is the TextFormat class
var tFormat:TextFormat = new TextFormat();
tFormat.font = _fontName;
tFormat.size = _fontSize;
tFormat.color = _fontColor;
// this is the TextField attributes
var tField:TextField = new TextField;
tField.multiline = true;
tField.wordWrap = true;
tField.selectable = false;
tField.embedFonts = _embedFonts;
tField.defaultTextFormat = tFormat;
tField.autoSize = TextFieldAutoSize.CENTER;
tField.antiAliasType = AntiAliasType.ADVANCED;
tField.text = _theLabel;
tField.x = _width / 2 - tField.width / 2;
tField.y = _height + 1;
addChild(tField);
loadImage();
//trace("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 ("this is the loadImage function");
}
private function imgLoaderOpen(e:Event):void {
//trace("imgLoader load started");
}
private function imgLoaderComplete(e:Event):void {
//trace("imgLoader load completed");
}
// START SETTER FUNCTIONS *********************************************************************************************
// creating 'setter' functions that allow private variables in classes to be assigned new values at any time from the outside
// uses the 'set' keyword to create a function that from outside the class can be treated like a property
public function set theLabel(value:String) :void{
_theLabel = value;
draw();
}
public function set myIcon(value:String) :void{
_myIcon = value;
draw();
//trace ("did this happen");
}
public function set fontName(value:String) :void{
_fontName = value;
draw();
}
public function set fontColor(value:int) :void{
_fontColor = value;
draw();
}
public function set fontSize(value:int) :void{
_fontSize = value;
draw();
}
public function set embedFonts(value:Boolean) :void{
_embedFonts = value;
draw();
}
public override function set width(value:Number) :void{
_width = value;
draw();
}
public override function set height(value:Number) :void{
_height = value;
draw();
}
// END SETTER FUNCTIONS *********************************************************************************************
}
}
any help would be very appreciated. again, the path is correct, no doubt.