XRay Logging with AS3
Oct 30th, 2007 by jbloom
Using Xray you can utilize logging in your AS3 development in a nice clean manner. One of the great benefits here is that your logging/debugging process can be the same when developing locally and when you are running on your development and production servers.
To get started download the latest xray code from their SVN repository.
http://code.google.com/p/osflash-xray/source
Then create a new AS3 flash document using the code below as the document class:
Make sure that you add the ‘trunk’ directory that you downloaded to your class path (so flash can find the xray files)
Once you are compiling correctly, launch the xray viewer in a browser from http://www.rockonflash.com/xray/flex/Xray.html. You will get a notification about not finding a SWF to connect with, ignore this for now (full xray support is not yet therefor AS3 projects). Make sure that the Show Output checkbox along the bottom is checked.
Now if you click the red square in your swf player, you should see the following show up in the XRay viewer windows.
Congratulations you are now logging. Big thanks to John Grden and everyone else contributing to Flash development methodologies.
package { import com.blitzagency.xray.logger.XrayLog; import flash.display.*; import flash.events.*; public class testLoggingAS extends MovieClip { private var log:XrayLog = new XrayLog(); private var mc:MovieClip public function testLoggingAS() { log.debug("Application starting up"); createClickableMovieClip() log.debug("Application has completed startup"); } private function showTheClick(e:Event):void { log.debug("Square was clicked. Tracing out the Event", [e]); } private function createClickableMovieClip():void { mc = new MovieClip(); mc.name = "ClickableMovieClip" mc.graphics.beginFill(0xFF0000); mc.graphics.drawRect(0, 0, 100, 80); mc.graphics.endFill(); mc.x = 80; mc.y = 60; addChild(mc); mc.addEventListener(MouseEvent.CLICK, showTheClick) } } }
thx Jbloom for the great post.
We got the loggin working but how can we take snapshots of the app and use the other functionalities of XRAY?
Hi Bachir,
The snapshots and other XRAY features that you are used to from AS2 development aren’t ready for use in AS3 yet.
I’ve spoken with John Grden http://www.rockonflash.com/blog/ the original author of xray and if you want to help get xray going in AS3 the best thing to do is join the OSFlash mailing list at http://osflash.org/mailman/listinfo/osflash_osflash.org and volunteer to test etc.
If you’re really adventurous you could always jump into the source code, fix what ever is needed and submit the patch…
-josh
Hi Josh,
thanks again for your reply, I will go and check it out at osflash.
One thing though, after i posted here, I played bit more with Xray and managed to get it working with AS3. I could actually digg down my objects etc… and even access all properties etc, the only thing i couldn’t see was the methods.
will have a look and hope i can help out there.
thanks