Public, Private, Protected, Internal: Access Modifiers in AS3 ·
25 March 2008, 01:07
Wow, I really went away for a while. Between working, wedding planning and the holidays I really lost track of posting! Ohhh where to begin again :) . Since I have gotten a number of questions regarding access modifiers in AS3, thats seems a good place to start.
What is an access modifier?
☆ Jonathan Greene
Comment [10]
Understanding root and the Document Class in AS3 ·
11 December 2007, 12:44
Hopefully, we all know the _root object is gone in AS3. While use of _root was generally frowned upon in the Actionscript dev community, it had its uses. It was a quick and easy way to reference your project's main timeline. Moving into AS3, we let go of _root and embrace the concept of a Document Class.
The purpose of the Document Class in AS3 is to extend your project's main timeline (just a MovieClip instance) with a custom MovieClip subclass. While a similar effect was achievable in AS2, it required using a work-around. It's nice to be able to assign your project a 'main' class right from the properties panel in Flash CS3.
☆ Jonathan Greene
Comment [15]
Yahoo! Maps: AS3/Flex vs. AS2/Flash ·
16 November 2007, 13:48
Given the visibilty of mapping APIs today, it is not a supprise that many of our clients are requesting mapping elements on their site. Since I am a flash developer, I hold a particular affinity for creating solutions with Yahoo! maps over Google maps.
Since the Yahoo! maps component is an AS2 movie at its core, the AS3 API essentially wraps the AS2 map and communicates with it via the Yahoo! AS3 Maps Communication Kit. While the AS3 API lets you use all the AS2 functionality, the big kicker: it requires you use the Flex framework (adding 200kb+) to your project.
☆ Jonathan Greene
Comment [1]
Storing SWFObject.addVariable() vars globally in AS3 ·
23 August 2007, 20:46
Embedding variables with SWFObject is easy. In previous versions of Actionscript all the variables registered with the SWFObject were globally available within the SWF. From any class or object, you could call _root.theVariableName and access that variable.
However, moving to AS3, things are a little different. The SWFObject still embeds FlashPlayer 9 content without a problem – the SWF is properly embedded into the HTML and all the variables and parameters passed to the SWFObject are registered with the SWF. The only difference in AS3 is that these variables are not automatically available throughout your FLA.
☆ Jonathan Greene
Comment [2]
Global Variables in AS3 ·
16 August 2007, 10:50
Yes, we know it can get sloppy, but sometimes is just makes sense to create variables that are accessible from anywhere in your project.
Prior to AS3 it was really easy… there was the _global object: _globals.myvar = ‘mystring’. You are most likely reading this because you are trying to use the _global object in AS3. Ecmascript (the standard on which AS3 is based) does not support this notion, rather it forces you to create your own globally accessible object if you so desire. They are encouraging instance based data coupling, because it’s a lot more structured and less error prone. If you are working on a large application, I will encourage you to not use global variables (especially if unit testing is a requirement). However, if you don’t give a damn about what us programming snobs say, have no idea what unit testing is, or just want to use some global variables in AS3, then don’t feel bad, they can be quite handy!
☆ Jonathan Greene
Comment [36]
onReleaseOutside in AS3 using DisplayObject.stage.addEventListener ·
10 August 2007, 18:07
I am working a few basic wrapper classes for my AS3 library. I am essetially using the Decorator pattern to wrap display objects with, for example, draggable resizing functionality. As I was creating my ResizableSprite class, I came to a point where the onReleaseOutside event of old would have really come in handy.
Needless to say, onReleaseOutside is no longer an event in AS3. Simple enough to get around, right? Can’t we just set a MouseListener to check for MouseUp event? The answer, depending on your Actionscript background is both yes and no. In AS2 the Mouse object was global, meaning that any line of code in the application (no matter what frame, object, class, etc… it was written in) that referenced the Mouse object all talked to the same object. Things have changed in AS3; each Display Object (SimpleButton, Sprite, MovieClip, TextField… basically anything drawn on the stage) has its own internal Mouse object, that only reacts when the mouse is over that object. So, in the case of onReleaseOutside, clicking on the object will trigger an event, moving off that object will trigger an event, but releasing the mouse off of the object will be ignored and won’t fire an event.
☆ Jonathan Greene