I’ve been teaching myself ActionScript 3 at work. It’s been a slow process, because it’s been on a as needed basis. Today I spent 6 hours trying to do something simple. Not so simple if you don’t know how to do it, but simple once you do.
I needed to play movie clips at random. The clips fade in and out as they go from one to the other, but they don’t have to be in any particular order. So I made some movie clips with shapes bouncing around, that was the easy part, and then watched a ton of tutorials on “Math.random” scripts.
6 hours later I come up with the following scripting…
var MCs = new Array(“ball”, “box”, “poly”);
var selectedMC = MCs[Math.floor(Math.random() * MCs.length)];
gotoAndPlay(selectedMC+”MC”);
WTF?! That’s it? Three little damn lines?! I’m sure to a AS3 pro this would be easy as stealing candy from a baby. Me… Not so much. So here is what 6 hours of work got me today.
Impressive, no?!
#1 by Patricia on February 13th, 2009
Good job. You will sleep well from mental exhaustion…..
#2 by kirk on February 13th, 2009
oooh magic code.. its like the matrix.