One of my first blog posts, catches me ranting about how I’m going to show you how to do everything in my Portfolio…
Thats right all my dirty little secrets; including a mix of both very strong OOP, and a bunch of sweet little workarounds(hacks), for getting things done. Don’t judge! I’m actually trying to show that you can do things in Actionscript in more than one way. And sometimes the bad way, can work better. (there are a few things I’m keeping stashed, mainly what happens in the FLA’s, you shouldn’t need em though, if you do…)
Enter the first installment.
If you travel over to my portfolio you’ll notice the home page now contains an extra button for “source” when clicked you go here: http://juanbonfante.com/SourceView/srcview/index.html (you can also right click anywhere on the flash movie, and choose “Source”).
That’s where the magic happens! If you’ve ever published a Flex project, you’ll recognize this is the “Poject -> Export release build” source viewer. For the most part it is built on the fly by Flex. Of course because it’s Flex there are some issues with the original code…
- Target: Get Flex Builder to build non-Flex project.
I used FDT to write this whole thing, the steps are probably going to be similar, if you use a different IDE, or if you just use Flex Builder.
Step 1: Create a copy of your project within your workspace.
Copy of Project within workspace
Step 2: Remove Flash Nature from project (if using FDT)
Step 3: Switch over to Flex Perspective, and Add Flex Project Nature, to the folder.
Copy of Project with Flex Nature
You can save yourself step 4, by unchecking the “Automatically declare stage instance” box. The reason for this is FDT and FlexBuilder will actually throw errors if you don’t properly declare an instance, at the top of the class. While this box is checked, Flash will add the instances for you, but you’ll get a compile-time error, if you leave the manual declaration in the class. To properly showcase this i left a few of the fla’s with this box checked.

AS3 Settings
Step 4: Declare the instances that are throwing errors in the compiler. Since this will prevent the project from compiling.
Luckily in this example there are only 3 unique errors, in 2 different .as files.
So we look up the source file and add the variable it’s looking for.
Step 5: Repeat this process for any other remaining variables.
Step 6: Once you’ve finished cleaning up your code, the error console should be free of errors. (!!!Warnings are OK!!!!).
Step 7: By now Flex has already created the main.mxml, so we’ll just publish that. You can add something to the code if you’d like. This way you can put a message, or instructions as I have. Head on over to the Project -> Export Release Build…
Step 8:
a) Check ON, “Enable view source”
b) if there’s files you don’t want exported it, now is your chance, otherwise it will include everything including fla’s, and any other type of file it can find.
c) Hit finish, let it do its thing for a few minutes.
d) Once its done head on over to the folder that you chose to dump it in.
c) Look for “srcview” folder
d) Run index.html
(in this case its viewSource/srcview/index.thml)
Step 9: Go out. You’re done.
http://juanbonfante.com/SourceView/srcview/index.html






















