forked from arpit/openpyro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEffectsTest.as
More file actions
90 lines (75 loc) · 2.36 KB
/
EffectsTest.as
File metadata and controls
90 lines (75 loc) · 2.36 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package
{
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import org.openPyro.aurora.AuroraButtonSkin;
import org.openPyro.controls.Button;
import org.openPyro.core.Application;
import org.openPyro.core.UIControl;
import org.openPyro.effects.Effect;
import org.openPyro.layout.VLayout;
import org.openPyro.painters.GradientFillPainter;
public class EffectsTest extends Application
{
public function EffectsTest()
{
}
private var target:UIControl;
override protected function createChildren():void{
target = new UIControl();
target.backgroundPainter = new GradientFillPainter([0xcccccc, 0xffffff],null,null, Math.PI/2);
var tf:TextField = new TextField();
tf.width = 180;
tf.height = 180;
tf.defaultTextFormat = new TextFormat("Arial", 14);
tf.text = "Hello, this is an effects demo. Click on the buttons on the left to apply different effects.";
tf.x = tf.y = 10;
tf.multiline = true;
tf.wordWrap=true;
target.addChild(tf);
target.size(200,200);
target.x = 160;
target.y = 20;
addChild(target);
createButton("Fade", function (event:MouseEvent):void{
Effect.on(target).fadeIn(10);
});
createButton("Slide Up", function(event:MouseEvent):void{
Effect.on(target).slideUp(1);
});
createButton("Wipe Up", function(event:MouseEvent):void{
Effect.on(target).wipeUp(1);
})
createButton("Chain wipe and slide", function(event:MouseEvent):void{
Effect.on(target).wipeDown(1).slideUp(1);
})
}
private function createButton(label:String, clickHandler:Function):Button{
var b:Button = new Button();
with (b){
skin = new AuroraButtonSkin();
width = 140;
height = 20;
addEventListener(MouseEvent.CLICK, clickHandler);
}
addChild(b);
b.label = label;
return b;
}
override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var layoutChildren:Array = [];
for (var i:int=0; i< this.contentPane.numChildren; i++){
var ch:DisplayObject = this.contentPane.getChildAt(i);
if(ch is Button){
layoutChildren.push(ch);
}
}
var vlayout:VLayout = new VLayout(10);
vlayout.initX = vlayout.initY = 10;
vlayout.layout(layoutChildren);
}
}
}