Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Using BlitMask for a mc with moving elements in it.

Recommended Posts



I have a problem and im not sure how to solve it (with the BlitMask technic).

Currently Im trying to create a mask (which I can more around the stage) that shows only a fragment (lets say 50x50) of the main movie clip.The main MC (lets name it Rainbow) has elements that are moving in it (like i black ball that goes from 1 corner to the other corner and then repeats that infinitely ).


So what it is supposed to be happening is this: There is the main MC which stays at stage.x and stage.y and then there is my little new element (lets name it frac ( from fraction )), which i can move freely anywhere on the stage. This element (frac) shows that portion of the main MC every single frame, so when  the ball in the main MC moves through that area ( the area that frac specified to watch ), frac shows that movement in itself. 


I currently have made it work with using flash.geom.Matrix; and bitmapData;.

it is something like this:

        public class Main extends MovieClip
                private var bmd:BitmapData;
		private var countainer:Sprite = new Sprite();
		private var bm:Bitmap = new Bitmap();

		private var myRainbow:Rainbow = new Rainbow();//the moving MC
		public function Main()
                        this.addChild( myRainbow )
                        myRainbow.x = stage.x;
                        myRainbow.y = stage.y;

			bmd = new BitmapData( 50, 50 );
			bm.x = 0;
			bm.y = 0
			countainer.addChild( bm );
			addChild( countainer )
			countainer.x = 100
			countainer.y = 100
			addEventListener(Event.ENTER_FRAME, onFrame);
			addEventListener(MouseEvent.MOUSE_UP, drop);

		private function onFrame( event:Event )
			bmd.draw( myRainbow, new Matrix( 1, 0, 0, 1, 0, 0 ), null, null, new Rectangle( 0, 0, 50, 50 ) );
			// the last two numbers of the Matrix show the starting point of where the mask will show
                        bm.bitmapData = bmd;





But with this solution the performance is extremely poor.

So I searched the net in a more performance friendly solution and found the BlitMask technic.

So is there a way of doing this with the BlitMask???  


to be more clear I`ve uploaded  the fla- file that I`ve made with the code above so you can see what Im doing

the link is : https://drive.google.com/file/d/0B5u6hrR2w7UEYmFHbHdlWnlWNjA/edit?usp=sharing


Link to comment
Share on other sites



BlitMask gets its performance boost by taking a bitmap capture of a large display object and only rendering a small portion of those pixels (the masked area).


If the content within the masked area is constantly changing (like balls boumcing around) you will have to repeatedly recapture the pixels for the bitmap and thus lose the performance benefits.


In other words BlitMask is optimized for super fast scrolling of static content (as shown in the demo).


It doesn't sound to me like it is designed to handle your particular use case.

Link to comment
Share on other sites

I see.I was hoping that it somehow is suited for my problem : (.

But can i ask for some help. Like a good suggestion to point me thru, if you had ever came across something like that or if you have a clue.

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.