Jump to content
Search Community

is it possible to tween numbers to count down?

herke test
Moderator Tag

Recommended Posts

Hey,

 

Is it possible to use this when its in a class? i'm getting errors when trying the simplest example with this class:

"ReferenceError: Error #1069: Property startTotal not found on PriceCalculator and there is no default value."

 

package  {
import flash.display.MovieClip;
import com.greensock.TweenMax;
import com.greensock.easing.*;

public class PriceCalculator extends MovieClip {
	var startTotal:Number 	= 100;
	var newTotal:Number 	= 200;

	public function PriceCalculator() {
	}

	public function updatePrices():void {
		TweenMax.to(this, 2, {startTotal:newTotal, onUpdate:updateTotal});
		function updateTotal(){
			trace(startTotal)
		}
	}
}
}

 

is there any way round this?

 

Cheers

Neil

Link to comment
Share on other sites

  • 3 years later...

	
	public class BigWin
	{
		private var bgClass:Class;
		private var bgSpr:Sprite;
		private var mtx:Matrix = new Matrix()
		private var bgMC:MovieClip;
		private var mcHolder:MovieClip = new MovieClip()
		private var timeline:TimelineLite;
		private var tempMC:MovieClip
		private var initScore:int;
		private var targetScore:int;
		
		public function BigWin():void
		{
			mtx.createGradientBox(Main.game.config.swfWidth, Main.game.config.swfHeight, Math.PI * 0.5, 0, 0);
			bgSpr = new Sprite()
			bgSpr.graphics.beginGradientFill(GradientType.LINEAR, [0x000000, 0x000000], [.6, 0], [80, 180], mtx)
			bgSpr.graphics.drawRect(0, 0, Main.game.config.swfWidth, Main.game.config.swfHeight)
			bgSpr.graphics.endFill()
			mcHolder.addChild(bgSpr)
			
			bgClass = Main.queue.getLoader('main_uiMC').getClass('bigwinBgMC') as Class;
			bgMC = new bgClass()
			bgMC.x = (Main.game.config.swfWidth - bgMC.width) >> 1
			bgMC.y = ((Main.game.config.swfHeight - bgMC.height) >> 1) - 80
			
			mcHolder.addChild(bgMC)
		}
		
		public function start():void
		{
			initScore = 0;
			targetScore = 400
			
			mcHolder.alpha = 0;
			Main.mainMC.addChild(mcHolder)
			
			TweenLite.to(mcHolder, .3, {alpha: 1});
			winamount()
			
			timeline = new TimelineLite()
			timeline.append(TweenLite.to(MovieClip(bgMC.getChildByName('glowMC')), 1, {scaleX: 1.3, scaleY: 1.3, delay: .3}))
			timeline.append(TweenLite.to(MovieClip(bgMC.getChildByName('glowMC')), 1, {alpha: 0}))
		}
		
		private function winamount():void
		{
			tempMC = MovieClip(bgMC.getChildByName('winAmountMC')) as MovieClip
			
			TweenLite.to(tempMC, 0, {glowFilter: {color: 0x69FF00, alpha: .9, blurX: 2, blurY: 2, strength: 4, quality: 3}, dropShadowFilter: {color: 0x000000, alpha: 0.7, blurX: 12, blurY: 12, strength: 2, angle: 90, distance: 0}})
			TweenLite.to(tempMC, 1, {initScore:targetScore, onUpdate:updateScore, ease:Linear.easeNone});
		}
		
		private function updateScore():void
		{
			trace(initScore, targetScore)
		}
	}


Currently the trace back result for initScore is 0.

Not sure y it does not adds up

Link to comment
Share on other sites

Its preferable to provide a simplified FLA that we can actually compile.

From looking at your code it looks like initScore is a property of your BigWin class but you are trying to tween it as if it is a property of tempMC.

 

Prior to your tempMC tween add

trace("tempMC.initScore = " + tempMC.initScore);

my guess is that it will come up undefined or null, if so you may need to add

tempMC.initScore = someValue

Or you may want to tween this.initScore 

TweenLite.to(this, 1, {initScore:targetScore})
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...