Author Archives: Zevan

Simple BlendMode Nav

CLICK HERE TO COPY
Actionscript:

stage.frameRate=30;

var nav:Sprite = Sprite(addChild(new Sprite()));

nav.x=nav.y=150;

 

var cover:Sprite;

var coverDest:Number=0;

var spacing:int=4;

var btnNum:int=6;

 

buildNav();

 

addEventListener(Event.ENTER_FRAME, onLoop);

 

function onLoop(evt:Event):void {

    cover.x += (coverDest - cover.x) /4;

}

 

function buildNav():void {

    for (var i:int = 0; i<btnNum; i++) {

        var b:Sprite=makeBox(50,50);

        b.x = i * (b.width + spacing);

        b.buttonMode=true;

        [...]

Posted in motion | Tagged , | Leave a comment

MYSQL SOUNDEX

CLICK HERE TO COPY
C:

SELECT * FROM _users WHERE SOUNDEX(name) LIKE SOUNDEX('jon');

Not ActionScript, but the coolest thing I've seen in Mysql in awhile, the soundex function will convert a string into a soundex index... read more about it on wikipedia.
I did some tests and it matches things like:
what's your name? & whats yer [...]

Posted in misc, string manipulation, strings | Leave a comment

Circles & cacheAsBitmap

CLICK HERE TO COPY
Actionscript:

[SWF(width=600,height=400,backgroundColor=0x000000,frameRate=30)]

var mcs:Vector.<MovieClip> = new Vector.<MovieClip>();

var num:int = 2000;

for (var i:int = 0; i<num; i++){

    var s:MovieClip = new MovieClip();

    s.graphics.lineStyle(0,0xFFFFFF);

    s.graphics.drawCircle(0,0, Math.random()*30 + 3);

    s.x = Math.random()*stage.stageWidth;

    s.y = Math.random()*stage.stageHeight;

       // comment out to kill your cpu

    s.cacheAsBitmap = true;

    addChild(s);

    s.vx [...]

Posted in DisplayObject, Graphics | Tagged , | 1 Comment

split() hacks & RegExp

CLICK HERE TO COPY
Actionscript:

var path:String = "section/home.swf";

 

var deepLinkValue:String = path.split("/")[1].split(".swf")[0];

 

trace(deepLinkValue);

/*outputs:

home

*/

As a primarily self taught programmer there was a time when I didn't know what a regular expression was. There was also a time when ActionScript didn't have them (you had to use a library). Sometimes when I'm in a rush I still do weird things [...]

Posted in string manipulation, strings | Tagged , | Leave a comment