Flash Tips : Class Linkage
Let’s say you’ve created a fantastic new class and want to link it to a movie clip you’ve created in Flash. How do you let Flash know that you want to use that class with that particular movie clip? The answer is fairly straightforward.
First of all we’ve created a simple class extended from MovieClip and titled it DraggableShape. This class basically makes a movie clip draggable. So we create a red circle on the stage, convert it to a movie clip by hitting F8, and naming it redCircleMC. The redCircleMC movie clip will now appear in the library for this particular .fla file. If you can’t see the library, hit Ctrl-L. Right click on the redCircleMC item and choose the Linkage… option. Check the Export for ActionScript checkbox, which automatically checks the third check box as well. On the first line, type in the instance name and on the second line, type in the class to which you want the movie clip to link; in this case the class DraggableShape.
|
Hit Ctrl-Enter and view the movie clip. You should now be able to drag your red circle all over the screen of your .swf. The resulting .swf is featured below. If using Internet Explorer, click in the frame to activate.
