Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Read _droptarget Property in ActionScript
Your Ad Here

Read _droptarget Property in ActionScript


This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

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

Follow the steps below:

  1. Launch Flash Designer and choose "blank".
  2. Set the frame delay to "Stop" ("Frame" > "Frame Delay").
  3. Size the frame at about 300x300. ("Frame" > "Frame Size")
  4. Create 1 small and 1 larger shapes with the rectangle tool and give them different fill colors.
  5. Select smaller shape and click Edit > Convert to Sprite.
  6. Right-click it and click "Placement Properties".
  7. Check the "Action-Script Target" checkbox and click OK.
  8. Click the other shape and repeat the process.

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)



Author's URL: Selteco.com
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Read _droptarget Property in ActionScript"

Only registered users can write comment

No comments yet...