| 1 |
package { |
|---|
| 2 |
import flash.display.*; |
|---|
| 3 |
import flash.events.Event; |
|---|
| 4 |
import com.nitoyon.as3query.*; |
|---|
| 5 |
import test.RoundRect; |
|---|
| 6 |
|
|---|
| 7 |
// Import 'Tweener' and force the class to be linked. |
|---|
| 8 |
import caurina.transitions.Tweener; Tweener; |
|---|
| 9 |
|
|---|
| 10 |
public class Box25withTweener extends Sprite { |
|---|
| 11 |
public function Box25withTweener() { |
|---|
| 12 |
$(stage).attr({ |
|---|
| 13 |
scaleMode: "noScale", |
|---|
| 14 |
align: "TL" |
|---|
| 15 |
}); |
|---|
| 16 |
|
|---|
| 17 |
// create 25 boxes |
|---|
| 18 |
for(var i:int = 0; i < 25; i++) { |
|---|
| 19 |
$(RoundRect) // $(ClassName) equals $(new ClassName()) |
|---|
| 20 |
.attr({ // Set properties |
|---|
| 21 |
x: (i % 5) * 50, |
|---|
| 22 |
y: Math.floor(i / 5) * 50, |
|---|
| 23 |
width: 40, |
|---|
| 24 |
height: 40 |
|---|
| 25 |
}) |
|---|
| 26 |
.appendTo(this); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
function animate(f:Boolean):void { |
|---|
| 30 |
// Select 'RoundRect' elements using CSS selector |
|---|
| 31 |
$("RoundRect:" + (f ? "odd" : "even")) |
|---|
| 32 |
.addTween({ |
|---|
| 33 |
rotation: 90, |
|---|
| 34 |
scaleX: 0.5, |
|---|
| 35 |
scaleY: 0.5, |
|---|
| 36 |
time: 0.6, |
|---|
| 37 |
delay: 0.3, |
|---|
| 38 |
transition: "easeOutCubic" |
|---|
| 39 |
}) |
|---|
| 40 |
.addTween({ |
|---|
| 41 |
scaleX: 1, |
|---|
| 42 |
scaleY: 1, |
|---|
| 43 |
time: 0.5, |
|---|
| 44 |
delay: 0.9, |
|---|
| 45 |
transition: "easeOutElastic", |
|---|
| 46 |
onComplete: function():void { |
|---|
| 47 |
// restore the rotation and call again. |
|---|
| 48 |
this.rotation = 0; |
|---|
| 49 |
animate(!f); |
|---|
| 50 |
} |
|---|
| 51 |
}); |
|---|
| 52 |
} |
|---|
| 53 |
animate(false); |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
} |
|---|