Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Owen Corso

Tweens keep losing MouseEvents!

Recommended Posts

hi, i love Greensock class packages! i use them exclusively now.

 

i am having a problem lately with my tweens (i think 2 separate problems). they seem to get lost or mixed up or garbage collected or whatever

1) if you mess with them before they're finished, they screw up

2) the MouseEvents are not smoothly being listened to. like if you jiggle the mouse over the sprite, it will lose the over event.

 

www.jackandjasper.com

 

maybe you can tell if my techniques are wrong just by looking at this class:

 

package com.jackandjasper.util
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;

import gs.TweenLite;
import gs.easing.Back;

import lt.uza.utils.Global;

public class SideNavBtn extends Sprite
{
	private var global:Global;
	private var id:Number;
	private var spr:Sprite;
	private var tf:TextField;
	private const outColor:Number = 0xd0ccb5;
	private const overColor:Number = 0xFFFF66;
	private const textTint:Number = 0x966241;
	private var myOverTintTween:TweenLite;


	public function SideNavBtn(passedInID:Number, passedInLabel:String)
	{
		super();
		global = Global.getInstance();
		id = passedInID;
		var f:Fill = new Fill();
		spr = f.doFill(outColor, 300, 40);
		tf = new TextField();
		tf.x = tf. y = 10;
		tf.selectable = false;
		if(global.css){
			tf.styleSheet = global.css;
		}
		tf.htmlText = "
" + passedInLabel + "";
		addChild(spr);
		addChild(tf);
		addEventListener(MouseEvent.MOUSE_OVER, over);
		addEventListener(MouseEvent.MOUSE_OUT, out);
		addEventListener(MouseEvent.CLICK, clicked);

	}
	private function over(e:MouseEvent=null):void{
		myOverTintTween = TweenLite.to(spr, 1, {tint:overColor, ease:Back.easeOut});
		TweenLite.to(tf, 1, {tint:textTint, scaleX:1.2, scaleY:1.2, x:20, ease:Back.easeOut});

	}//end over
	private function out(e:MouseEvent):void{
		myOverTintTween = TweenLite.to(spr, 1, {removeTint:true, ease:Back.easeOut});
		TweenLite.to(tf, 1, {removeTint:true, scaleX:1, scaleY:1, x:10, ease:Back.easeOut});
	}//end out
	private function clicked(e:MouseEvent):void{
		global.id = id;

	}//end clicked

}//end class SideNavBtn
}//end package

Link to comment
Share on other sites

as you can see above, i tried instantiating the tween as a class variable in an effort to protect it from being garbage collected but i'm still having the issue.

Link to comment
Share on other sites

1) if you mess with them before they're finished, they screw up

 

Please define "mess with". Also, I would recommend making sure you have the latest version of the classes from http://www.tweenlite.com.

 

2) the MouseEvents are not smoothly being listened to. like if you jiggle the mouse over the sprite, it will lose the over event.

 

TweenLite/Max will never effect the way your MouseEvents are being listened to. There's no code in there that could possibly do it (unless I'm going nuts which is always a possibility). Have you put a trace() in there to see if the handler is getting called? I noticed you're using MOUSE_OVER/MOUSE_OUT which is a common mistake. Those get triggered every time ANY of the children of that object are rolled over/out. I suspect you meant to use ROLL_OVER/ROLL_OUT instead. Try that and update to the latest version of TweenLite/Max and let us know if anything gets fixed.

Link to comment
Share on other sites

mess with = switch states quickly before the state is done with tweening objects into place to build the state (ie go back and forth to home>people>Our Story on jackandjasper.com).

 

thanks for the tip on ROLL_OVER vs MOUSE_OVER,that definitely fixes one of the problems.

Link to comment
Share on other sites

I'm not sure exactly what to tell you about the state changing issues you're having other than to say that I've done stuff like that frequently (as have lots of other TweenLite/Max users) without any problems. I'd need to see the code and setup to troubleshoot effectively (can't look at anything in-depth today/tomorrow, though - rush projects on my plate). I'd recommend doing the ROLL_OVER/OUT thing and making sure you have the latest classes and double-check your logic on the flow of things and let us know what you find.

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