Arghya Posted August 1, 2014 Share Posted August 1, 2014 How to get totalProgress and currentProgress value when tween is executed using TweenMax....??? Link to comment Share on other sites More sharing options...
jamiejefferson Posted August 1, 2014 Share Posted August 1, 2014 progress() totalProgress() Link to comment Share on other sites More sharing options...
Arghya Posted August 1, 2014 Author Share Posted August 1, 2014 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???? Link to comment Share on other sites More sharing options...
Carl Posted August 1, 2014 Share Posted August 1, 2014 This sounds more like an issue of figuring out how your app is structured than something related to GSAP. To expand on Jamie's suggestion: var tween:TweenMax = TweenMax.to(mc, 1, {x:300}); //then to get or set a progress tween.progress() //get tween.progress(1) // set I really don't know how to suggest that you gain a reference to the tween from one class to another from what you have provided Link to comment Share on other sites More sharing options...
Arghya Posted August 2, 2014 Author Share Posted August 2, 2014 (edited) //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? Edited August 2, 2014 by jamiejefferson added code blocks Link to comment Share on other sites More sharing options...
jamiejefferson Posted August 2, 2014 Share Posted August 2, 2014 We can't really focus on teaching you how to use and share data between objects, but it looks like you are already using doNext as an onComplete, so you probably just need to put whatever code is needed to alert your Main class in the doNext function. Perhaps trigger a custom event and use a listener in main? If you just want a reference to the tween, make objecttween public. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now