Jump to content
Search Community

MC duplicates after 1 throwprops scrolling

ladyb314 test
Moderator Tag

Recommended Posts

I have a vertically scrolling mc that i am controlling using the throwprops plugin with a blitmask applied to it.  I also have a button within that movieclip that triggers a popup when tapped.

 

After i scroll the movieclip one time i now show a duplicate of the movieclip behind it.  so when i scroll up or down to the ends, when the movieclip goes past the end point, I see a duplicate of the movieclip behind it. This only happens after I have scrolled the full thing once, so i'm thinking it has something to do with the blitMask.  Any help would be greatly appreciated.

 

I'm using the demo code just to test it out, so i can then edit it.  Here is my updated code:

var bounds:Rectangle = new Rectangle(0, 0, 480, 800);

var blitMask:BlitMask = new BlitMask(mc, bounds.x, bounds.y, bounds.width, bounds.height, false);
blitMask.bitmapMode=false;


var t1:uint, t2:uint, y1:Number, y2:Number, x1:Number, x2:Number, xOverlap:Number, xOffset:Number, yOverlap:Number, yOffset:Number;
var isMoving:Boolean=false;
var isCatched:Boolean=false;
blitMask.stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(event:MouseEvent):void {
TweenLite.killTweensOf(mc);
blitMask.disableBitmapMode();
if(isMoving==true)
{
isCatched=true;
isMoving=false;
}

x1 = x2 = mc.x;
xOffset = this.mouseX - mc.x;
xOverlap = Math.max(0, mc.width - bounds.width);
y1 = y2 = mc.y;
yOffset = this.mouseY - mc.y;
yOverlap = Math.max(0, mc.height - bounds.height);
t1 = t2 = getTimer();
mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);



}

function mouseMoveHandler(event:MouseEvent):void {
isMoving=true;
if(blitMask.bitmapMode==false)
{
blitMask.enableBitmapMode();
}

var y:Number = this.mouseY - yOffset;
//if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior)
if (y > bounds.top) {
mc.y = (y + bounds.top) * 0.5;
} else if (y < bounds.top - yOverlap) {
mc.y = (y + bounds.top - yOverlap) * 0.5;
} else {
mc.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) {
//x2 = x1;
//x1 = mc.x;
y2 = y1;
t2 = t1;
y1 = mc.y;
t1 = t;
}
event.updateAfterEvent();
}

function mouseUpHandler(event:MouseEvent):void
{
mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (mc.y - y2) / time;

ThrowPropsPlugin.to(mc, {throwProps:{ y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:50}}, onUpdate:blitMask.update, onStart:blitMask.enableBitmapMode, onComplete:throwComplete, ease:Strong.easeOut}, 5, 0.3, 1); 

}

function throwComplete ()
{
isMoving=false;
isCatched=false;
blitMask.disableBitmapMode();
}




mc.shortcuts_btn.addEventListener(MouseEvent.CLICK,FNA);
mc.radar_btn.addEventListener(MouseEvent.CLICK,FNA);
function FNA (e:MouseEvent)
{
if(isMoving==false && isCatched==false)
{
	fna.visible = true;
}
else{
	//donothing;
}

}
Link to comment
Share on other sites

Hard to visualize what is happening but it sounds like perhaps when you re-enable bitmapMode you should also update  the blitMask using

blitMask.update(null, true);

update recaptures all the most recent bitmap data of the target.

 

If you still need help, please provide your fla, with only the code and assets necessary to replicate the problem. Please remember to not upload the greensock files.

 

Thanks.

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