A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [Flash8] Scrollrect

  1. #1
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666

    [Flash8] Scrollrect

    There is something called scrollRect which looks like mask to me, but probably is different.

    To test this code set up some mc (with large bitmap in it) with linkage name "container" into library:

    Code:
    import flash.geom.Rectangle;
    var container:MovieClip = setUpContainer ();
    var window:Rectangle = new Rectangle (0, 0, 100, 200);
    container.scrollRect = window;
    function setUpContainer ():MovieClip {
    	var mc:MovieClip = this.createEmptyMovieClip ("container", this.getNextHighestDepth ());
    	mc.cacheAsBitmap = true;
    	mc._x = 50;
    	mc._y = 50;
    	var content:MovieClip = mc.attachMovie ("content", "content", mc.getNextHighestDepth ());
    	content.cacheAsBitmap = true;
    	content.startDrag (true);
    	return mc;
    }

    From the happy LiveDocs, on Macromedia's site:

    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.
    Good find (by Willoughby) !



    /*Message originally posted by tonypa on 09-14-2005 at 06:05 PM,moved to its own thread by tomsamson */
    Last edited by tomsamson; 09-15-2005 at 04:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center