» Home » Movies » Tutorials » Submissions » Sound FX » Board » Links » Reviews » Feedback » About FK » Gallery » Fonts » The Lounge » Sound Loops » Sitemap
Login | Register | 651326 Members and growing!
Search tutorials
Author: Gorky | Website: http://
```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 :)

• There are no comments yet. Be the first to comment!

• You must have javascript enabled in order to post comments.

Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.