Skip to main content
December 25, 2009
Question

On click detection

  • December 25, 2009
  • 1 reply
  • 601 views

Here is the thing i have flash game and what i want is when you click somewhare on your flash movie i want flash to detect the position and than to create movement for a designated movie clip from starter point to the selected with the mouse destination and than when it reaches the designated location i want the movie clip to play certain frame... is this possible? and if the second one is not pls tell me how to make the first part with the position detection and than making a movie clip to move form starter point to the detected position

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 25, 2009

you can use:

import mx.transitions.Tween;

this.onMouseDown = function() {
    t1 = new Tween(mc, "_x", mx.transitions.easing.Elastic.easeOut, mc._x, this._xmouse, 3, true);
    t2 = new Tween(mc, "_y", mx.transitions.easing.Elastic.easeOut, mc._y, this._ymouse, 3, true);
};
t1.onMotionFinished = function() {
    // use mc.swapDepths() is mc is not at a removeable depth
    mc.removeMovieClip();
};

December 26, 2009

thanks for replaying but i kind of don't stand how to use the code can you help me by making me a sample .fla file or just guide me whare to put the code and stuff ? thanks a lot

kglad
Community Expert
Community Expert
December 26, 2009

that should be:

import mx.transitions.Tween;

this.onMouseDown = function() {
    t1 = new Tween(mc, "_x", mx.transitions.easing.Elastic.easeOut, mc._x, this._xmouse, 3, true);
    t2 = new Tween(mc, "_y", mx.transitions.easing.Elastic.easeOut, mc._y, this._ymouse, 3, true);
    t1.onMotionFinished = function() {
        // use mc.swapDepths() is mc is not at a removeable depth
        mc.swapDepths(0);
        mc.removeMovieClip();
    };
};