Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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 ...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Ned,
Any luck in helping me figure this out?
fs ...
Fernando Serna
Newspaper Adviser, Adobe Certified Associate
Photojournalism, Flash Animation
On Wed, May 6, 2015 at 3:40 PM, Fernando Serna <fernando.serna@nisd.net>
Copy link to clipboard
Copied
I took a quick look at your file and I can see right off the bat where the problem is because there is a compiler error right off the bat. As I indicated in my previous response, when you get flashing like you said you get it usually means there is a coding error, and the coding error shows up in the Compiler Errors panel. It is indicating that line 19 in frame 2 has a problem... it is unable to find anything named person_mo. That is because there is nothing in frame 2 that you have assigned an instance name of person_mo.
Copy link to clipboard
Copied
Thanks. I'm going to place several instances (and name them person_mo1,
person_m2 ...) of person_mo, and try to code it so the movie clip begins to
play. I may be back in touch.
Really appreciate the help.
fs ...
Fernando Serna
Newspaper Adviser, Adobe Certified Associate
Photojournalism, Flash Animation
On Wed, May 13, 2015 at 12:02 PM, Ned Murphy <forums_noreply@adobe.com>
Copy link to clipboard
Copied
I tried it with just one and saw its head pop when I scoped it, so you should be alright as long as you manage it properly.
Copy link to clipboard
Copied
Send me the code, please, just to make sure I code it correctly. Umm, one
other thing. I'd like to be able to click on the PlayAgain button and
return the animation to the first frame to begin the game once more. Do I
do the same thing as with the person_mo?
fs ...
Fernando Serna
Newspaper Adviser, Adobe Certified Associate
Photojournalism, Flash Animation
On Wed, May 13, 2015 at 1:50 PM, Ned Murphy <forums_noreply@adobe.com>
Copy link to clipboard
Copied
I did nothing to the code. I just named one of the instances "person_mo"
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now