Flex 2-Style View Source Context Menu for ActionScript 3 Projects
Flex 2 projects have a very neat feature that they get from the mx.core.Application class: A "View Source" option on the context menu.
It's not terribly hard to implement in straight AS3 but it is nice to have it done automatically for you. Unfortunately, ActionScript 3-only projects do not have this by default. As I see the View Source feature as one of the most important features in AS3/Flex 2, I decided to make a simple class that will allow you to do this.
Of course, nothing simple is ever simple. I decided to make it a Singleton (although really it could easily have been a static method). Now, if you need to know one thing about AS3 in its current state: It doesn't like Singletons. By that I mean the combination of rules regarding packages and access specifiers (you can't have a private class in a package any longer) makes it almost impossible to implement a true Singleton... almost! :).
After much head scratching and experimentation, I came up with one method of creating a true singleton in AS3. I'll leave the details of that for another blog post and instead post the SWF here.
My brain's fried -- this is still not a true singleton and you can't really have one in AS3 unless we can have private constructors. In the meanwhile this is just one method of faking it in a convoluted way that offers no protection over accidentally instantiating the class directly via its constructor. Pfft!
If you want the source, just right-click in the AS3 app above and view source ;)
Comments
by Peter Hall on 2007-06-16 14:12:52
by Jimmy Rittenborg on 2007-08-16 04:44:24
by Fabricio on 2007-12-14 18:44:46
by Jake on 2009-01-05 03:50:12
by Aral on 2009-01-03 19:52:17
by İbrahim Ersoy on 2009-01-02 22:14:55
by Jeff Schiller on 2009-04-21 03:14:44
by Carl on 2011-03-31 04:40:24