Hello again,
I've come forward with the following code but still have 3 problems:
1) How to run the flyTween on mouse over event?
2) How to add the "polaroid blitz" tween at the very end?
3) Don't know how to remove the mouse over handler at the end - since it is an anonimous closure
Thank you for any hints
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
applicationComplete="init()">
<fx:Script>
<![CDATA[
import com.greensock.TweenMax;
import com.greensock.easing.Bounce;
import com.greensock.easing.Cubic;
import mx.collections.ArrayList;
import spark.core.SpriteVisualElement;
private function init():void {
var g:Graphics = myComp.graphics;
g.clear();
g.beginFill(0xCCCCCC);
g.drawRect(0, 0, myComp.width, myComp.height);
g.endFill();
}
private function handleClick(event:MouseEvent):void {
var star:SpriteVisualElement = new Star();
star.x = event.localX;
star.y = event.localY;
myComp.addChild(star);
TweenMax.to(star, 2, {
bezier: [
{x:star.x + 10, y:star.y - 20, scaleX: 1, scaleY: 1},
{x:star.x + 20, y:star.y + 20, scaleX: 1.2, scaleY: .8},
{x:star.x + 20, y:star.y + 30, scaleX: 1, scaleY: 1}],
orientToBezier: false,
ease: Bounce.easeOut
});
var flyTween:TweenMax = TweenMax.to(star, 1, {
delay: 10,
ease: Cubic.easeOut,
bezier: [
{x: myComp.width - star.width, y: Math.max(event.localY, myComp.height/2)},
{x: myComp.width - star.width, y: 0}
],
onComplete: function():void {
myComp.removeChild(star);
// XXX how to remove mouse over listener here?
}
});
star.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
flyTween.complete();
});
}
]]>
</fx:Script>
<mx:UIComponent id="myComp" width="100%" height="100%" click="handleClick(event)" />
</s:Application>