Monday, May 12, 2008

MovieClip Subclass with Asset

The star image from the previous post can be animated with a MovieClip subclass.

Add a new ActionScript Class in the oas2 subfolder called RotatingStar. Copy and paste this code. Save changes.

Open the main class file, Application.as. Two modifications are required.
  1. Above the class declaration:
    import oas2.RotatingStar ;
  2. At the bottom of the class constructor:
    var my_star2:RotatingStar = RotatingStar.create(this, "my_star2", 250, 100, 400) ;
Save the file, and the SWF file is automatically rebuilt by Eclipse. Click to see a rotating star in the Flash demo.

1 comment:

Anonymous said...

When I add a RotatingStar as you say above, the previous tutorial's (non-rotating) star begins to rotate too! That is, I have one star created with attachMovie, the other with RotatingStar, but they both act the same.

I'm guessing it has something to do with the static_symbol_name() hack corrupting the first movie, but I'm too much of a newb to be sure.