29 August 2010

Debug a Flash project using Flash Builder and Device Central CS5

Yes, this time we don't need Flash CS5 to build/debug...unless you really need its classes.

Update Flash Builder 4 to support Flash Player 10.1

On Flash Builder, create a new Actionscript project.

Optional (ex: if you plan to use assets dynamic loading and not [Embed] metadata tag or others Flex SDK objects)
Remove the Flex 4.1 SDK lib
Add 3 SWC folders
- ${FLASHPRO_APPCONFIG}/ActionScript 3.0/libs
- ${FLASHPRO_APPCONFIG}/ActionScript 3.0/libs/11.0
- ${FLASHPRO_APPCONFIG}/ActionScript 3.0/FP10
I personnaly still go with Flex SDK, the use of [Embed] is such a great thing...and Flex Hero is coming!

Update Project compilation setup to only create HTML (no version check, no browser history)
Edit html-template\index.template.html to
<html><head /><body>Debug on</body></html>
Delete the no longer needed html-template\swfobject.js

On your main AS file, add the SWF metadata tag (edit it to your need)
[SWF(width="480", height="800", backgroundColor="0xFFFFFF", frameRate="25")]
Build project to generate the bin-debug\ files

add an External tool with Run > External Tool > Open external tools Dialog...

Add a new program (DC_<projectname> for exemple) with these info
In Location, Browse filesystems form the file Adobe Flash CS5\Device Central\adcdl.exe
Define Working directory to ${workspace_loc:/<projectname>} if you load external assets
In Arguments, add the magic string "<mobileSettings><testDevices><testDevice id=__mobile_ID__/></testDevices></mobileSettings>" and the full path to the generated swf file (second arg)
see method1 for more information on __mobile_ID__
ex :
"<mobileSettings><testDevices><testDevice id=1494/></testDevices></mobileSettings>" ${workspace_loc:/<projectname>/bin-debug/<file>.swf}

Now, ask for debug (F11)
close the browser it opens
launch the External tool
You can now debug

Site notes
I don't need a batch file anymore since Device Central doesn't crash if I only define the mobile ID (no more selected or <contentType />). If you had problem with it, jump back to the debug.bat usage from method 1.

No comments: