Jump to content
Search Community

Jerky performance, I did something bad!

mrEmpty test
Moderator Tag

Recommended Posts

Hello.

 

OK, so I'm getting bad performance with some tweens, I'm guessing I did something bad as Greensock never fails me.

 

What I'm doing is tweening some sprites up and down based upon mouseX:

 

public function parallaxLogic(ParallaxYTransition:Number):void
	{
		for (var i:int = 0; i < paraLayers; i++)
		{
			TweenLite.to(paraArray[i], 0.5, {y:(ParallaxYTransition * paraRatio * i)});
			//paraArray[i].y = (ParallaxYTransition * paraRatio) * i;
			//trace(paraArray[i].y);
		}
	}

 

I have some sprites in an array, and based upon a ration number, the sprites in that array move more or less than each other (parallax). I call this function by:

 

...
stage.addEventListener(MouseEvent.MOUSE_MOVE, init);
	}

	private function init(event:MouseEvent):void
	{
		ppp.parallaxLogic(mouseY);
	}

 

I'm guessing it's to do with the array, and the time taken to loop through it?

 

Simple FLA with classes attached. :)

Link to comment
Share on other sites

it may be because you are are constantly creating new tweens with new end values that are drastically different than the previous tweens (fast mouse movement).

you also didn't mention how many objects are in your array.

i couldn't open your file.

 

 

 

something like this (with better math) might do what you want:

 

http://www.snorkl.tv/dev/cheapParallax/

move mouse left to right (but not too far right, it bugs out when you move off stage in some browsers)

 

import com.greensock.*;
import flash.events.MouseEvent;

addEventListener(Event.ENTER_FRAME, moveIt);

function moveIt(e:Event):void{
//small box in background
box1.x +=( mouseX - box1.x) * .05
//large box if foreground
box2.x +=( mouseX - box2.x) * .1

}

 

files attached

Link to comment
Share on other sites

Hello.

 

The moves aren't radically different at the moment, the problem happens if I manually enter different tween values also. I currently have 5 layers, each with 1 sprite (a basic square).

 

I use Flash 5.5, I can save as version 5 if that's easier?

 

Displaying frame rate my movie is running at 60fps, so it may just be my eyes. But it does look less smooth than I'd normally expect.

Link to comment
Share on other sites

I just tested this on a different system, it's working fine. I'm guessing a lot of the odd issues I've been having are either down to Lion + CS5.5 or the way the IT Department configured this Mac. It's behaving badly.

 

A good example is code that will compile and run fine, will then decide to not compile at all and throw an error, normally to do with not being able to find external classes. And then a simple quit and re-run of Flash solves the problem. It means I can spend ages to trying to find the problem in my code, only to discover it doesn't exist.

 

But it's good to know my base Parallax system runs, and I can move on with it.

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