Skip to main content
Serna7
Participating Frequently
May 6, 2015
Question

Flash CS5, AS3, Stop Drag, Add Up Release for a separate function

  • May 6, 2015
  • 3 replies
  • 1101 views

Using AS3 in Flash CS5, I have a movie clip where I've placed start drag and stop drag actions, and I'd like to activate a button action (run a movie clip named person_mo) with the ReleaseToDrop function. However, I do not know how to add the right code snippet or code it correctly. Here is the AS I have for the drag: 

    stop(); 

    /* Drag and Drop Makes the specified symbol instance moveable with drag and drop. */ 

   

    SCOPE2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag); 

   

    function fl_ClickToDrag(event:MouseEvent):void

    {    

   

    SCOPE2.startDrag();

   

   

    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop); 

   

    function fl_ReleaseToDrop(event:MouseEvent):void

    {    

    SCOPE2.stopDrag();

    }

How can I play the person_mo movie clip and stop the drag?

This topic has been closed for replies.

3 replies

Serna7
Serna7Author
Participating Frequently
May 6, 2015

The scope is what is dragged. It shows the stick guy (person_mo movie clip), and the intent is to have the movie clip play once the mouse is released. Thus, the stick guy loses his head. It's a shoot the stick guys game with a timer bar counting down ten seconds. At that instance, where the player can drag and drop (or release) the scope, the clip should play every time. However, after inserting

function fl_ReleaseToDrop(event:MouseEvent):void

    {   

    SCOPE2.stopDrag();

     person_mo.play();

    }

following:

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);


it began flashing.



Serna7
Serna7Author
Participating Frequently
May 6, 2015

I recall trying the stopDrag function, but it caused the movie to flash back and forth from the first frame to the last frame. I have a three-frame movie with movie clips, the main one has 11 frames with frame-by-frame animation and stops in frames 1 and 11. Frames 1 and 3 in the main timeline also have stops.

Here is the fist frame and actions:

Frame 2 SCOPE and person_mo clips (each stick figure is the person_mo with a button in the first frame and stops actions in frames 1 and 11):

Person_mo clip with button:

Frame 2 actions:

I appreciate the help. fs ...

Ned Murphy
Legend
May 6, 2015

What did you try when it flashed the frames?  That is usually an indication of a coding error.

It is difficult to tell what you are doing even with all the pictures you show.   Based on the last two you show, it looks like you have the animation planted inside the UP frame of a button symbol.  If you do that then there is no way to control that symbol because a button symbol cannot have any other properties than it is assigned by Flash.  You should remove it from the button symbol and just use the movieclip itself if you want to drag it around.

Serna7
Serna7Author
Participating Frequently
May 6, 2015

The scope is what is dragged. It shows the stick guy (person_mo movie

clip), and the intent is to have the movie clip play once the mouse is

released. Thus, the stick guy loses his head. It's a shoot the stick guys

game with a timer bar counting down ten seconds. At that instance, where

the player can drag and drop (or release) the scope, the clip should play

every time. However, after inserting

function fl_ReleaseToDrop(event:MouseEvent):void

{

SCOPE2.stopDrag();

person_mo.play();

}

following:

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

it began flashing. I've attached the FLA and SWF. The FLA would not upload,

so I used Google drive to insert it.. I appreciate you helping.

fs ...

GameAS3.fla

<https://docs.google.com/a/nisd.net/file/d/0B-rH1XLAyumhSF9mZ1ZadW1haW8/edit?usp=drive_web>

Fernando Serna

Newspaper Adviser, Adobe Certified Associate

Photojournalism, Flash Animation

Ned Murphy
Legend
May 6, 2015

Start with the following change and then explain more if it does not work.

    function fl_ReleaseToDrop(event:MouseEvent):void

    {    

    SCOPE2.stopDrag();

     person_mo.play();

    }