Behrooz
Tahanzadeh


SType action script library

It’s been always painful for me to create instances, assign their properties and add event handlers and do it over and over again in many lines! And the final code is always messy and hard to read. So I have developed a library called SType (for super type!) which does all three steps (create, assign, handle) in one line of code. SType uses AS3 Signal library have been developed by Robert Penner.

following explains how SType works:

1.Create

you can pass an existing instance or pass null and SType will create a new instance.

[btcode title=’AS3′ lang=’java’]
import fl.controls.button;
SButtun(new Button());
[/btcode]is equal to:
[btcode title=’AS3′ lang=’java’]
SButtun(null);
[/btcode]

2.Assign

instead of assign each property, one by one, you can pass a CSS like object that contains variable name and values.

[btcode title=’AS3′ lang=’java’]
btn.width = 100;
btn.x = 10;
btn.y = 20;
btn.lable = ‘click me!’;
[/btcode]is equal to:
[btcode title=’AS3′ lang=’java’]
SButtun(null , {width:100, x:10, y:20, label:’click me!’})
[/btcode]

3.Handle

and instead of add event listeners with regular addEventListner command you can pass all event handlers in one statement like assigning properties. I use AS3 Signal event handling method so it will cause better performance in comprison to native action script 3 event binding method for free!

[btcode title=’AS3′ lang=’java’]
SButton(null, null, {
click: onClickEventListener,
doubleClick: onDClickEventListener
});
[/btcode]is equal to:
[btcode title=’AS3′ lang=’java’]
import flash.events.*;
btn.addEventListener(MouseEvent.Click , onClickEventListener);
btn.addEventListener(MouseEvent.DOUBLE_Click , onDClickEventListener);
[/btcode]

STypes on Github

Repository: Stypes onGithub
Programming Language: Action Script 3.0
Runtime: Adobe AIR