Topic: ActionScript Gurus (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11225" title="Pages that link to Topic: ActionScript Gurus (Page 1 of 1)" rel="nofollow" >Topic: ActionScript Gurus <span class="small">(Page 1 of 1)</span>\

 
kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 09-19-2001 00:48

Ok all you AS gurus, I need some help understanding why a script works like it does. In this file:
http://www.krets.net/misc/shoppy.swf

You can drag the right gift onto the bag and it will disappear. The gift is basically a movie symbol with two keyframes. Frame 1 is the bag with a stop action on it and frame 2 is blank.

Here is the action script on the gift button symbol in the movie clip...

code:
on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}
on (release) {
target = GetProperty("",_droptarget);
if (target ne "") {
gotoAndStop (2);
}
}



In the line which sets the target, how does that work? I've looked for a property or value on the bag but can't find one. I'm not sure how that script defines the target.

Help would be much appreciated....

Here is the .fla file too....
http://www.krets.net/misc/shoppy.fla

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 09-19-2001 06:10

Huh. That's Flash 4 syntax, and I really just learned ActionScript with Flash 5. If I were coding Flash 5 , I'd use a hitTest to evaluate whether the gift was intersecting the bag.

I'll see what I can find out about the _droptarget thingie there.

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 09-19-2001 12:49

interesting. Well, I leaned something. _droptarget will return the path to any movie clip underneath the one dropped, in slash notation. Wow! In this movie, they use drop target simply to test for whether the present was dropped on the bag (in other words, if the _droptarget does not return "nothing", then play frame two).

But - if you had six bags and the box could be dropped on any of them, and you wanted to know which one it got dropped on...... useful!

Thanks krets.

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 09-19-2001 14:42

Thanks Steve. I've been teaching Flash here lately and am starting to become more comfortable with AS. I just couldn't figure out how that _droptarget worked. I thought it might be something with the movie clip of the bag because the other gift symbol is a button, not a movie.

Cool!

So then I assume that if you wanted to have more than one draggable box clip you would have to give the gift bag a name and then change the line so that instead of using a ne "" you would use a eq "gifttarget" and change the the GetProperty line accordingly.....?



[This message has been edited by kretsminky (edited 09-19-2001).]

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 09-19-2001 15:04

First of all, you want to start writing Flash5 syntax: the comparison operators in Flash 5 are == for equality, and != for inequality ("ne" is Flash 4 for inequality). The older style "getProperty" should be updated too, to dot syntax. And the two "onRelease" statements could be combined into one.

>>So then I assume that if you wanted to have more than one draggable box clip you would have to give the gift bag a name and then change the line so that instead of using a ne "" you would use a eq "gifttarget" and change the the GetProperty line accordingly.....?

If I understand this correctly, _droptarget returns the path to the thing the dragger was dropped onto. In this case, it would return the path to the bag MC, whatever it was named. If you had multiple boxes dropped onto a common bag (or shopping cart or whatever), and you wanted to keep track of which boxes were dropped into one bag, you'd need some other solution.

You could also take this a step farther. Initialize the start x and y of the box. If it misses the target (ie, if _droptarget returns nothing), the box will return to its starting coordinates. That could be cool!

I bought Colin Moock's ActionScript the Definative Guide - if you are teaching Flash and trying to get a grasp on Flash5 ActionScript, this book is superb. Really. No other word.

And - if you have trouble getting to sleep at night - well, three of four pages generally does it for me!

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 09-19-2001 15:32

Exciting reading eh?

Thats strange that the courseware we are using would use Flash 4 syntax for Flash 5. Its generally very good courseware written by experts in their field. I'll have to look into that book.

I'm really liking what I am learning about 5, you can do some great stuff with it. I'll have to look into it more.

Fig
Paranoid (IV) Mad Scientist

From: Houston, TX, USA
Insane since: Apr 2000

posted posted 09-20-2001 16:11

Hehe, yeah, I need to pick up that one for reference. I'm working thru (when I have time) Foundation Actionscript right now and it's awesome, great book, easy to read, and I'm learning a ton...

Chris


KAIROSinteractive

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 09-22-2001 23:59

I bought Foundation ActionScript today.

I looked at the Definitive Guide as well but I just thought that the other one did a much better job of presenting the material with more visual aids to help.

Its been a blast so far going through it, I've learned a ton.


Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 09-23-2001 13:19

Well, the 2 books have different intentions. I have 'em both. Foundation ActionScript holds your hand more, and is certainly WAY more entertaining to read. Is Foundation ActionScript going to have an index that includes _droptarget? I don't think so. Foundation ActinScript shows how to use, let's say, the sound object. Cool. Want to know what an "object" *is*, not just how to use it? Want to know *why* you declare a new sound object?

Well, bottom line - it's good to have 'em both. 'Specially a teacher who's likely to be asked strange and obscure questions. Like - "how does _droptarget work?"



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu