Welcome to WebmasterWorld Guest from 54.166.117.130

Forum Moderators: open

event.target problem

   
9:23 pm on Jul 19, 2008 (gmt 0)

5+ Year Member



I've read that you can use the following code so that several different movie clips could use the same function:

function pickUp(event:MouseEvent):void {
event.target.startDrag();
}

But that doesn't work for me. It only works if I specify the actual movieclip name such as:

function pickUp(event:MouseEvent):void {
myMovieClip.startDrag();
}

Does anyone know why the first snippet doesn't work? I really want to be able to use that so I don't have to have several dozen functions that do the same thing.

2:14 pm on Aug 8, 2008 (gmt 0)

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



Don't know. How's this coming along?
12:45 am on Aug 15, 2008 (gmt 0)

10+ Year Member



Try using currentTarget. Some more details would be helpful, like whether there are children of the movie clip?
3:27 am on Aug 15, 2008 (gmt 0)

5+ Year Member



Holy crap, that worked perfectly chronic!

THANK YOU

function pickUp(event:MouseEvent):void {
event.currentTarget.startDrag();
}

function dropIt(event:MouseEvent):void {
event.currentTarget.stopDrag();
}

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month