A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5848 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


Random Links | Add your own Flash Related Links
Flash Tutorials 1277 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Trading Customer Accounting (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories Drag, Drop and Swap
Author: Gorky

 
Page 5
«prev 1 2 3 4 5 6 7 next»

On (Press)
 Set Variable: "/:current_targetX" = GetProperty ("", _x)
 Set Variable: "/:current_targetY" = GetProperty ("", _y)
 Set Variable: "/:ballnum" = 1
 Call ("/code:OnPress")
 Start Drag ("", L=45, T=45, R=455, B=255)
End On
On (Release, Release Outside)
 Call ("/code:OnRelease")
 Stop Drag
End On

The basic action here is the drag action, which is accomplished using the Start Drag command on a mouse action. Before we start the drag, we assign the 'current_target' variables contained in the last piece of code to the current x and y loc of the ball we just click on. We also set the ballnum variable to 1, which is the number of the ball we just clicked on. Depending on which movie clip you are putting this code into, change this number the number of that movie clip. For example, when you put this code into movie clip 4, then you will set 'ballnum' to 4. After 'ballnum' is set, the OnPress code is called. Here it is.

Set Variable: "/:first" = eval("/:ballpos" & /:ballnum)
Set Variable: "num" = 0
Loop While (num <= 6)
 If (/:ballnum <> num)
 Set Property ("/ball" & num, Visibility) = 0
 End If
 Set Variable: "num" = num + 1
End Loop

The first line sets the 'first' variable to the same number as ballpos1 (or ballpos2, whichever ball you are dragging). A quick word on the ballpos variable. Its not very intuitive, but ballpos1 = 4 means that ball1 is on the 4th target. ballpos5 = 3 means ball 5 is on the 3rd target etc. What the 'first' variable does basically is to store which target you are pulling your dragable movie clip from. So if you begin dragging ball 3 from target 6, first gets set to 6. As you saw in the initialization code, ballpos1 - ballpos6 all get set to 1-6 initially.

The loop contained in this part of the code sets ball1 through ball6 (except the one you are dragging) invisible.

Here is where I need to explain why I have two sets of dragable movie clips, and the need for the loop just described. Basically, its all for looks. If we take away the stayers layer, and remove the previous loop from the movie, it will all still work except that when you go to drag one of the movie clips, many of them will appear beneath the other ones when dragged across them. Each movie clip has its own depth even though they are all on the same layer, and since you can't change depth in actionscript, the only way I could figure out how to always make them appear on top of all the other ones when you are dragging them is to do it this way.

So now, when you start dragging a movie clip, all the other movie clips on that layer disappear, but you don't see it since there are duplicates of those clips on the stayers layer. Since all the movie clips except the one you are dragging (on the 'draggers' layer) are now invisible, the one you are dragging will never appear to be behind anything. If you don't know what I mean, delete the stayers layer, remove this loop from OnPress, and remove the loop that turns the visibility back on (this loop is in OnRelease), then run it and drag some stuff around. If anyone knows a simpler way to do this I would appreciate the knowledge :)


«prev 1 2 3 4 5 6 7 next»

» Level Advanced

Added: : 2000-06-28
Rating: 7.01 Votes: 182
Hits: 14049
» Author
--
» Download
Download the files used in this tutorial.
Download (16 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs