Welcome to WebmasterWorld Guest from 107.22.66.11

Forum Moderators: open

Message Too Old, No Replies

Import Photo to Flash

And then be able to click and drag it

     
12:27 am on May 19, 2008 (gmt 0)

New User

5+ Year Member

joined:Sept 14, 2007
posts: 14
votes: 0


I want to be able to import an external image file and then click and drag that image around.

Here is the AS3 code I have in the first frame:

var loader = new Loader();
square_mc2.addChild(loader);
loader.load(new URLRequest("images/image1.jpg"));

square_mc2.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
square_mc2.addEventListener(MouseEvent.MOUSE_UP, dropIt);

function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
event.target.parent.addChild(event.target);
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget) {
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
}
}
square_mc2.buttonMode = true;

That code allows me to click and drag around the square_mc2 Movie Clip and it also imports an image for that clip. ***I want the image to cover the entire movie clip and then be able to drag that image around. The problem I have is the image itself isn't clickable... I have to leave a small portion of the Movie Clip exposed so I can click the MOVIE CLIP and move it and the image around.

How can I fix this?

Many thanks

5:46 pm on July 8, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


Get this working yet? You might get some help from a google search on your issue.