Flash® 8 - MovieClip.scrollRect Example
MovieClips in Flash® Player 8 support a new property called scrollRect. When set to an instance of a flash.geom.Rectangle class, it sizes the clip for scrolling and masks content outside the scrollRect boundaries. The example requires Flash® 8 Beta Player.
One of Turkey's Amazing Beaches. Drag the image around.
First off, scrollRect might be one of my favorite features in Flash® 8. It solves so many issues with using MovieClips as containers. The scrollRect property allows you to set the visible area of a MovieClip by assigning a flash.geom.Rectangle instance. The Rectangle is set as follows:
mc.scrollRect = new flash.geom.Rectangle(0,0,100,100)
The arguments are xOffset, yOffset, Width, and Height. Starting at the 0,0 orgin of the MovieClip, the above code will create a rectangle from 0,0 to 100,100. If I did this:
mc.scrollRect = new flash.geom.Rectangle(20,30,100,100)
the rectangle created would cover from 20,30 to 120,130 of the target MovieClip. Remember the last two arguments are not coordinates but width and height. This is a very easy mistake to make and the new Rectangle Class is used with a lot of the new features. Put this in your back pocket, you will need it later on, trust me.
In the example the dragging of the clip is an illusion. I am actually setting the scrollRect value as you drag the mouse around. In this case I have not changed the _x, _y of the clip but rather modified the scrollRect to look like I did. This is extremely useful for container creation and makes masking or scrolling content much simpler. As a technique, it is orthogonal and allows you to manipulate the view without requiring nested MovieClips or many of the old school techniques. It is a revolution in how you can manipulate content visually.
Remember scrollRect, it is your new best friend when manipulating a container's view. This example will ship with full source and documentation within Flash® by Example.
More to come,
Ted ;)
3 Comments:
Hi Ted,
Where's your RSS feed? I want to keep an eye on your site without having to come back on a daily basis ;)
Your IFBIN project sounds truly exciting.
Cheers,
Mads (www.madsb.com)
You can find the feed right here:
IFBIN RSS Feed URL
I added a link to the sidebar also. Thanks for pointing out that the RSS was hiding, all fixed!
We have lots of examples to cover and we are just getting warmed up.
Cheers,
Ted ;)
This looks interesting. I tried to find the file, but it does not seem to be on the list.
Post a Comment
<< Home