Jump to content
Search Community

afarber

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by afarber

  1. 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>
    

  2. Hello,

     

    I'm trying to reproduce "doobers" - i.e. coins, stars, etc. provided to players in games after they performed simple tasks, like chopping a tree.

     

    The doobers would usually

     

    1) Bounce and change dimensions at the same time (bigger width, smaller height and then back to normal)

    2) Fly in a bezier curve up to the score bar

    3) Lighten up in a polaroid effect for a split-second.

     

    I have prepared a complete working example and screenshot for the 2)

     

    but don't know how to do 1) and 3).

     

    Any ideas please?

     

    Regards

    Alex

     

    P.S. Below my test case code and screenshot:

     

    Gm5qR.png

     

    Star.fxg:

     

    <?xml version='1.0' encoding='UTF-8'?>
    <!-- fxg/star.fxg -->
    <fxg:Graphic xmlns:fxg="http://ns.adobe.com/fxg/2008" version="2">  
    <fxg:Path x="9.399" y="10.049" data="M 82.016 78.257 L 51.895 69.533 L 27.617 89.351 L 26.621 58.058 L 0.231 41.132 L 29.749 30.52 L 37.714 0.241 L 56.944 24.978 L 88.261 23.181 L 70.631 49.083 Z">
    	<fxg:fill>
    		<fxg:SolidColor color="#FFFFFF"/>
    	</fxg:fill>
    	<fxg:stroke>
    		<fxg:SolidColorStroke
    			caps="none"
    			color="#4769C4"
    			joints="miter"
    			miterLimit="4"
    			weight="20"/>
    	</fxg:stroke>
    </fxg:Path>
    </fxg:Graphic>
    

     

    MyApp.mxml:

     

    <?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 mx.collections.ArrayList;
    		import spark.core.SpriteVisualElement;
    		import com.greensock.TweenMax;
    		import com.greensock.easing.Cubic;
    		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, 1, {
    				delay: 2,
    				ease:  Cubic.easeOut,
    				bezier: [
    					{x: myComp.width - star.width, y: Math.max(event.localY, myComp.height/2)},
    					{x: myComp.width - star.width, y: 0}
    				]
    			});
    		}
    	]]>
    </fx:Script>  
    <mx:UIComponent id="myComp" width="100%" height="100%" click="handleClick(event)" />
    </s:Application>
    

×
×
  • Create New...