Tracing in FlashDevelop from AS3

Someone who was using my AS3 FlashDevelop Templates just asked how they could trace to the output panel in FlashDevelop. It just took a few minutes to come up with a solution, so I’ll post it here for everyone. Just create the following class:

package org.flashdevelop.utils {
import flash.system.fscommand;

public class FlashOut3
{
public static function trace(msg:Object):void
{
fscommand(“trace”, msg.toString());
}
}
}

and pop it in the folder:

C:/Program Files/FlashDevelop/Tools/

Then replace the compile target in your build.xml with the following:

< target name="compile">
< exec executable="${flex2.dir}/${compiler}">
< arg line="-source-path='C:/Program Files/FlashDevelop/Library'" />
< arg line="-default-frame-rate=${framerate}" />
< arg line="-default-background-color=0x${background.color}" />
< arg line="-default-size ${width} ${height}" />
< arg line="'${basedir}/${source.dir}/${source.file}'" />
< arg line="-o=${output.file}"/>
< /exec>
< /target>

Or you can just add in that third line there, with the -source-path argument.

Now, in any class where you want to trace something, you’ll have to import the FlashOut3 class:

import org.flashdevelop.utils.Flashout3;

And then you can trace to the output panel like so:

Flashout3.trace(“hello world”);

This entry was posted in Flash. Bookmark the permalink.

5 Responses to Tracing in FlashDevelop from AS3

  1. Mike J says:

    Nice work Keith! Your work on getting the AS3 + FD has been great. =)

  2. kp says:

    Oh, I should mention that this only works if you set your launchmethod to tab. If the swf is playing in the standalone player or browser, there’s no way FD can know about it. Next is to hack the FlashConnect class into an AS3 version. That will take a bit more work though. 🙂

  3. Elango says:

    Works Great!! Thanks a lot..

    Elan

  4. nice work keith.
    i had a little solution set up using XPanel ( http://www.ajaxmaker.com/xpanel/xpanel.htm ) – once you download the AS3 source, you have to change the imports from util to utils and it works fine.i prefer launching it within a browser over the tab in FD. I also had it open during init, so it was listening by the time it got to compile.

  5. kp says:

    Nice find, Todd.

    When using FlashOut3, I find it’s useful to add a little function to your class:

    private function trace(msg:Object):void
    {
    FlashOut3.trace(msg);
    }

    This allows you to call trace(“hello world”) directly.

Leave a Reply