View Full Version : MovieClip.scrollRect Best Practices

10-26-2006, 09:18 PM
I love MovieClip.scrollRect. It's awesome. However, I've seen two differing opinions on how to use it properly, both claiming to be better. I've used it both ways, and personally can't see a difference, so I'm hoping someone can offer a compelling argument for one method over the other.

Let's say that I have a MovieClip that I'm going to use as a basic scrollpane. For simplicity, _root.scrollPaneMC.content is where everything is attached.

Method 1: Create a flash.geom.Rectangle, and apply that using _root.scrollPaneMC.scrollRect = myRectangle. Then, I adjust the _x & _y of scrollPaneMC.content

Method 2: Same setup as above, however, I adjust the .x & .y of myRectangle, and reapply the scrollRect of the MovieClip each time I adjust the rectangle.

Both give the same appearance to the end user, but I haven't seen a performance difference with either method.

So, what are your opinions?

10-29-2006, 10:22 PM
I prefer method 2.

Method 1 is easier to tween with AS, you don't need an onMotionChanged handler but...
Method 2 gives more useful values: y+ is down, not up; (x,y) gives the co-ords of the visible area not matter where the content reg point is.

02-24-2009, 11:45 AM
...after quite a long time.

Method 2 is also more efficient when used together with cacheAsBitmap.