The ‘new’ Class keyword and creating dynamic buttons in AS3
I use dynamic movieclips in almost every project I work on and AS3’s new method of adding dynamic movieclips to the stage makes it easy, instead of using AS2’s duplicateMovieClip() method. I will show you some tips and tricks to easily create applications in which dynamic movieclips are used and easily manage those movieclips.
1. Create a movieclip with a linked Class
First create a new AS3 project in Flash and create a new movieclip (Insert > New Symbol…), let’s call it MenuButton. In the Linkage properties (click the Advanced button if needed), check the Export for ActionScript box and for this example just leave all the settings like they are so click OK. You can put anything inside the movieclip you want but for this example I’m putting in a black box with the following properties: X:0, Y:0, width:100, height:20. Now return to the root scene, highlight the empty keyframe and open the actions tab.
9-slice scaling was introduced in Flash 8. It is called 9-slice scaling when you open the property window of a library movie clip (the advanced tab has to be open to see it). This property can also be set in ActionScript and in code, it is called scale9Grid. Enabling this property will split the movie clip into 9 parts: 1 center piece, 4 sides, and 4 corners. When the movie clip is resized, it will keep the outer edge in tact, while the main part gets resized. It does this by resizing the center piece in both width and height, resizing the top and bottom sides in width, resizing the left and right sides in height, and the corners will not be resized at all. What is this used for? This solves the problem of resizing movie clip boxes that have rounded corners. Every developer that used Flash MX or earlier versions of Flash knows that dynamically resizing a movie clip box with rounded corner was a huge hassle. This was a fantastic new feature, but unfortunately, frustrated developers more than it pleased them - it has many bugs.
Hi. My name is Christian Kragh and I'm a freelance Flash designer / developer. Welcome to my blog where I write and hopefully discuss any topics related to freelancing or Flash. I'm currently located in Rochester, NY.








