I need to make an item draggable (dragable?) Sorry if my terminology is not right!
I have a class where I will store variable and do calculations:
package Classes
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class PrintItem extends MovieClip
{
public var imageLoader:Loader;
public function PrintItem()
{
}
public function loadImage(url:String):void
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
}
}
}
I create a new instance of the class, I pass it an URL in loadImage and I add it to the canvas like this:
var myItem:PrintItem = new PrintItem();
myItem.loadImage("pic.jpg");
this.addChild(myItem.imageLoader);
myItem.imageLoader.x = 50;
myItem.imageLoader.y = 50;
myItem.imageLoader.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
myItem.imageLoader.addEventListener(MouseEvent.MOUSE_UP, dropIt);
But there I am stuck. I need to make this item draggable and write the pickUp and dropIt functions. event.target.startDrag(false); doesn't work (Loader isn't draggable) and event.target.parent.startDrag(false); doesn't work as the whole stage becomes draggable! HELP! Is it because only the Loader is added to the stage?