07.09.2011 10:12
Putting objects of your own class on the Stage within Flash IDE [basic]
While programming interfaces (or similar stuff) in Flash I started asking myself "wouldn't it be cool if Flash had allowed custom objects of my own class on the Stage"? While the truth is it's entirely possibility even since AS2! But the problem is that you won't hear about it anywhere and Flash doesn't really tell if you the object you have put on the Stage is already that of your own class rather than the standard MovieClip.
To see what this feature is useful for I suggest a following test my Dear reader: 1. Download one of those classes: AS2Test.as (ActionScript2 version) or AS3Test.as (ActionScript3 version). 2. In the new Flash project (AS2 or AS3 depending on the downloaded class) create a MovieClip with at least three different animation frames.
3. If you haven't done so already put the downloaded class into your project's folder and then open the MovieClip's (one created in the previous step) properties.
4. Move to the advanced settings and check the "Export for ActionScript", followed by typing in the downloaded class' name ("AS3Test" for ActionScript3 example in the image below).
(For AS2 "Base Class" won't be available while AS3 will have this field empty). 5. Now simply drag and drop your MovieClip from the Library onto the Stage and then compile the animation (CTRL+Enter by default). If everything went smoothing the MovieClip in the animation should react to the mouses cursor movement and clicks. This all might seem like a gimmick, but in practice this could save you a lot of time, especially in bigger project where lot of objects are being reused multiple times.
To see what this feature is useful for I suggest a following test my Dear reader: 1. Download one of those classes: AS2Test.as (ActionScript2 version) or AS3Test.as (ActionScript3 version). 2. In the new Flash project (AS2 or AS3 depending on the downloaded class) create a MovieClip with at least three different animation frames.
3. If you haven't done so already put the downloaded class into your project's folder and then open the MovieClip's (one created in the previous step) properties.
4. Move to the advanced settings and check the "Export for ActionScript", followed by typing in the downloaded class' name ("AS3Test" for ActionScript3 example in the image below).
(For AS2 "Base Class" won't be available while AS3 will have this field empty). 5. Now simply drag and drop your MovieClip from the Library onto the Stage and then compile the animation (CTRL+Enter by default). If everything went smoothing the MovieClip in the animation should react to the mouses cursor movement and clicks. This all might seem like a gimmick, but in practice this could save you a lot of time, especially in bigger project where lot of objects are being reused multiple times.