|
Selteco.com > FlashDesignerZONE.com >
Tutorials > T1048
Read _droptarget property in ActionScript.Drag blue rectangle over the yellow. If you drop the blue one on the yellow, the script will align blue rectangle inside the yellow.
NOTE: Minimum Flash Designer version 5.0.17 (verify revision number under "Help" > "About...", download update if required) Follow the steps below:
Smaller shape (blue) should appear as "Sprite3" and larger (yellow) as "Sprite4". If necessary rename the sprite: select it and choose "Item" > "Placement Properties" Choose "Frame" > "ActionScript" and paste the code:
Sprite3.onPress = function()
{
Sprite3.startDrag();
};
Sprite3.onRelease = function()
{
if(Sprite3._droptarget=="/Sprite4")
{
// align Sprite3
Sprite3._x = Sprite4._x + (Sprite4._width-Sprite3._width)/2;
Sprite3._y = Sprite4._y + (Sprite4._height-Sprite3._height)/2;
};
Sprite3.stopDrag();
};
Press F9 to preview the movie.
_droptarget always returns the path with a leading slash /. Download source project t1048.zip (4 kb)
|
|
Products
|
Purchase
|
Downloads
|
Support
|
Flash Tutorials
|
Contact
Copyright © 1999-2013 Selteco Software, Inc. www.selteco.com, ph: +1 810 377 5778 |