Jump to content
Search Community

Strange autoAlpha behavior 4 Sprites when initially loading

spizer test
Moderator Tag

Recommended Posts

So I'm getting some inconsistent behavior with tweened Sprites.

 

Basically... I'm loading a series of Sprites that have their content filled from an XML document, then each stored in an array. Only three ever show at a time, but nne of this really matters... what matters is... For some reason, when I initially load the Sprites, the autoAlpha property seems to mess up, by seemingly granting different levels of transparency. Now, it gets stranger. I apply listeners to the Sprites, so that when you rollover them, autoAlpha = 1 and that works perfect, then when you roll off and autoAlpha = .5 it works like its supposed to.

 

_xPositions is an array of preset positions for the "cards"

img is a Sprite

and

 

Here's the initial placement code:

					case 1 :
					img.x=this._xPositions[3];
					TweenMax.from(img, 1, {y: "100", onComplete:addCardListeners, onCompleteParams:[img]});
					TweenMax.to(img, 1, {autoAlpha:0.5, ease:Expo.easeOut, overwrite: false});
					loadTH(id);
					this._images[id].thLoaded = true;
					break;

 

The Rollover:

		if ($evt.currentTarget.isMainImage == false && $evt.currentTarget.x < stage.stageWidth/2) {
		//tempX = (this._xPositions[1] + Math.ceil(this._images[$evt.currentTarget.id].popMC.width *.45));
		tempX = this._images[$evt.currentTarget.id].popMC.width - (this._images[$evt.currentTarget.id].popMC.width - ((this._images[$evt.currentTarget.id].popMC.width * 2) - stage.stageWidth)) / 2;
		tempX = (this._xPositions[1] + tempX);			
		TweenMax.to(tempIMG, .25, {x: tempX, autoAlpha:1, blurFilter:{blurX:0, blurY:0}, ease:Expo.easeOut, onComplete:removeRollOver, onCompleteParams:[tempIMG], overwrite: true});

	} else if ($evt.currentTarget.isMainImage == false && $evt.currentTarget.x > stage.stageWidth/2) {
	        tempX = this._images[$evt.currentTarget.id].popMC.width - (this._images[$evt.currentTarget.id].popMC.width - ((this._images[$evt.currentTarget.id].popMC.width * 2) - stage.stageWidth)) / 2;
		tempX = (this._xPositions[3] - tempX);
		TweenMax.to(tempIMG, .25, {x: tempX, autoAlpha:1, blurFilter:{blurX:0, blurY:0}, ease:Expo.easeOut, onComplete:removeRollOver, onCompleteParams:[tempIMG], overwrite: true});

 

The RollOff:

		if ($evt.currentTarget.isMainImage == false && $evt.currentTarget.x < stage.stageWidth - ((stage.stageWidth/3)*2)) 
	{
		tempX = this._xPositions[1];
		TweenMax.to(tempIMG, .25, {x: tempX, autoAlpha:.5, ease:Expo.easeOut, onComplete:addRollOver, onCompleteParams:[tempIMG], overwrite: true});

	} else if ($evt.currentTarget.isMainImage == false && $evt.currentTarget.x > stage.stageWidth - ((stage.stageWidth/3)*2)) 
	{
		tempX = this._xPositions[3];
		TweenMax.to(tempIMG, .25, {x: tempX, autoAlpha:.5, ease:Expo.easeOut, onComplete:addRollOver, onCompleteParams:[tempIMG], overwrite: true});

 

I've tried using the fromTo method, but that has an implied overwrite of true which for whatever reason prevents the Sprite from even beginning the tween in my code...

 

I'm stumped. Am I just going to have to live with this?

Link to comment
Share on other sites

Hi spizer,

Your code should work from what you've posted.

Is there any chance you could post a simple use case scenario FLA with the offending behaviour?

 

I assume you tried tracing the alpha value after each sprite is tweened to see what it's returning?

 

Also, you can set the Overwrite value on a per tween basis, so you're not limited to the default value:

http://www.greensock.com/overwritemanager/

Link to comment
Share on other sites

The trace comes back consistent between the two, and I've tried using (just for giggles) each of the overwrite types. To no avail... I'll see if I can mock something up, cheers for the response. :)

Link to comment
Share on other sites

It definitely sounds like there's something else going on in your code so I'd echo X10's request for a very simple FLA that demonstrates the behavior. Doesn't sound like an overwrite issue to me.

 

You said the problem was just when you "load" the Sprites - are you maybe starting the tweens before the content fully loads and thus the tween is partially finished before the content even shows up on the stage? Just curious.

Link to comment
Share on other sites

  • 1 month later...
You said the problem was just when you "load" the Sprites - are you maybe starting the tweens before the content fully loads and thus the tween is partially finished before the content even shows up on the stage? Just curious.

 

Interesting!! I'll see what happens if I tell the function not to run till the data is done loading. :) At work at the moment, so I'll have to wait till I get home to try it.

 

Also, you can see the evil that I've put together at:

 

http://www.robowaffle.com/

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