Here is a super-basic class that virtualizes the action of a two-position switch. If you create a two-frame MovieClip and add Switch as it’s class in the properties panel, then clicking the MC will move it to the first and second frames, respectively.
package Switch {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Switch extends MovieClip {
private var _currentState:Boolean = false;
public function Switch():void {
addEventListener(MouseEvent.CLICK, switchClicked);
}
private function switchClicked($event:MouseEvent):void {
if(_currentState) {
_currentState = false;
gotoAndStop(1);
} else {
_currentState = true;
gotoAndStop(2);
}
}
public function get currentState():Boolean {
return _currentState;
}
}
}
Check out the new image gallery I have developed in Flash and ActionScript 3.0. It is installed on my main portfolio web site. You can also download it here:

Ever since I started working with Flash, around 2000-2001, I have always groaned when it comes to embedding an SWF in a web page, mainly because it’s ugly. No amount of organizing and code formatting can make an <embed> and <object> sandwich look edible. On top of that, I was never quite certain if adding some JavaScript to the atrocity would be a good idea.
In those early days working with flash, I was not concerned with such boring terms as web standards and browser compatibility, but now that I am working on more practical projects, web standards and browser-compatibility are very important to me.
After researching for a couple of days, it seems the SWFObject 2.0 method is the way to go for now. A List Apart posted this great article which compares the historic methods of embedding Flash content. Here is a summarized list of “key ingredients of a great Flash embedding method” from that article:
- Standards Compliance
- Cross-Browser Support
- Support for Alternative Content
- Avoidance of Flash/Content Player Mismatches
- Auto-Activation of Active Content
- Ease of Implementation
Here is a quick summary of the methods used up to SWFObject 2.0 (From the A List Apart article mentioned above):
At this point, Bobby Van Der Sluis and Geoff Stearns have both stated that SWFObject 2.0 is the best method, mentioned here and here.
I will write a later post about my experience using the new method.