Author Archives: Zevan

AS Quiz #1

This is the first in a hopefully long series of short ActionScript Quizzes I’ll be writing. This is just 6 simple questions… check it out….
Number of Questions : 6
Difficulty : Easy
Topic : General

Posted in Quiz | Tagged , , , | 16 Comments

Too Many Buttons

CLICK HERE TO COPY
Actionscript:

[SWF (width = 500, height = 500)]

 

var canvas:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFF);

addChild(new Bitmap(canvas));

 

var indexCanvas:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFF);

 

var btnNum:int = 5000;

var info:Array = [];

 

var brush:BitmapData = new BitmapData(10,10,false, 0xCCCCCC);

var border:Shape = new Shape();

border.graphics.lineStyle(2, 0x000000);

border.graphics.drawRect(0,0,10,10);

brush.draw(border);

 

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

with (txt) height = 20, width = 50, background = 0xFFFFFF, [...]

Posted in BitmapData, arrays, misc | Tagged , , | Leave a comment

~20,000 Rollovers

CLICK HERE TO COPY
Actionscript:

[SWF(width = 500, height = 500, frameRate = 30)]

 

var canvas:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false, 0xFFFFFF);

 

var indexCanvas:BitmapData = new BitmapData(stage.stage.stageWidth, stage.stageHeight, false,

                                            0xFFFFFF);

addChild(new Bitmap(canvas));

 

var s:Shape = new Shape();

 

var lineData:Array = [];

var dataIndex:int = [...]

Posted in BitmapData, Data Structures, UI, arrays, display list, graphics algorithms, matrix, misc, pixel manipulation, return values | Tagged , , | 2 Comments

Array map

CLICK HERE TO COPY
Actionscript:

var a:Array = [1,2,3,4,5,6];

var double:Array = a.map(function():int{return arguments[0] * 2});

trace(double);

/*outputs:

2,4,6,8,10,12

*/

A condensed example of Array.map()
Here is the same thing written in haskell:

a = [1,2,3,4,5,6]
double = map (*2) a

main = print double

Posted in arrays, functions | Tagged , , | Leave a comment