By Zevan | October 28, 2008
Actionscript:
-
myClip.gotoAndStop(int(Math.random() * myClip.totalFrames + 1));
An easy way to make a MovieClip go to a random frame. In the future I may post a demo of this technique.
By Zevan | October 28, 2008
Actionscript:
-
var alphabet:Array = ("abcdefghijklmnopqrstuvwxyz").split("");
-
trace("this is the letter b...", alphabet[1]);
-
trace(alphabet);
-
/* outputs:
-
this is the letter b... b
-
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
-
*/
This is an easy way to create an array of the alphabet. It's easier to type than:
Actionscript:
-
var alphabet:Array = ["a","b","c".... etc];
By Zevan | October 28, 2008
Actionscript:
-
appendExclamation("actionsnippit")("dot")("com")("is")("live");
-
-
function appendExclamation(str:String):Function{
-
trace(str + "! ");
-
return appendExclamation;
-
}
-
-
/* outputs:
-
actionsnippit!
-
dot!
-
com!
-
is!
-
live!
-
*/
This technique allows you to call a function more than once on one line. I first saw this used in the source files from a talk at flashcoders ny... I didn't attend the talk, but stumbled on this interesting blog post awhile back http://www.flashcodersny.org/wordpress/?p=166.
This is a fun technique to use, I've found some unusual uses for it already... some of which you'll see in later posts....