Author Archives: Zevan

Object Parsing (object from string #2)

CLICK HERE TO COPY
Actionscript:

var str:String = '{numA:100, numB:100, stringA:"hi there", object:{red:155, green:155, blue: 255}, array1D:[1, 2, 3, 4, 5, "six"], array2D:[[1,0,0], [0,1,0], [0,0,"z"]], color:0xFF0000}'

 

var obj:Object = toObject(str);//, true); // comment the "true" in for some debug info

 

// acess every value in the object for testing purposes

trace(obj.numA);

trace(obj.numB);

trace(obj.stringA);

trace(obj.object.red, obj.object.green, obj.object.blue);

trace(obj.array1D +" testing access: " + obj.array1D[3]);

trace(obj.array2D + [...]

Posted in dynamic, string manipulation, strings | Tagged , | 4 Comments

Object from String

CLICK HERE TO COPY
Actionscript:

var str:String='{x: 10, y:10, width:100, heigth:100, name:"myClip", type:"clip"}';

 

var obj:Object=toObject(str);

 

trace(obj.x + obj.width, obj.name, obj.type);

 

function toObject(str:String):Object {

    str=str.replace(/\{|\}/g,"");

    // to an array of name value pairs [0] = name, [1] = value etc...

    var pairs:Array=str.split(/\:|\,\s+/);

    var obj:Object = new Object();

    for (var i:int = 0; i<pairs.length; i+=2) {

    [...]

Posted in dynamic, string manipulation, strings | Tagged , | 2 Comments

Infinity Scroller (repeating navigation)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var buttonsWidth:Number = 0;
var buttonsA:Sprite = new Sprite();
var buttonsB:Sprite = new Sprite();
var nav:Sprite = new Sprite();
 
var buttonData:Array = ["one", "two", "three", "four", "five", "six",
[...]

Posted in UI, motion | Tagged , | 4 Comments

Testing New Code Highlighter

1
2
var sprite:Sprite = new Sprite();
addChild(sprite);

Just testing a new highlighter... the site may have some weird issues for the next few minutes
UPDATE: Seems to be working, please let me know via the comments on this post if you see any code highlighting issues.
The new code highlighter won't copy and paste line numbers into the timeline. For [...]

Posted in Uncategorized | Leave a comment