stackoverflow.com

April 22nd, 2009

I am in love with stackoverflow.com. It’s a programming wiki / forum-y thing from the same guy who wrote Joel on Software… and um, some other dudes. Anyway, check it out, it’s in desprate need of other actionscript nerds.

The best thread so far:

http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered

My favorite is:

stop(); //hammertime!

Adobe offering Free Flex Builder 3 Professional for unemployed developers

April 9th, 2009

Adobe’s being super nice and offering free flex builder 3 pro to any developers who find themselves unemployed:

https://freeriatools.adobe.com/learnflex/?PID=1225267

Fixing distortion caused by 3D transformations in Flash Player 10

March 11th, 2009

The bottom text has rotationX set to 360, while the top has no transformations applied.

The bottom text has rotationX set to 360, while the top has no transformations applied.


On a recent project, I used the new 3D properties available in flash player 10 for some very simple 3D effects. Unfortunately, I ran into some issues with text quality, where any text in an object with a 3D transformation applied became a bit blurry – it looked a bit like the old text on a half pixel bug – and I was worried I was having some sort of FP7 flashback or something;) What I was doing, was rotating a movieclip wtih some text in it. At the end of the rotation the movieclip was back to it’s original position – I checked to make sure the rotationX, rotationY, rotationZ, and z properties were all zero in case my tweens were doing something weird, but this wasn’t the case.

Anyway, I eventually figured out that the issue was coming from the 3D transformation. The first fix I tried was to set the object’s matrix3D (a property of a DisplayObject’s transform property) property to a new Matrix3D object, or to null. Setting the matrix3D to a new Matrix3D object did not fix the issue, the text remained blurry. Setting the matrix3D to null also repositioned the movieclip back to 0,0. So the solution is fairly simple, just store the x and y values, then set the matrix to null, and then reset the x and y values.


var position:Point = new Point(myMC.x, myMC.y);


myMC.transform.matrix3D = null;


myMC.x = position.x;


myMC.y = position.y;

Of course, if you want 3D effects and non blurry text, you might be out of luck… unless anyone else has a better solution?

Adobe Flickr API Fail

September 23rd, 2008

I’m working with the AS3 Flickr API created by Adobe for a presentation for work, and I’m finding it really frustrating. For starters, it really doesn’t seem to match up very well with the Flickr API documentation. In particular, I’m using the search function in flickr.Photos, and for some reason, they way Adobe wrote the search function, it only accepts one license, as a , while Flickr's documentation states that you can pass multiple licenses as a comma delineated String. I'm not sure why Adobe would want to remove functionality from the API, when it's so simple to add back in. All I had to do was change the license:Number = -1 param to license:String = "", and fix the related errors that appear.

Error 1151: A conflict exists with definition myMC in namespace internal.

September 11th, 2008

A friend of mine, who is an excellent Flex developer, asked me about this bug the other day. It’s something you’ll only encounter in the Flash IDE, so if you mainly work in Flex, it’s it’s a bit of a stumper.

Remember in AS2 how if you drew a MovieClip on the stage, you had to
also declare a variable of the same name in your custom class? Well,
in Flash CS3 / AS3, Adobe has decided to give us developers some
options. The only problem is, they didn’t make it exactly obvious that
the change was made, so you may be getting all sorts of nasty errors,
and wondering why you ever decided to build that project in Flash
instead of Flex.

So if you’re getting errors along the lines of “1151: A conflict
exists with definition myMC in namespace internal.” and you’re working custom classes attached to library objects with instances, the error is probably caused by the fact that you have “Automatically declare stage instances” checked. This checkbox is located under Publish Settings > Flash > ActionScript 3.0 Settings. If it’s checked, flash will automatically add variables to your class at compile time. If you already have tried to declare a variable in your class for this instance, the compiler will throw error 1151, as you will now have two declarations of the same variable.

The fix is easy, simply decide whether or not you want flash to create your variable names for you. I personally prefer to declare my own stage instances as I believe it’s a better practice to have all your variables listed at the top of a class, but annoyingly, this means I will have to uncheck the “Automatically declare stage instances” checkbox for every new fla, as unfortunately this option only seems to be available under publish settings, and not available under the application preferences.

Also note that you’ll need to make your instance declarations public, or they won’t work!

Adventures in AIR

May 14th, 2008

So I’m getting back to trying to learn AIR. I had originally written a few small apps way back when it was in alpha, so now I’m learning the release version. It’s surprisingly simple. My goal with this app was to play with the saving of bitmaps to the hard drive, and it turned out to only require 8 or so lines of code.

var bd:BitmapData = new BitmapData(targetCanvas.width, targetCanvas.height, false);
bd.draw(targetCanvas);

var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);
var imgByteArray:ByteArray = jpgEncoder.encode(bd);

var fs:FileStream = new FileStream();

try{
fs.open(file, FileMode.WRITE);
fs.writeBytes(imgByteArray);
fs.close();
}catch(e:Error){
Alert.show("Error saving file :( : " + e.message);
return;
}
Alert.show("File Saved.");

I’m also using the AS3 Flickr API from adobe, which is another thing I haven’t played with yet. I’m finding the documentation for the flickr api to be slightly less than spectacular, it doesn’t seem to actually match up with how the API works, but I did manage to get a search of creative commons licensed photos working.

Anyway, check it out. It’s still in progress, so please let me know if you find any bugs, or just have suggestions for improvement.

AIR Lolcat Generator

the Dictionary Object

February 7th, 2008

Ever run into the problem of passing data with your MouseEvents? You can’t store data in your MovieClips, Sprites, whatever, without creating a custom class, and sometimes creating all those custom classes is a bit more than you need.

Enter the dictionary object:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Dictionary.html

The dictionary object allows you to store variables like in an associative array, but instead of using strings as keys, you can use objects.

Construct your dictionary object. Passing true tells the dictionary object to use weak references, it’s false (strong) by default

var myDictionary:Dictionary = new Dictionary(true);

Set up your objects, storing the appropriate data in the dictionary object. (In use, this data would be pulled from xml or something)

for(var i:int=0; i<10; i++){
var temp:Sprite = new Sprite();
myDictionary[temp] = 'my random data';
temp.addEventListener(MouseEvent.CLICK, clickHandler);
this.addChild(temp);
}

Then your mouse event handler can easily access the data!

protected function clickHandler(e:MouseEvent):void{
trace(myDictionary[e.currentTarget]);
}

naughty, naughty uints.

February 1st, 2008

I stumbled across this helpful analysis of ActionScript 3.0 Optimizations while reading about bit operations last week. I think some of you might find it useful. I find it interesting (as I mentioned in my class last night) that uint, unlike in other languages, is remarkably inefficient. Having learned java once upon a time, I was totally excited about the addition of ints and uints… but for now I’ll have to stick to ints.

http://rozengain.com/?postid=35

A friend likened optimizing actionscript, to judo skills:

There is a Japanese expression that is actually the main principal of Judo which is “Seiryoku Zenyo” translated as “maximum efficiency with minimum effort”. 

welcome to actionscriptgirl.com

February 1st, 2008

Welcome! This is my second attempt at a blog,  ever, I’m hoping this one will be less of a miserable failure than my first one. Hopefully, this time around I’ll be a bit more diligent about posting on a regular basis.

In general this blog should contain my general thoughts about ActionScript, problems I’ve run into, and neat things I’ve stumbled across on other blogs… all relating to ActionScript.

If there’s anything you’d like to see me write about, please let me know!