Printable quick reference cards for the ActionScript language. AS3, Flex, AIR, Papervision, and more!
ActionScriptCheatSheet.com

Archive for the 'actionscript' Category

ActionScript 3.0 Cheatsheet – Top Level Classes

ActionScript 3.0 Cheatsheet Here is the first pass at the AS3.0 Cheatsheet. I started by creating one sheet for the language to mirror the AS2.0 sheet. I got one together for the main packages and then realized that there needed to be a series of cheets to cover the massive size of the third version of ActionScript… So here is the Top Level Classes Sheet. The next sheets will be:

Top Level – Error Classes

flash. Packages

flash. Classes

mx. Packages

mx. Classes

Interfaces

That’s a lot of sheets, but the language is growing, quite nicely too I’d have to say

Stay tuned for new AS3.0 sheets to be posted.

 

20 comments

How to reverse an array with ActionScript (without the .reverse method)

I was reading a blog the other day and in it the author mentioned the fact that a lot of programmers don’t know how to reverse an array in their language of choice. Not by using a library or language method like we have in ActionScript but the acutal programmatic task of reversing an array.

I have used the handy reverse method in the past but never really thought much about how it acutally worked. Not being a CS major and coming from more of a Multimedia background I thought that this would be something to look into.

Here is the code to do the reverse operation:

function reverse(a) {
// index of leftmost element
var left = 0;
// index of rightmost element
var right = a.length-1;
while (left < right) {
// exchange the left and right elements
var temp = a[left];
a[left] = a[right];
a[right] = temp;
// move the bounds toward the center
left++; right–;
}
}
var example_array = new Array(1,2,3,4,5);
trace(example_array);
reverse(example_array);
trace(example_array);

This is Java code ported to ActionScript the original Java code can be found here:

http://www.leepoint.net/notes-java/data/arrays/34arrayreverse.html

Here is how you use the reverse method in ActionScript if you are looking or wondering: Array.reverse();

4 comments

« Previous Page