I'm new to flash, actionscript, and the class/method/static/instance paradigm. I do have one class that I use, it loads a png file and adds it to the stage, I can then manipulate it with the mouse. What I want to do is add some text on top of the png file. When the user clicks and drags the png file around, I want the text to stick with it, basically make it part of the png, overlay it, combine them, group them, whatever.
Here is the class I am using to load the png.
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.*;
import flash.net.URLRequest;
public class element_icon extends MovieClip {
public function element_icon(type) {
var imageLoader:Loader = new Loader();
var theURL:String = "images/" + type + ".png";
var imageRequest = new URLRequest(theURL);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
imageLoader.load(imageRequest);
function onIOError(e:IOErrorEvent):void{
var theURL:String = "images/default.png";
var imageRequest = new URLRequest(theURL);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
imageLoader.load(imageRequest);
}
function onComplete(evt:Event) {
addChild(imageLoader.content);
}
}
}
}