Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
Scroller v02
 
Implemented the blur filter to the scroll. The maximum width and height for a bitmap instance is 2880 pixels, if a filter were to apply to the instance, the filter wont not work.

However we can work around this by using the scrollRect property. If the scrollRect is set to a flash.geom.Rectangle object, the movie clip will be cropped to the size set, this will ensure that the apply area will not be larger than 2880 pixels unless you set your stage size larger to that.


import flash.geom.Rectangle;
import flash.filters.BlurFilter;

// set the scrollbar content width and height
var sWidth:Number=350;
var sHeight:Number=250;

// set allowance at the end of the scroll
var allowance:Number=3;

// declare the scrollRect area using the Rectangle class
var rect:Rectangle=new Rectangle(0,0,sWidth,sHeight);

// declare blur filter using the Filter class
var blur:BlurFilter=new BlurFilter(0,3,5);

// calculate the content height & add allowance to it
var cHeight:Number=Math.ceil(content_mc._height)+allowance;
scroll_mc._height=Math.floor(sHeight/cHeight*sHeight); // set the scrollbar height

// bitmap caching for content_mc
content_mc.cacheAsBitmap=true;

var top:Number=0;
var btm:Number=sHeight-scroll_mc._height;

scroll_mc.onPress=function():Void{

this.startDrag(false,this._x,top,this._x,btm);
this.onMouseMove=function():Void{

updateAfterEvent();

}

// apply the blur filter when scrolling
content_mc.filters=[blur];

}

scroll_mc.onRelease=scroll_mc.onReleaseOutside=function():Void{

this.stopDrag();
this.onMouseMove=undefined;

// remove the blur filter
content_mc.filters=[];

}

scroll_mc.onEnterFrame=function():Void{

// calculate percentage of the scroll content
var percent:Number=(this._y-top)/(btm-top);

// set a new scrollRect rectangle
rect.y=percent*(cHeight-sHeight);
content_mc.scrollRect=rect;

}

scroll_mc.useHandCursor=false;



Download Fla

suggestion

 
 
 
         
  © copyright 2007 THINKLUNATIC.    
Brian Chia Jonathan Ng