Author Archives: Zevan

XML to ActionScript #2

CLICK HERE TO COPY
Actionscript:

var script:XML=<code>

 

   <make reference="blur" class="flash.filters.BlurFilter">

     <set blurX="10" blurY="10" />

   </make>

   

   <make reference="filts" class="Array">

     <call method="push">

       <arg reference="blur" />

     </call>

   </make>

   

   <make reference="mat" class="flash.geom.Matrix">

     <call method="rotate" args="1" />

     <set tx="100" ty="100" />

   </make>

   

   <make reference="box" class="flash.display.Sprite">

       <setRef filters="filts" transform.matrix="mat"/>

    [...]

Posted in XML, dynamic, external data, instantiation | Tagged , , | 2 Comments

XML to ActionScript

CLICK HERE TO COPY
Actionscript:

// this xml is inline but could easily be in an external file

var script:XML=<code>

 

  <!-- // call some methods of the main timeline graphics property -->

  <call method="graphics.beginFill" args="0xFF0000" />

   

  <call method="graphics.drawRect" args="0, 0">

     <!-- // use this to access properties of the main movie -->

     <!-- [...]

Posted in XML, dynamic, external data, string manipulation | Tagged , , | 6 Comments

Random Guitar Tablature

CLICK HERE TO COPY
Actionscript:

// number of notes in chord

var noteNum:int = 3;

var lowNote:Number = 0;

var highNote:Number = 4;

// delay between chords

var delay:int = 2000;

////////////////////////////////////////

var chord:String = "";

highNote += 1;

var tab:TextField = TextField(addChild(new TextField()));

tab.x = tab.y = 20;

tab.defaultTextFormat = new TextFormat("Courier", 12);

tab.multiline = true;

tab.width = 200;

 

changeChord();

setInterval(changeChord, delay);

 

function changeChord():void{

    var strings:Array = [];

    strings[0] = [...]

Posted in random, string manipulation, strings | Tagged , , | 6 Comments

Random Negative or Positive

CLICK HERE TO COPY
Actionscript:

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

  // randomly set a variable to -1 or positive 1

  trace(int(Math.random()*2) - 1 | 1);

}

 

/* outputs something like this

1

1

-1

1

-1

-1

1

1

-1

-1

*/

The past few days I found myself using this one-liner a few times. Just a quick way to randomly get -1 or 1.
I was brainstorming today and [...]

Posted in one-liners, random | Tagged , , | 3 Comments