Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClip > scrollRect (MovieClip.scrollRect property) | |||
public scrollRect : Object
The scrollRect property allows you to quickly scroll movie clip content and have a window viewing larger content. Text fields and complex content scroll much faster, because pixel level copying is used to scroll data instead of regenerating the entire movie clip from vector data. To see the performance gain, use scrollRect in conjunction with a movie clip that has cacheAsBitmap set to true.
The movie clip is cropped and scrolled with a specific width, height, and scrolling offsets. The scrollRect properties are stored in the movie clip's coordinate space and are scaled just like the overall movie clip. The corner bounds of the cropped window on the scrolling movie clip are the origin of the movie clip (0, 0) and the (scrollWidth, scrollHeight) point. These points are not centered around the origin but use the origin at the upper-left corner. A scrolled movie clip always scrolls in whole pixel increments. If the movie clip is rotated 90 degrees and you scroll it left and right (by setting the scrollRect.x property), it scrolls up and down.
If set to a flash.geom.Rectangle object, the movie clip is cropped to a certain size and scrolled.
Availability: ActionScript 1.0; Flash Player 8
The following example sets up a MovieClip hiearchy (by calling the setUpContainer() function) and then sets a new Rectangle as the scrollRect property.
import flash.geom.Rectangle;
var container:MovieClip = setUpContainer();
var window:Rectangle = new Rectangle(0, 0, 100, 40);
container.scrollRect = window;
function setUpContainer():MovieClip {
var mc:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
mc._x = 50;
mc._y = 50;
mc.opaqueBackground = 0xCCCCCC;
var content:MovieClip = mc.createEmptyMovieClip("content", mc.getNextHighestDepth());
var colors:Array = [0xFF0000, 0x0000FF];
var alphas:Array = [100, 100];
var ratios:Array = [0, 0xFF];
var matrix:Object = {a:150, b:0, c:0, d:0, e:150, f:0, g:150, h:150, i:1};
content.beginGradientFill("linear", colors, alphas, ratios, matrix);
content.lineTo(300, 0);
content.lineTo(300, 300);
content.lineTo(0, 300);
content.lineTo(0, 0);
content.endFill();
content._rotation = -90;
mc.onEnterFrame = function() {
this.content._y += 1;
}
return mc;
}
The setUpContainer() function performs the following steps:
containercontent inside of containercontent MovieClipcontainer MovieClipIf your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001968.html