FORUMS: list search recent posts

Drag & Drop question

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kenn Macintosh
Drag & Drop question
on Aug 30, 2008 at 5:34:28 pm

I've searched the database on Drag and Drop Action Script and found them too complicated for what I need. I just want the user to drag a movie clip and release it over a box and then jump to frame 22. I'm going to assume the user is not stupid and will at least get it close to the drop box before release. With the attached script (AS 2.0), I can get the movie clip to drag and release, but when I release it, it doesn't jump to frame (22) and begin to play. You can DL the FLA file off my server.

http://www.animationsunlimited.com/public/buttontest.zip


Thanks, Kenn

CODE.............

on (press) {
startDrag(this);
}
on (release) {
gotoAndPlay(22);
stopDrag();


}



Return to posts index

Richard Williams
Re: Drag & Drop question
on Aug 30, 2008 at 8:58:06 pm

Hey Ken,

You were not a million miles away... you just have to tell it what you want to go to frame 22...

on (press) {

startDrag(this);

}
on (release) {

stopDrag();
_root.gotoAndPlay(22);


}

This still does not make any difference where you drop the movie clip though. Try this tutorial...

http://www.actionscript.org/resources/articles/26/1/Drag-n-Drop-and-Drop-Ta...

Hope this helps




Return to posts index

Kenn Macintosh
Re: Drag & Drop question
on Aug 31, 2008 at 12:41:27 am

Richard,

Yep. adding "_root" works just honkey dory. I guess that was the root cause of the problem . What does "_Root" do anyway? Does that define the path or something like that? As you can tell, I'm not a syntax guru.

I added ("true,150,150,370,150" per the tutorial you linked me to) to keep the user from moving the mouse all over the place. Even if they get it close to the "virtual" drop location, that's all that matters, because when it jumps to (22), it looks like they got it in there. Here's the modified code if anyone is interested in a way to D&D and object and have it move to another frame w/o having to do all the code for targets..



on (press) {
startDrag(this,true,150,150,370,150);
}
on (release) {
stopDrag();
_root.gotoAndPlay(22);
}


Here's the FLA if anyone wants to see how it was done..

http://www.animationsunlimited.com/public/buttontest5.zip

Cheers,
Kenn



Return to posts index


Pieter Helsen
Re: Drag & Drop question
on Aug 31, 2008 at 12:48:42 am

Yes, _root is a reference to the main timeline in AS2. Each object on the scene has a certain scope. What you did in the beginning could also be translated as this:
on (release) { 
stopDrag();
this.gotoAndPlay(22);
}

That makes it a little easier to explain. Basically what you're doing is tell flash to go to and play frame 22 of this object. And since you added the action to the button, this object is in this case the button. So it tried to go to frame 22 of the button, but since there wasn't anything in that frame, nothing happened.

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]