Jump to content
Search Community

Problem on using TweenLite for animation on filtering

toStephen test
Moderator Tag

Recommended Posts

Hi all,

 

I need to build a flash application that requires filtering of spots. Every time the user selects another filter i reload the layout function, remove all objects that are currently in the movieclip and then re-add them and re-apply the tween with one for lus.

 

But for some odd reason, when i change the filter before all the tweens are completed, they stop rendering at the point i changed it. Causing the tween to get stuck... and displaying only half on the results. They get added in the display list but just aren't shown due to the tween not completing.

 

Does someone has a solution? I think i need to reset the tweens on the object or clear something...

 

override public function layout():void
 {
  var coloms:int = Math.floor(componentWidth/116.65);
  var padding:Number = 5;

  while(this.numChildren > 0)
  {
   TweenLite.killDelayedCallsTo(getChildAt(0));
   TweenLite.killTweensOf(getChildAt(0));
   this.removeChildAt(0);
  }

  if(tiles.length > 0)
  {
   trace('Thera are: '+this.numChildren+' in the displaylistt');
   for(var i:int = 0; i < tiles.length; i++)
   {
 var spotThumb:SpotThumb = tiles[i];
 spotThumb.x = (i % coloms) * (116.65 + padding);
 spotThumb.y = int(i / coloms) * (116.65 + padding);
 trace(i);
 switch(appModel.currentFilter)
 {
  case 'alle':
  default:
  {
   addChild(spotThumb);
   break;
  }	 
  case 'like':
  {
   break;
  }

  case 'monument':
  case 'foodendrinks':
  case 'vervoer':
  case 'shoppen':
  case 'hotel':
  { 
   if(spotThumb.spotCat == appModel.currentFilter)
   {
    addChild(spotThumb);
   }
   break;
  }
 }
 TweenLite.from(spotThumb, 0.2, {alpha:0, delay: 0.1*i});
   }
  }
 }

 

Thanks in advance!

 

Stephen

Link to comment
Share on other sites

I got a little lost in your description and your code. I think the problem is that you are using a

from() tween.

 

see if the following explanation applies to your application.

 

i have a movie clip named mc on the stage.

it currently has an alpha of 1.

every time I click on it I the following code will execute

 

TweenLite.from(mc, 10, {alpha:0, ease:Linear.easeNone});

 

the alpha gets set immediately to 0 and the tween begins increasing the alpha towards 1.

 

5 seconds later the alpha will have tweened to .5 (remember the duration is 10 seconds).

 

If i click mc at the 5-second point the tween will reset and tween FROM an alpha of 0 TO an alpha of .5

 

perhaps you will need to use a TweenMax.fromTo() tween

 

TweenMax.fromTo(spotThumb, .2, {alpha:0}, {alpha:1, delay:0.1*i});

 

OR manually set the alpha of your clips to 1 prior to tweening from alpha 0.

 

spotThumb.alpha = 0;
TweenLite.from(spotThumb, 0.2, {alpha:0, delay: 0.1*i});

 

hope this sheds some light on your situation.

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