Jump to content
GreenSock

Applauz

BlitMask .. What am I doing wrong ?

Recommended Posts

I'm trying to tween a very large movieclip (allChapters_mc) which has a height of 706 and a width of about 26,000 pixels.

 

The allChapters_mc is set up by adding a bunch of smaller movieclips that are 1024 x 706 along a horizontal line. The reason I had to do it this way is that putting them directly on the stage isn't possible as there is a limitation for how high the X property will go when directly in the Flash IDE.

 

 

 

Here is the code I am trying to use to tween the clip.

 


function setAllChapters():void{


houseBTN.alpha = 1;
houseBTN.mouseEnabled = true;


// This is where I add the movie clip that holds all the smaller movie clips
allChapters_mc = new AllChapters_mc();
this.addChild(allChapters_mc);

//I'm adding it off stage at 1024 pixels and going to animate it in place
allChapters_mc.x = 1024;
allChapters_mc.y = 42;


// Place & Set Home Button since it may have been removed
loadedSection = "AllChapters";
mainHomeBTN.visible = true;

// Make sure this movie clip is at the top depth
setChildIndex(allChapters_mc, allChapters_mc.parent.numChildren - 1);

// Create Blitmask
blitMask = new BlitMask(allChapters_mc, 0, 42, 1024, 706, true);

// Tween the chapters, update blitmask
TweenMax.to(allChapters_mc, 1, {x:0, y:42,onUpdate:blitMask.update, visible:true, ease:Expo.easeOut,startAt:{x:1024, y:42, visible:true}, onComplete:setChaptersToolbar});


topNavBar.topTitle.htmlText = "Introduction";
setChapterTopNavArrow();

}

 

 

 

This is what I use initially ... it works .. but its sluggish and slow.

 

 

Inside of the allChapters_mc I have those smaller movie clips .. Inside of those there is a Next and Back button that either move the allChapters movieclip x property by 1024 or -1024.

 

This is what that code looks like

 

 

TweenMax.to(MovieClip(parent.parent).allChapters_mc, 0.7, {x:MovieClip(parent.parent).allChapters_mc.x - 1024,ease:Expo.easeOut,onUpdate:MovieClip(parent.parent).blitMask.update, onStart:MovieClip(parent).disableEverything, onComplete:MovieClip(parent).enableEverything});

 

 

Am I doing this right ? Why is it so choppy ? Is there a better way I can use blitmasking on such a large movie clip ?

Link to comment
Share on other sites

Try removing onUpdate:MovieClip(parent.parent).blitMask.update since you are tweening position.

Link to comment
Share on other sites

But if I remove the update of blitmask during the tween .. won't that void using blitmask at all ?

Link to comment
Share on other sites

But if I remove the update of blitmask during the tween .. won't that void using blitmask at all ?

Well, kinda. The point is that if you move the target, you need to make sure BlitMask updates so that it synchronizes the position. Calling update() accomplishes that. Wolfzor, I bet you were concerned about calling update(null, true) which would force an entire recapture of the original target's pixels which would be a waste of time and processing. But by default, the 2nd parameter of update() is false which means it won't force a recapture of all the pixels.

 

So you need to either use an onUdpate to keep calling update() OR set autoUpdate to true which will make it always watch to see if/when the target moves and call update() automatically.

 

It looks like your code is setting the "visible" property of your target to true during the entire tween which completely defeats the purpose of the BlitMask. You're making Flash have to think about and render ALL of those pixels on every frame. BlitMask toggles the target's visible property to false while its bitmapMode is true, ensuring that Flash doesn't need to worry about all those extra pixels outside the boundaries of the BlitMask. I suspect you'll see a nice performance increase if you stop messing with the target's "visible" property :)

Link to comment
Share on other sites

I removed the visible:true from the tween .. those were there for some other testing. Removing them hasn't made a difference.

 

I have smoothing set to true.

 

Is there a reason I see better performance when I set bitmapmode = false ?

Link to comment
Share on other sites

There definitely shouldn't be BETTER performance with bitmapMode = false. There must be something else going on in your code. It almost sounds like you're forcing a full recapture of the BlitMask on every frame. It's very difficult to troubleshoot without having your FLA file to publish on our end. Can you post that?

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