Category Archives : Flash/Flex


flash cs5 packages cannot be nested

I was mucking about in Flash CS5 and got this error when I typed include “ClassName.as”. Note, I normally use FlashDevelop for flex stuff, so I was trying to use the CS5 interface. I got the error, and was like what? So I hit google and got this response: Try this first save the AS file as Starter_1.as Next make a new fla and save it in the same folder as the Starter_1.as Now in the fla in properties look for Document class: and write >> Starter_1


Die Flash, Hello Nurse HTML 5 2

Well, There’s not much more I can add than this: Die Flash, Die from the pink crow. Read it, learn it, love it. He also get’s extra points for using the word Shadenfreude, which is german for “the feeling of delight you feel when learning of the misfortunes of others, especially enemies or those you dislike.” I know, I know, don’t I love flash? Somewhat, it can be great, and I do post a lot of flash related stuff, especially flex/as3. I also know C# and Asp.net, doesn’t mean I like those languages or products, it just means that when a Client says “Can you do it in…”, I can 90% of the time say “yes, if you want, but…” And the but is where I usually recommend a better, more maintainable and less proprietary option. Don’t get me wrong, Adobe is making effort to opensource, which is why I have kind of reserved judgment for a little later. However so far, it only seems a bit half assed. They should remember the old fable of the child and the nettles: A Boy was stung by a Nettle. He ran home and told his Mother, saying, “Although it hurts me very much, I only touched it gently.” “That was just why it stung you,” said his Mother. “The next time you touch a Nettle, grasp it boldly, and it will be soft as silk to your hand, and not in the least hurt you.” Whatever you do, do with all your might. While there are […]


HowTo ActionScript 3 (as3 flash or flex or AIR) Class and Object Inheritance, extends

It seems I have been getting alot of hits due to my post on AS3 inheritance, and I notice that most of the documentation and examples out there don’t really cover the whys and the hows in a thorough manner. There are a couple of parts to this little tutorial, the first being a kind of very basic demonstration of extending, and then some concrete realworld samples. You can jump ahead to the realworld samples if you are just looking to see how/why you might use extend to solve some real problems. Basic/intro to oop and extending in as3 extending event dispatcher to manage your own event queue extending event to create a custom event and finally extending Panel to make a drag/drop Panel Having classes and objects does not equal OOP. To understand a class, you need to understand that an object without state or behavior is meaningless, so to be an object, it must have those things. The object itself is an environment, it is like a scope, it’s a container which imparts a kind of semantic meaning to the function and variables attached to it. Having objects is very nice, but there needs to be something more, and that something more is inheritance. Without inheritance, objects are simply wrappers, and it would be just as well to create functions and simply pass in some kind of key to ameliorate what to do. With inheritance, you share state and behavior between objects. The common example is with a person, people have names, and […]


How To Flash CS5: Keyboard Navigation Action Script 3 KeyboardEvents 6

Well, I was watching an interesting little tutorial on keyboard navigation with AS3. Now, the guy’s tutorial was actually really good, however, it wasn’t really what I would call AS3. It was very on target for what it was doing, but didn’t leave much room for expansion in my opinion. So I decided to try my hand at changing it up a littler bit. Here is the code: This is put on the main timeline, in the first frame on an actions layer. That is, you just create a new layer, and name it actions, it’s just a convention. import flash.events.KeyboardEvent; import flash.events.Event; var currentKeyDown:uint = 0; var Keys:Object = {up: 38, down: 40, left: 37, right: 39,r:82, shift: 16, ctrl: 17, z:90, x:88}; var CurrentKeysDown:Object = {up: false, down: false, left: false, right: false, shift: false, ctrl:false}; stage.addEventListener(KeyboardEvent.KEY_DOWN,setCurrentKeyDown); stage.addEventListener(KeyboardEvent.KEY_UP,clearCurrentKeyDown); setTimeout(updateCanvas,100); function setCurrentKeyDown(event:KeyboardEvent):void { trace(event.keyCode); for (var key:String in Keys) { if (Keys[key] == event.keyCode) { CurrentKeysDown[key] = true; } } } function clearCurrentKeyDown(event:KeyboardEvent):void { for (var key:String in Keys) { if (Keys[key] == event.keyCode) { CurrentKeysDown[key] = false; } } } function moveEntity(entity:MovieClip):void { currentKeyDown = 0; var x:Number = 0; var y:Number = 0; for (var key:String in Keys) { if (CurrentKeysDown[key]) { currentKeyDown = Keys[key]; } switch (currentKeyDown) { case Keys.shift: entity.speed += entity.speed * .05; break; case Keys.ctrl: entity.speed -= entity.speed * .05; break; case Keys.z: entity.rotationSpeed += entity.speed * .06; break; case Keys.x: entity.rotationSpeed -= entity.speed * .06; break; case Keys.r: entity.x = 200; entity.y = 200; break; case Keys.left: […]


AS3 Multiple Inheritance/Mixins 2

Well, I just got done reading this post about multiple inheritance in as3 which probably should have been titled AS3 mixin technique, because that is more or less what it is, check out the wikipedia article on mixins for some history and pros and cons. I’ll will admit straight out that I am a supporter of MI and Mixins and the like. I am not much for the aristotelian idea of the universe, sometimes A is A, and sometimes it’s both A and B and MI, when used responsibly helps you to find more elegant and concise solutions to a great many problems. Just because people use something incorrectly in some instances doesn’t make that thing inherently evil, take for instance perscription drugs, would you rather painkillers where completely banned or never prescribed just because some or even alot of people abuse them? No, a great many things when used excessively with little understanding of what it is and how it works can be called evil, but they aren’t, the people who abuse them are evil, let’s start calling a spade a spade. The problem with MI and Mixins is not that they are evil, it’s that evil people use them for nefarious purposes. Anyway, back onto topic, I liked the guys article, and to be honest, he was pretty brave for putting it up, the minute you say something about MI, either way, a “discussion” read “flamegeddon” ensues, not always, but it’s generally a risk when you start throwing words like Inheritance around with […]


ActionScript 3.0 Wishlist

ActionScript 3.0 is just, well, pretty damn awesome. Nevertheless, as I’ve been working in AS3, I have come across a few limitations of the language, that while not show stoppers, leave just a little something to be desired. 1. No control over GC. That doesn’t sound important to your average Joe Programmer, but being able to commandeer, or at least influence Garbage Collection would be so totally awesome. For instance, I am working on a framework that more or less enforces a singleton based architecture, everything should be a singleton, except in 1 or 2 small circumstances that the framework controls. I.e. I have a special object wrapper that controls an inner object and can do some fancy footwork about it, all without you really having to worry about what is in the object. I would love for the user to be able to call SpecialObject.destroy(), and have it completely obliterated from memory. As it stands right now, this is not possible. Further more, it’s not really possible to make sure anything is removed from memory, because if it has even 1 single existing reference in your entire app, it will not be GCed, as was pointed out in the gskinner.com post about the AS3 Garbage Collector. Furthermore, if it has an event attached to it, it can’t be destroyed, which causes all kinds of issues, including one I’ll talk about in a moment. One method of fighting against this, that I am working on, but unsure of, is to discourage putting objects into variables […]