1. Home
  2. Computing & Technology
  3. Animation

ActionScripting Challenge: Flash Candy Heart Explained

By , About.com Guide

8 of 9

The last thing to do is write the ActionScripts that control the behavior of the candy heart. There are two separate sets of scripts we need to write; the first governs which candy heart out of the stacked symbols is displayed atop the others by using [linkurl=http://animation.about.com/od/flashanimationtutorials/ss/swapdepthstabs.htm]swapDepths[/link] based on the user's color choice - and makes sure that the text field is pulled to the top as well, so that changing the depth of the candy heart doesn't eclipse the text field. Right-click on one of the symbols representing color options and open the Actions panel:
on (release) {
_root.pink.swapDepths (3);
_root.texty.swapDepths (5);
_root.texty.heartmessage.textColor=0xCC3366;
}

You'll notice that I also used to change the color of the text inside the dynamic text field (instance name heartmessage) inside the symbol texty, assigning a hexadecimal value chosen in a shade to correspond with the color of the heart - darker pink for the pink heart, darker purple for the purple heart, etc.

Overall, this script pulls the pink heart (instance name pink) up to a depth of 3, then sets the symbol containing the dynamic text field (texty) atop it at a depth of 5, before changing the text color. You can copy-paste the script for each of the buttons for the color options, and just change the instance name being swapped to a depth of 3 (green, blue, yellow, etc.) and the hex value determining the color of the text.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. ActionScripting Challenges
  6. ActionScripting Challenge: Flash Candy Heart Explained

©2009 About.com, a part of The New York Times Company.

All rights reserved.