Jump to content
Search Community

throwProps very choppy [HELP]

Applauz test
Moderator Tag

Recommended Posts

I have 2 images stacked.. both are 1024 x 768 fps is set to 60 This is an AIR for iOS projects in Flash CS5.5 Rendering is set to GPU

 

 

Here is my code

 

// Blitmasking for Section 1

TweenPlugin.activate([ThrowPropsPlugin]);



var blitMask:BlitMask = new BlitMask(section1_mc, section1_mc.x, section1_mc.y, section1_mc.width, section1_mc.height, true);

blitMask.scrollX = 0;

// This makes the blitMask interactive
blitMask.bitmapMode = false;

var t1:uint, t2:uint, y1:Number, y2:Number;

blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);




function mouseDownHandler(event:MouseEvent):void {

blitMask.bitmapMode = true;

TweenLite.killTweensOf(section1_mc);
y1 = y2 = section1_mc.y;
t1 = t2 = getTimer();
blitMask.scrollX = 0;
section1_mc.startDrag();
section1_mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
section1_mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}

function enterFrameHandler(event:Event):void {
y2 = y1;
t2 = t1;
y1 = section1_mc.y;
t1 = getTimer();
blitMask.scrollX = 0;
blitMask.update();
}

function mouseUpHandler(event:MouseEvent):void {

blitMask.bitmapMode = false;
blitMask.scrollX = 0;
section1_mc.stopDrag();
section1_mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
section1_mc.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (section1_mc.y - y2) / time;
var yOverlap:Number = Math.max(0, section1_mc.height - section1_mc.height);

ThrowPropsPlugin.to(section1_mc, {throwProps:{
							 y:{velocity:yVelocity, max:0, min:-768, resistance:200}
						 }, onUpdate:blitMask.update, ease:Strong.easeOut
						}, 10, 0.3, 0.5);
}


 

 

Is there something I am doing wrong here ? It's extremely choppy and laggy

Link to comment
Share on other sites

I'm very confused by what you're doing in a few places...

 

You set the BlitMask's scrollX to 0 on mouseDown and on every frame while the mouse is being dragged - why? That would force it to basically sit still while the user is dragging their mouse. It would also cause it to jump to the top whenever someone clicks on it. That seems very unintuitive and it explains why things look jumpy.

 

And then you set bitmapMode back to false exactly when you need the performance boost the most (while the throwProps tween is happening). Why? Remember, you will only see the speed benefits of BlitMask when its bitmapMode is turned on (otherwise it just acts like a regular mask which isn't nearly as fast in Flash but it does give you interactivity for mouse events).

 

I assume that maybe you want to remove all the lines of code where you set scrollX and then also remove that line in the mouseUpHandler() where you set bitmapMode to false. If you want bitmapMode to turn false when the tween is finished so that you can get interactivity again, just use an onComplete in the tween and point it to the BlitMask's disableBitmapMode method. Like onComplete:blitMask.disableBitmapMode.

Link to comment
Share on other sites

Hi,

 

Sorry .. I'm just getting the hang of this plugin.

 

The reason I was setting the scrollX to 0 was because it was shifting when I would drag left & right... I only want it to move then scrolling up and down.

 

I'll apply the other changes and test again.

 

 

Cheers!

Link to comment
Share on other sites

Here is my updated code.

 

Believe it or not .. performance is now even worse than it was before. .. Am I missing something here ? Your help is appreciated.

 

TweenPlugin.activate([ThrowPropsPlugin]);



var blitMask:BlitMask = new BlitMask(section1_mc, section1_mc.x, section1_mc.y, section1_mc.width, section1_mc.height, true);




blitMask.bitmapMode = true;

var t1:uint, t2:uint, y1:Number, y2:Number;

blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);




function mouseDownHandler(event:MouseEvent):void {



TweenLite.killTweensOf(section1_mc);
y1 = y2 = section1_mc.y;
t1 = t2 = getTimer();

section1_mc.startDrag();
section1_mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
section1_mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}

function enterFrameHandler(event:Event):void {
y2 = y1;
t2 = t1;
y1 = section1_mc.y;
t1 = getTimer();

blitMask.update();
}

function mouseUpHandler(event:MouseEvent):void {



section1_mc.stopDrag();
section1_mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
section1_mc.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (section1_mc.y - y2) / time;
var yOverlap:Number = Math.max(0, section1_mc.height - section1_mc.height);

ThrowPropsPlugin.to(section1_mc, {throwProps:{
							 y:{velocity:yVelocity, max:0, min:-768, resistance:300}
						 }, onUpdate:blitMask.update, ease:Strong.easeOut
						}, 10, 0.3, 1);
}



Link to comment
Share on other sites

I'm very confused by what you're doing in a few places...

 

You set the BlitMask's scrollX to 0 on mouseDown and on every frame while the mouse is being dragged - why? That would force it to basically sit still while the user is dragging their mouse. It would also cause it to jump to the top whenever someone clicks on it. That seems very unintuitive and it explains why things look jumpy.

 

And then you set bitmapMode back to false exactly when you need the performance boost the most (while the throwProps tween is happening). Why? Remember, you will only see the speed benefits of BlitMask when its bitmapMode is turned on (otherwise it just acts like a regular mask which isn't nearly as fast in Flash but it does give you interactivity for mouse events).

 

I assume that maybe you want to remove all the lines of code where you set scrollX and then also remove that line in the mouseUpHandler() where you set bitmapMode to false. If you want bitmapMode to turn false when the tween is finished so that you can get interactivity again, just use an onComplete in the tween and point it to the BlitMask's disableBitmapMode method. Like onComplete:blitMask.disableBitmapMode.

 

 

Sorry for so many posts.

 

I got the performance thing fixed.

 

Just can't figure out how to lock the X coord at 0 without setting scrollX to 0 in the enterframe

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