Tools
Tools: A Farewell to ActionScript
2026-02-09
0 views
admin
A Personal Baseline ## A Brief Hope ## Too Good to be True ## Final Thoughts My first programming language was JavaScript, but my favorite for years has been ActionScript (3, to be precise). Many years ago, I learned ActionScript to try to make a Flash game, and fell in love with programming somewhere during the process of creating a character that could walk across the screen. Since then, ActionScript has been the standard for what I look for in a programming language, even as I moved one to other projects. It's been years since I worked in ActionScript, so I dug out some of my own code to look at it now that I have more experience under my belt. It's quite interesting to see how working with this language (or any language) influences the assumptions I've brought into my later work. Let's look at some samples: First, we have the beginning of a declaration for a (probably overengineered) character class. I've found it strange that in JavaScript, properties are added onto an object whenever necessary rather than declaring them upfront as I did here (although upfront declarations can be done). JavaScript is really a prototypal language - its class syntax is sugar over setting up the prototype under the hood. ActionScript, however, has both prototype and class inheritance. I prefer the upfront declarations for clarity, but JavaScript's system makes more sense not that I understand the reason for the discrepancy. I also have always appreciated ActionScript's strong typing. TypeScript gives me something similar, but it requires installing types for every package and occasionally overloading types that are wrong. I never had such issues with ActionScript (though to be fair, I never used anything beyond the standard libraries). I also like that ActionScript has separate types for unsigned integers, signed integers, and floating point numbers, rather than a catch-all number class. Let's take a look at another sample from later in the same class: We can see that JavaScript and ActionScript have almost identical syntax, which makes sense as both are ECMAScript implementations, though there are a few differences besides the explicit typing. For example, ActionScript uses the double equal sign rather than triple for equality checking because it handles type coercion differently. The ENTER_FRAME event also points to the differing ways the browser and Flash handle rendering. Flash had discrete frames and associated events, and attempted to play at a steady framerate, so I treated frames as reliable units of time for animation. (If ActionScript had some sort of delta variable to handle frame stuttering, I didn't know about it.) I still find myself thinking in terms of frames - 'on the next frame, my page should render such-and-such' - even when I'm not explicitly working with frames (though it is possible in the browser, such as by using the requestAnimationFrame() method). Unfortunately for me, the death of Flash pretty much ended my hopes to write in ActionScript. Flash wasn't the only thing that used AS3, of course. I never looked into Adobe AIR because I'd gotten the impression it was really for Mac, and by the time I learned that it had Windows runtimes I'd already moved to Linux. I learned while researching this, however, that Adobe Flex had evolved into Apache Flex and now Apache Royale, which still uses ActionScript. Perhaps I could use my favorite language again! As I read more about the project, I became increasingly excited. Royale adds some JavaScript features I particularly rely on to ActionScript, such as arrow functions and the null conditional operator. It boasts the ability to compile to JavaScript and even to use JavaScript libraries (Node.js and Apache Royale), increasing the odds that any project I created would be usable. I installed and ran Royale's Hello World, and wrote my first ActionScript in years. Unfortunately, I quickly ran into problems. Once I got the Hello World set up, I had no idea how to proceed. I could write ActionScript within the script tag or in other .as files, run it, and see output in my browser console, but I couldn't figure out how to interact with the page from my script, much less draw graphics. Royale is based on AS3 and MXML, a markup language similar to HTML, but which was totally new to me. If I had experience with Flex, it would have been easier to adapt, but even then all the libraries have changed. I had trouble finding information about which namespaces were available, much less what options they all contained, and to be honest, I'm really more interested in writing ActionScript than learning MXML. Some of this was a documentation problem. Sections of the website are incomplete or missing. I found information on setting up a front end application with Royale, but nothing on just drawing a single rectangle. One of the strengths of Flash was the ease of using graphics, since it was so geared to animations and games, so I was disappointed not to find anything. Given that the project itself last major update was December 2024, I'm not optimistic that things will change soon. I really, really wanted this to work. I was so excited to discover that ActionScript was still around, and I was looking forward to creating even a proof of concept project with it. I'm sure it can be done, but the effort to wade through missing documentation and a markup language I don't understand just isn't justified by the few features I feel like I'm missing in JavaScript. I might continue to check in on Royale every once in a while, but I don't intend to put much time into fighting it in its current state. In some ways this feels like closing a door. I've come full circle and am working in JavaScript again, though it's come a long way since I first learned to declare variables with var in Khan Academy's Drawing and Animation course. For games in particular, Haxe often gets recommended as the next step from Flash, and of course there are other options for complete engines such as Godot. And ActionScript wouldn't have been much help for my ultimate goal of scientific programming. I'll always be fond of ActionScript and thankful for what I've learned working with it, but it's just not the tool for me anymore. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK:
public class WorldSprite { public var charname:String; public var currentFrame:Bitmap; public var follower:WorldSprite; public var hasFollower:Boolean = false; protected var _stage:DisplayObjectContainer; protected var _scale:Number; protected var _spritesheet:SpriteSheet; protected var _coors:Array; protected var _x:Number; protected var _y:Number; protected var _z:Number; protected var _dir:uint; //0 = down, 1 = up, 2 = right, 3 = left protected var _walkFrameCounter:uint; protected var _commandArray:Array = []; protected var _stepArray:Array = []; protected var _moving:Boolean = false; protected var _framesToMoveTiles:uint = 8; protected var _followerNextStepDir:uint; protected var _pressedArray:Array = []; protected var _isPC:Boolean; protected var _isFollower:Boolean; protected var _currentMap:TileMap; // constructors, functions, etc } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
public class WorldSprite { public var charname:String; public var currentFrame:Bitmap; public var follower:WorldSprite; public var hasFollower:Boolean = false; protected var _stage:DisplayObjectContainer; protected var _scale:Number; protected var _spritesheet:SpriteSheet; protected var _coors:Array; protected var _x:Number; protected var _y:Number; protected var _z:Number; protected var _dir:uint; //0 = down, 1 = up, 2 = right, 3 = left protected var _walkFrameCounter:uint; protected var _commandArray:Array = []; protected var _stepArray:Array = []; protected var _moving:Boolean = false; protected var _framesToMoveTiles:uint = 8; protected var _followerNextStepDir:uint; protected var _pressedArray:Array = []; protected var _isPC:Boolean; protected var _isFollower:Boolean; protected var _currentMap:TileMap; // constructors, functions, etc } CODE_BLOCK:
public class WorldSprite { public var charname:String; public var currentFrame:Bitmap; public var follower:WorldSprite; public var hasFollower:Boolean = false; protected var _stage:DisplayObjectContainer; protected var _scale:Number; protected var _spritesheet:SpriteSheet; protected var _coors:Array; protected var _x:Number; protected var _y:Number; protected var _z:Number; protected var _dir:uint; //0 = down, 1 = up, 2 = right, 3 = left protected var _walkFrameCounter:uint; protected var _commandArray:Array = []; protected var _stepArray:Array = []; protected var _moving:Boolean = false; protected var _framesToMoveTiles:uint = 8; protected var _followerNextStepDir:uint; protected var _pressedArray:Array = []; protected var _isPC:Boolean; protected var _isFollower:Boolean; protected var _currentMap:TileMap; // constructors, functions, etc } CODE_BLOCK:
protected function step(dir:uint):void { //This does *NOT* have the walkable logic! Use addStepCommand if external! this._moving = true; if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,null); } this._dir = dir; this.changeFrame(this._dir * 2); this._walkFrameCounter = 0; if(this.hasFollower) { var followerDir:int = this.calcFollowerStep(); //Bad things happen if this is a uint if(followerDir != -1) { this.follower.step(followerDir); } } if(dir == 0) { this._coors[1] += 1; adjustZ(); //All get adjusted at the end of the step, but this must be done sooner to avoid clipping through the tile } else if (dir == 1) { this._coors[1] -= 1; } else if (dir == 2) { this._coors[0] += 1; } else if (dir == 3) { this._coors[0] -= 1; } if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,this); //means you can't walk through things } this.currentFrame.addEventListener(Event.ENTER_FRAME,_walkFrame);
} Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
protected function step(dir:uint):void { //This does *NOT* have the walkable logic! Use addStepCommand if external! this._moving = true; if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,null); } this._dir = dir; this.changeFrame(this._dir * 2); this._walkFrameCounter = 0; if(this.hasFollower) { var followerDir:int = this.calcFollowerStep(); //Bad things happen if this is a uint if(followerDir != -1) { this.follower.step(followerDir); } } if(dir == 0) { this._coors[1] += 1; adjustZ(); //All get adjusted at the end of the step, but this must be done sooner to avoid clipping through the tile } else if (dir == 1) { this._coors[1] -= 1; } else if (dir == 2) { this._coors[0] += 1; } else if (dir == 3) { this._coors[0] -= 1; } if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,this); //means you can't walk through things } this.currentFrame.addEventListener(Event.ENTER_FRAME,_walkFrame);
} CODE_BLOCK:
protected function step(dir:uint):void { //This does *NOT* have the walkable logic! Use addStepCommand if external! this._moving = true; if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,null); } this._dir = dir; this.changeFrame(this._dir * 2); this._walkFrameCounter = 0; if(this.hasFollower) { var followerDir:int = this.calcFollowerStep(); //Bad things happen if this is a uint if(followerDir != -1) { this.follower.step(followerDir); } } if(dir == 0) { this._coors[1] += 1; adjustZ(); //All get adjusted at the end of the step, but this must be done sooner to avoid clipping through the tile } else if (dir == 1) { this._coors[1] -= 1; } else if (dir == 2) { this._coors[0] += 1; } else if (dir == 3) { this._coors[0] -= 1; } if(!this._isFollower && coorsOnMap(this._currentMap,this._coors)) { this._currentMap.editDynamicMap(this._coors,this); //means you can't walk through things } this.currentFrame.addEventListener(Event.ENTER_FRAME,_walkFrame);
}
how-totutorialguidedev.toaimllinuxapachenodejavascript