Share Posted March 8, 2015 hey guys, using throwprops and blitmask. using the code from the generator. since I have buttons in my movieclip, I can't have blitmask going all the time. so I can't tell if it's enabling or not. can someone with some skills check to see if I've done this correct, or if there's a better way? I've bolded the two places. I didn't use the enable/disable but true/false modes. var bounds:Rectangle = new Rectangle(0, 0, 1280.15, 720); var blitMask:BlitMask = new BlitMask(main, bounds.x, bounds.y, bounds.width, bounds.height, false); //blitMask.bitmapMode = false; var t1:uint, t2:uint, y1:Number, y2:Number, yOverlap:Number, yOffset:Number; blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseDownHandler(event:MouseEvent):void { TweenLite.killTweensOf(main); y1 = y2 = main.y; yOffset = this.mouseY - main.y; yOverlap = Math.max(0, main.height - bounds.height); t1 = t2 = getTimer(); blitMask.bitmapMode = true; main.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); main.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function mouseMoveHandler(event:MouseEvent):void { var y:Number = this.mouseY - yOffset; //if main's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { main.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { main.y = (y + bounds.top - yOverlap) * 0.5; } else { main.y = y; } blitMask.update(); var t:uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { y2 = y1; t2 = t1; y1 = main.y; t1 = t; } event.updateAfterEvent(); } function mouseUpHandler(event:MouseEvent):void { main.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); main.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); var time:Number = (getTimer() - t2) / 1000; var yVelocity:Number = (main.y - y2) / time; ThrowPropsPlugin.to(main, {throwProps:{ y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:50} }, onUpdate:blitMask.update, ease:Strong.easeOut }, 2, 0.3, 0.5); blitMask.bitmapMode = false; } Link to comment Share on other sites More sharing options...
Author Share Posted March 8, 2015 or only put it here. I can't tell the difference function mouseUpHandler(event:MouseEvent):void { main.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); main.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); var time:Number = (getTimer() - t2) / 1000; var yVelocity:Number = (main.y - y2) / time; ThrowPropsPlugin.to(main, {throwProps:{ y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:50} }, onStart:blitMask.enableBitmapMode, onUpdate:blitMask.update, onComplete:blitMask.disableBitmapMode, ease:Strong.easeOut }, 2, 0.3, 0.5); } Link to comment Share on other sites More sharing options...
Share Posted March 9, 2015 in the first example, it looks like bitmapMode is false WHILE the throwProps tween is happening, as you set that as soon as the mouse_up happens. You want bitmapMode enabled during the throw and disabled after which is what the second example does. Also test example 2 if you drag and don't throw. You may still want to use blitMask.bitmapMode = false in the mouseUpHandler as well Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now