Publishing to Flash 8 with Swfmill and MTASC (or The Return of The Peeing Dog)
There's already quite a bit of information on creating Flash 8 SWFs using MTASC on the FlashCoders Wiki project on OSFlash. In this post, I am going to show you how Swfmill can also output Flash 8 SWFs and how you can use MTASC and Swfmill together to create Flash 8 SWFs using the Natural Entry Point Method.
And yes, the peeing dog is making another appearance.
Creating a Flash 8 SWF using the Natural Entry Point Method is essentially the same as creating a Flash 7 or 6 SWF. To demonstrate, let's make a peeing dog toggle a drop shadow when clicked (this is probably the first time in the history of mankind that this is being attempted, so download the source code and follow along very carefully!)
To start, create a folder for your project. Call it something descriptive, like PeeingDogWithDropShadow.
Inside it, create a folder called "src" for your (drumroll) source files and one called "build" in to which your compiled SWFs will be placed. Finally, inside the src folder, create a folder called "library". This will house a SWF, created using the Flash IDE, containing the animation of the peeing dog (PeeingDog.swf, which is part of the source code download for this example.)
Next, using your favorite editor (OK, your second-favorite will also do), create the main SWFML file for your application (application.xml) and place it in the src folder. The code for it is below:
Notice the version="8" attribute in the movie tag. That's where the magic is :) That will make Swfmill spit out (yuck) a Flash 8 SWF.
Also notice that you are asking Swfmill to import a SWF called classes.swf from the build folder. Needless to say that file doesn't exist yet. Once you have created the two classes you will be using for this example, you will ask MTASC to compile them into the classes.swf file for inclusion in the final application by Swfmill.
So, without futher ado, create the main Application class that will linked to the Application movie clip:
As you can see, it's very simple. All it does is attach an instance of the PeeingDog clip on to the stage.
Here's the code for the PeeingDog class:
In the PeeingDog constructor, you create an instance of the drop shadow filter and then, when the dog is clicked, toggle it on and off by setting the movie clip's filters property. Notice how the filters property is an array. This allows you to add more than one filter to a movie clip in Flash 8 but it also means that even if you are adding a single filter, you still have to wrap it up an array.
Finally, you need to compile the AS2 and SWFML files and build this project.
To start, you need to tell MTASC to compile the two classes you just wrote and place them in a SWF.
To do this, make sure that MTASC and Swfmill are both on your system's path and then open up a command line window and, from the root folder of your project (the one that contains the src and build folders), type the following command:
mtasc -version 8 -swf build\classes.swf -header 1:1:30 -cp src Application.as PeeingDog.as
This will create a Flash 8 SWF (
-version 8) called classes.swf in the build folder (
-swf) that has dimensions of 1px x 1px and a frame rate of 30fps (
-header). It will include the src folder in the classpath (
-cp) and compile the Application and PeeingDog classes into the SWF.
Next, tell Swfmill to compile the SWFML file for the main application using the following command:
swfmill simple src/application.xml build/application.swf
To make it simpler for you, I've provided a file called build.bat that you can run which contains both these instructions.
Once you have built the project, you should find two SWFs in your build folder: classes.swf and application.swf.
Double-click the application.swf file to launch it in the Flash 8 Beta Player. Click on the doggie to toggle his drop shadow on and off.
Download the code (38KB).