Jump to content
Search Community

Arghya

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by Arghya

  1. //This is CustomClass

    package
    {
        import flash.display.MovieClip;
        import com.greensock.*;
        import com.greensock.data.*;
        import com.greensock.easing.*;
        
        public class CustomClass extends MovieClip
        {
            private var _emptyMC:MovieClip = new MovieClip();
            private var _back:MovieClip = new MovieClip();
            public var tweenArray:Array = new Array();
            private var objecttween:TweenMax;
            
            public function CustomClass()
            {
                this.addChild(_emptyMC);
                _emptyMC.addChild(_back);
                drawShape();
            }
            
            private function drawShape():void
            {
                _back.graphics.clear();
                _back.graphics.beginFill(0xFFCC00);
                _back.graphics.drawRect(0,0,100,100);
                _back.graphics.endFill();
            }
            
            public function tweenExecute():void
            {
                objecttween = TweenMax.to(this,Number(tweenArray[0].time),{x:Number(tweenArray[0].x),y:Number(tweenArray[0].y),scaleX:Number(tweenArray[0].scalex),scaleY:Number(tweenArray[0].scaley),rotation:Number(tweenArray[0].rotation),tint:uint(tweenArray[0].color),delay:Number(tweenArray[0].delay),paused:tweenArray[0].tweenPause,ease:Linear.easeNone,onComplete:doNext,onCompleteParams:[Number(tweenArray[0].gotoFrame)-1]});
            }
            
            private function doNext(id:Number):void
            {
                objecttween = TweenMax.to(this,Number(tweenArray[id].time),{x:Number(tweenArray[id].x),y:Number(tweenArray[id].y),scaleX:Number(tweenArray[id].scalex),scaleY:Number(tweenArray[id].scaley),rotation:Number(tweenArray[id].rotation),tint:uint(tweenArray[id].color),delay:Number(tweenArray[id].delay),paused:tweenArray[id].tweenPause,ease:Linear.easeNone,onComplete:doNext,onCompleteParams:[Number(tweenArray[id].gotoFrame)-1]});
            }
        }
    }
     

     

    //This is Main Class

    package
    {
        import flash.display.MovieClip;
        import CustomClass;
        import flash.events.Event;
        import flash.events.MouseEvent;
        
        public class Main extends MovieClip
        {
            private var _empty:MovieClip = new MovieClip();
            private var cc:CustomClass;
            
            public function Main()
            {
                addEventListener(Event.ADDED_TO_STAGE,init);
            }
            
            private function init(e:Event):void
            {
                this.addChild(_empty);
                addShape();
                btn.addEventListener(MouseEvent.CLICK,onClick);
            }
            
            private function addShape():void
            {
                cc = new CustomClass();
                cc.x = 20;
                cc.y = 100;
                _empty.addChild(cc);
                
                cc.tweenArray.push({x:20,y:100,scalex:1,scaley:1,color:0xFFCC00,alpha:1,rotation:0,time:0.5,delay:0,tweenPause:false,gotoFrame:2});
                cc.tweenArray.push({x:300,y:400,scalex:1,scaley:1,color:0xFFCCCC,alpha:1,rotation:0,time:1,delay:0,tweenPause:false,gotoFrame:3});
                cc.tweenArray.push({x:600,y:100,scalex:1,scaley:1,color:0xFF0000,alpha:1,rotation:0,time:1,delay:0,tweenPause:false,gotoFrame:4});
                cc.tweenArray.push({x:20,y:100,scalex:1,scaley:1,color:0xFFCC00,alpha:1,rotation:0,time:1,delay:0,tweenPause:false,gotoFrame:2});
                
                //cc.tweenExecute();
            }
            
            private function onClick(e:MouseEvent):void
            {
                cc.tweenExecute();
            }
        }
    }
     

     

     

    there is button and i execute the tween when button is clicked. From Main class how to find when the tween is completed?

  2. Actually I have written a public funvtion name tweenExecute inside a custom class. Now I access this custom class instance from main and i want when tween is completed of that custom class instance. How can i find out????

  3. How to reset tween using TweenMax and change the clip to the initial position with all its properties like x,y scaleX, scaleY, color etc... plz give an example.........

×
×
  • Create New...