In dem Blog von dieFirma findet man ein gute Anleitung zu der Verwendung von dem PlugIn FDT von den Powerflashern, sowie deren Tool SOS zum Tracen außerhalb der Flash-IDE und dem OpenSource Compiler MTASC in Eclipse.
Hier geht’s zum Tutorial
——————————–
Ab hier das Original von http://blog.diefirma.de
As I recently wrote, I’m using FDT for developing Flash projects. For compiling I always used the usual MM-Compiler, remote-controlled by the FDT – Flash Launcher. Today I gave MTASC a new try and together with the Socket Output Server SOS I got a pretty powerful development enviroment. If you ask: “Ok, but what’s the use of MTASC?†– here is the answer.
I tried MTASC before and found it sometimes a little bit difficult to gather all the information I needed. As a result I decided to publish a little Howto. Here it is:
At first you need MTASC. Put it somewhere on your computer. Set up your FDT Flash Project and link the MTASC “stdâ€-folder as your Core Library. Now it’s time to configure the FDT MTASC Launcher. You can see the basic steps in this demo movie!
It shows how to create a swf-file without the Flash IDE. But often you want to use Flash to set up some graphics and put them into the library. Of course there are also some great OS tools like swfmill, but if you have already the IDE, why don’t use it for setting up the graphical elements?
Ok, so create a .fla, create some kind of “ball†MovieClip and put it into the library. Give it the linkage name “ballâ€. Save and publish the movie (â€ball.swfâ€) with Flash and then close Flash. You won’t need it anymore.
Stop!? But where is the code?
Here comes the magic: MTASC is able to “pimp†your compiled swf by injecting your AS2 classes into an existing file! Hence you have to change the MTASC arguments a little bit.The default FDT setting is like that:
-header 800:600:25 -main -swf default_mtasc.swfThe -header argument tells MTASC to create a complete new swf-file. But we don’t want that. We want to “extend†the existing ball.swf! To do that, just remove the complete -header argument. Now your MTASC args look like that (I publish my swfs in an extra deploy-folder):
-main -swf deploy/ball.swfThe FDT automatically adds the main class and the classpath (-cp). But stop – where is our main class? Here it is:
import de.diefirma.mtasc.Core; /** * @author Daniel Heidecke */ class de.diefirma.mtasc.MainApp { public static function main() : Void { Stage.align = "TL"; Stage.scaleMode = "noScale"; var c : Core = new Core(_root); } }That is the entry point of our application. As you see I create a new Object of my Core class:
import de.diefirma.mtasc.Ball; /** * @author Daniel Heidecke */ class de.diefirma.mtasc.Core { private var target : MovieClip; private var ballMc : Ball; public function Core(target : MovieClip) { this.target = target; Object.registerClass("ball", Ball); ballMc = Ball(target.attachMovie("ball", "ballMc", target.getNextHighestDepth())); } }There I register the class “Ball†with the ball clip in the library. Then I attach it to the _root. Here is the Ball-code:
/** * @author Daniel Heidecke */ class de.diefirma.mtasc.Ball extends MovieClip { public function Ball() { trace("hello mtasc!"); } public function onEnterFrame() { this._x += 2; this._y += 2; trace("my position: x: " + this._x + " - y: " + this._y); } }Ok – now you are ready to go. Set up a the MTASC Launcher as you already learned, change the arguments as showed above and get ready to rumble! MTASC compiles the three AS 2.0 classes into the existing ball.swf and tataa(!) when you open the swf (or watch it in the FDT/Eclipse internal SWF Viewer) you see the ball rolling on the stage! And all without using the Flash IDE!
That’s cool, but where is our trace statement? Here comes the Socket Output Server (SOS) into play. What is SOS? From their website:
POWERFLASHER SOS (SocketOutputServer) is a XML Socket server with a graphic user interface. Connected clients can send messages to SOS. These messages are shown in SOS. Further on commands from SOS to Client can be sent. These are freely configurable.
Great! But how does MTASC handle the trace() command? Fortunately it allows you to set up your own trace class!
Compiling using mtasc -trace MyClass.myTrace Test.as (…) will replace all calls of trace by calls to MyClass.myTrace (your custom trace function) […]
First, let’s adjust our Core class a little bit. Here is the new version:
import de.diefirma.mtasc.Ball; /** * @author Daniel Heidecke */ class de.diefirma.mtasc.Core { private var target : MovieClip; private var ballMc : Ball; private static var sock : XMLSocket; public function Core(target : MovieClip) { this.target = target; Object.registerClass("ball", Ball); ballMc = Ball(target.attachMovie("ball", "ballMc", target.getNextHighestDepth())); // connect to the sos sock = new XMLSocket(); sock.connect("192.168.1.38",4444); sock.send("sos connected"); } // this is our custom trace function. note, that it is static! public static function myTrace(obj : Object, fullclass : String, file : String, line : Number) { sock.send("msg: " + obj + "nclass: " + fullclass + "nline: " + line + "nn"); } }Note, that myTrace() is a static function, thus sock has to be a static var, too!
One last step to go. To tell MTASC how to handle our custom trace function we’ve to change the compiler args a litte bit.
-main -swf deploy/ball.swf -trace "de.diefirma.mtasc.Core.myTrace"That’s it. Start the SOS, then watch your swf! Now you should see the trace output on the SOS panel!
It’s also possible to debug your movies on remote sites.
Take the IP from the SOS Computer as Host for your XMLSocket.
With Flash as Client, a local Web server is necessary. The CrossDomainPolicy – XML file must admit the external server. Host must be “localhostâ€.You can download the example sourcefiles here. I hope this was helpful.
Kommentar schreiben