CLICK HERE TO COPY
Actionscript:
[SWF(width=560,height=300,backgroundColor=0x000000,frameRate=30)]
var key:Object = new Object();
var alphabet:Array = "abcdefghijklmnopqrstuvwxyz".split("");
var num:Number = alphabet.length;
var step:Number = 360 / num;
var colors:Object = new Object();
for (var i:int = 0; i<num; i++){
var index:String = alphabet[i];
key[index] = 65 + i;
var c:Array = hsv(i * step, 1, 1);
colors[index] = c[0] <<16 | [...]
CLICK HERE TO COPY
Actionscript:
function dotSyntax(target:*, path:String):* {
var level:Array=path.split(".");
var curr:* = target;
for (var i:int = 0; i<level.length; i++) {
curr=curr[level[i]];
}
return curr;
}
trace(dotSyntax(this, "stage.stageWidth"));
trace(dotSyntax(this, "graphics"));
trace(dotSyntax(this, "root.loaderInfo.bytesTotal"));
/*outputs something like:
800
[object Graphics]
1230
*/
This snippet shows how to parse dot syntax from a string. It does this by splitting the [...]
CLICK HERE TO COPY
XML:
<code>
<make reference="w" class="BasicView" args="stage.stageWidth, stage.stageHeight, false"/>
<call method="addChild" args="w"/>
<make reference="wireMat" class="WireframeMaterial" args="0x000000" />
<make reference="sphere" class="Sphere" args="wireMat, 100" />
<call method="w.scene.addChild" args="sphere" />
<make reference="animation" class="Object">
<set z="-500" rotationY="360" rotationX="360" ease="Back.easeOut"/>
</make>
<call method="TweenLite.to" args="sphere, 3, animation" />
<call method="setInterval" args="w.singleRender, 32" />
[...]
Posted in Box2D, Graphics, Math, QuickBox2D, XML, dynamic, external data, instantiation, misc, motion, return values, string manipulation, strings | Tagged actionscript, as3, flash |
CLICK HERE TO COPY
Actionscript:
package{
import flash.utils.getDefinitionByName;
public class Creator{
public function Creator():void{
// classes we can create
ClassA;
ClassB;
}
public function create(type:String):ISomeInterface{
[...]