Hi,
I’m creating a little project that allows you to drag some images.
I get this Error when I try to drag the images
ReferenceError: Error #1069: Property startDrag not found on flash.display.Loader and there is no default value.
at Icon03/beginDrag()
Here is my code
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class Icon03 extends Sprite {
private var xml:XML;
private var xmlList:XMLList;
private var xmlLoader:URLLoader=new URLLoader;//creates a new URL loader. xmlLoader
private var iconLoader:Loader;//=new Loader();// // creates a new loader. iconLoader
private var i:int;
private var iconContainer:Sprite;// = new Sprite();
private var mIcon:Sprite;
public function Icon03() {
xmlLoader.load(new URLRequest("Icon.xml"));//load Icon.xml
/*********************** Event handlers **********************/
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);// xmlLoader complete call function xmlLoaded
}
function xmlLoaded(evt:Event):void {
xml=XML(evt.target.data);
xmlList=xml.children();
for (i=0; i < xmlList.length(); i++) {
mIcon=new Sprite ;
iconContainer=new Sprite ;// creates a new Sprite. iconContainer
iconLoader=new Loader ;// creates a new loader. IconLoader
iconLoader.load(new URLRequest(xmlList*.attribute("icon")));//load icon from xml file
iconLoader.name=xmlList*.attribute("filename");//Name the icons with "filename"
iconContainer.name=iconLoader.name;
iconLoader.x=i * 100;
mIcon.graphics.beginFill(0xFF0000);
mIcon.graphics.drawRect(iconLoader.x,iconLoader.y,70,70);
mIcon.graphics.endFill();
//addChild(mIcon);
//addChild(iconContainer);
//iconContainer.addChild(iconLoader);
//iconContainer.mouseChildren=false;
iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,iconLoaded);// iconlLoader complete call function iconlLoaded
}
}//xmlLoaded
function iconLoaded(evt:Event):void {
evt.target.loader.addEventListener(MouseEvent.MOUSE_DOWN,beginDrag);// Mouse down begin drag
evt.target.loader.addEventListener(MouseEvent.MOUSE_UP,endDrag);// Mouse up stop drag
//trace(evt.target.content.name)
addChild(evt.target.loader);// add icon to stage
//iconContainer.addChild(iconLoader)
}
public function beginDrag(evt:Event):void {// start drag
//trace(evt.target.name);
trace(evt.currentTarget.content.name);
evt.target.startDrag();
}
public function endDrag(evt:Event):void {//end drag
evt.target.stopDrag();
}
}//Icon03
}//package