I don't use the this - word because of the nested functions ans possible
complications with the this pointiong to the prototype movieclip
In terms of scope for the nested function, is this the way to go ?
I just paste my proto,
cheers,
Latcho



MovieClip.prototype.addScroll=function (X,Y,H,mask_mc){
   /*
//scrollBar will be added to the _parent of the scrolling window (because that one is masked)
   //mask_mc always has to be on x:0 and y:0 off the content-clip (this)
   //X & Y =position relative to the scrollinng content (this) clip's pos
   //H= Scrollbar's total height
   //mask-mc the mc that masks the content (this)
   //assets to bind are 1 attachable clib with linkage 'scrollBarAssets'
//scrollBarAssets - mc should contain a 'scroll_top' / 'scroll_bot' / 'scroll_track' all with reference pint 0,0
   //also a 'scroll_grip' with reference point *in the middle* !
   */

   var contentScrollSpeed=3.75
var gripSpeed=3 // pixels the grip moves when we press the buttons of the scrollbar
   var scrollBarAssets_linkage="scrollBarAssets"
var content_mc=this
   var __X= this._x+X
   var __Y= this._y+Y
   var __H= H
var scrollBar=this._parent.attachMovie(scrollBarAssets_linkage,this._name+"ScrollBar",this._parent.getNextHighestDepth(),{_x:__X,_y:__Y})

var sb=scrollBar
   var grip=sb.scroll_grip
   var halfGrip=grip._height/2
sb.diffHeight=Math.max((this._height-mask_mc._height),0)
   sb.contentHomePos_y=content_mc._y
   sb.scroll_top._x=0
   sb.scroll_top._y=0
   sb.scroll_track._x=0
   sb.scroll_track._y=sb.scroll_top._height
   sb.scroll_track._height=__H-sb.scroll_top._height-sb.scroll_bot._height
   grip._x=sb.scroll_track._width/2
   sb.scroll_grip._y=sb.scroll_top._height+halfGrip
   sb.scroll_bot._x=sb.scroll_top._x
   sb.scroll_bot._y=__H-sb.scroll_bot._height
sb.bounds=new Object({left:grip._x,top:grip._y,right:grip._x,bottom:sb.scroll_bot._y-halfGrip})
   sb.gripHomePos_y=grip._y
sb.gripMaxMove_px=__H-sb.scroll_top._height-sb.scroll_bot._height-grip._height grip.onPress=function(){sb.dragStart()}
   grip.onReleaseOutside=sb.scroll_grip.onRelease=function(){sb.dragStop()}
sb.setContentYPos=function(px){
       gripToPercent=(1-((sb.diffHeight-px)/sb.diffHeight))
       gripToY=sb.gripHomePos_y+((sb.gripMaxMove_px)*gripToPercent)
       grip._y=Math.min(sb.gripHomePos_y+sb.gripMaxMove_px,gripToY)
       sb.dragStart()
       sb.dragStop()
   }
sb.dragStart=function(){ startDrag(grip, true, sb.bounds.left,sb.bounds.top,sb.bounds.right,sb.bounds.bottom);
       sb.isDragging=true
sb.onEnterFrame=function(){ sb.gripPercent=((grip._y-sb.gripHomePos_y)/(sb.gripMaxMove_px))*100 sb.contentNewPos_y=Math.round(sb.contentHomePos_y-(sb.diffHeight*sb.gripPercent)/100)
           sb.diff=content_mc._y-sb.contentNewPos_y
           sb.step=sb.diff/contentScrollSpeed
           content_mc._y-=sb.step
if(sb.contentNewPos_y==Math.round(content_mc._y)&&sb.isDragging==false){
               delete this.onEnterFrame
               content_mc._y=Math.round(content_mc._y)
           }
       }
   }
sb.dragStop=function(){
       this.scroll_grip.stopDrag();
       sb.isDragging=false
   }
   sb.scroll_bot.onPress=function(){
       delete sb.scroll_top.onEnterFrame
sb.scroll_bot.onEnterFrame=function(){ sb.gripNewPos=grip._y+gripSpeed if(sb.gripNewPos<=sb.gripHomePos_y+sb.gripMaxMove_px){
               grip._y=Math.round(sb.gripNewPos)
               sb.dragStart()
               sb.dragStop()
           }else{
               grip._y=sb.gripHomePos_y+sb.gripMaxMove_px
               delete sb.scroll_bot.onEnterFrame
           }
           sb.dragStart()
           sb.dragStop()
       }
   }
sb.scroll_bot.onRelease=sb.scroll_bot.onReleaseOutside=function(){
       delete this.onEnterFrame
   }
sb.scroll_top.onPress=function(){
       delete sb.scroll_bot.onEnterFrame
       sb.scroll_top.onEnterFrame=function(){

           newPos=grip._y-gripSpeed

           if(newPos>sb.gripHomePos_y){
               grip._y=Math.round(newPos)
               sb.dragStart()
               sb.dragStop()
           }else{
               grip._y=sb.gripHomePos_y
               delete sb.scroll_top.onEnterFrame
           }
           sb.dragStart()
           sb.dragStop()
       }
   }
sb.scroll_top.onRelease=sb.scroll_top.onReleaseOutside=function(){
       delete sb.scroll_top.onEnterFrame
   }
return scrollBar;
}


ASSetPropFlags(MovieClip.prototype, "addScroll", 7)

--
Hartelijke Groet,
                Stijn De Ryck

Further contact details in attachment 'mail.vcf',
or if visible,click on the icon below.


« I think the person who takes a job in order to live -that is to say, for the money-
 has turned himself into a slave. »
 § Joseph Campbell

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to