Jump to content
Search Community

TimelineLite crashes on mouse events

penny test
Moderator Tag

Recommended Posts

Hello,

 

in my ongoing project i'm building animated menu using TimelineLite - main idea is to play and reverse timeline on mouse events. I create few instances of Menu class, and play them with the mouse hard (multiple rollovers and rollouts). At first it plays smooth, then some of instances stop responding to mouse events and finally Flash Player crashes.

 

Here is my Menu class. Is this the problem with TimelineLite or am i doing it wrong?

 

package 
{
import assets.MenuClip;

import com.greensock.TimelineLite;
import com.greensock.TweenLite;

import flash.display.Shape;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;

public class Menu extends MenuClip
{
	private var timeline:TimelineLite;

	private var over:Boolean;

	private var background:Shape;

	public function Menu( $data:XML )
	{
		super();

		graphics.beginFill( 0x00FFFF, 1 );
		graphics.drawRect( 0, 0, 265, 36 );
		graphics.endFill();

		tf.autoSize = TextFieldAutoSize.LEFT
		tf.text = $data.title;

		background = new Shape();
		background.graphics.beginFill( 0xA10000, 1 );
		background.graphics.drawRect( 0, 0, 265, 36 );
		background.graphics.endFill();
		background.width = 0;
		background.alpha = 0;
		addChildAt( background, 0 );

		timeline = new TimelineLite();
		timeline.append( new TweenLite( background, .4, { alpha: 1, width: 500 } ) );
		timeline.stop();

		addEventListener( MouseEvent.ROLL_OVER, this_mouseEventHandler );
		addEventListener( MouseEvent.ROLL_OUT, this_mouseEventHandler );
	}

	private function this_mouseEventHandler( $event:MouseEvent ):void
	{
		switch ( $event.type )
		{
			case MouseEvent.ROLL_OVER:
			{
				timeline.play();
				break;
			}
			case MouseEvent.ROLL_OUT:
			{
				timeline.reverse();
				break;
			}
		}
	}
}
}

Link to comment
Share on other sites

I don't see any problems here - I suspect there's an issue somewhere else in your code. Tough to say without seeing it, though. This code doesn't push the engine hard at all - I've had stuff that's literally 1000x more complex than this running very smoothly inside a TimelineLite. Also please make sure you're using the latest version of the classes. http://www.tweenmax.com

Link to comment
Share on other sites

Hi,

 

this is a test code that does exactly the same as my original code (it crashes too).

 

package {
import flash.display.Sprite;
import flash.geom.Point;

public class TimelineMaxTest extends Sprite
{
	public function TimelineMaxTest()
	{
		var menu:Menu;
		var i:int = 6, anchor:Point = new Point();
		while( --i != 0 )
		{
			menu = new Menu();
			menu.y = anchor.y;
			addChild( menu );
			anchor.y += 36;
		}
	}
}
}

 

package
{
  import com.greensock.TimelineMax;
  import com.greensock.TweenLite;

  import flash.display.Shape;
  import flash.display.Sprite;
  import flash.events.MouseEvent;

  public class Menu extends Sprite
  {
     private var timeline:TimelineMax;

     private var over:Boolean;

     private var background:Shape;

     public function Menu()
     {
        super();

        graphics.beginFill( 0x00FFFF, 1 );
        graphics.drawRect( 0, 0, 265, 36 );
        graphics.endFill();

        background = new Shape();
        background.graphics.beginFill( 0xA10000, 1 );
        background.graphics.drawRect( 0, 0, 265, 36 );
        background.graphics.endFill();
        background.width = 0;
        background.alpha = 0;
        addChildAt( background, 0 );

        timeline = new TimelineMax();
        timeline.append( new TweenLite( background, .4, { alpha: 1, width: 500 } ) );
        timeline.stop();

        addEventListener( MouseEvent.ROLL_OVER, this_mouseEventHandler );
        addEventListener( MouseEvent.ROLL_OUT, this_mouseEventHandler );
     }

     private function this_mouseEventHandler( $event:MouseEvent ):void
     {
        switch ( $event.type )
        {
           case MouseEvent.ROLL_OVER:
           {
              timeline.play();
              break;
           }
           case MouseEvent.ROLL_OUT:
           {
              timeline.reverse();
              break;
           }
        }
     }
  }
}

 

I'm using the latest version of TimelineMax. After a crash the Flex Debugger shows that the script execution time has exceeded in class SimpleTimeline, function renderTime, on "while (tween)".

 

It happens on both Mac and Windows if it matters, i'm compiling in Flex Builder.

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