A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 36

Thread: Set and remove the srollbar

  1. #1
    Junior Member
    Join Date
    Aug 2006
    Posts
    18

    Set and remove the srollbar

    Hi
    How can I set or remove the scroll bar of the dynamic textfiled with actionscript? I know, it may be quite simple but I couldnt find anything in this board.

    THX

    Niclas

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    You can't with actionscript. Double-click on it and set "has scrollbar" property to no.

  3. #3
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    You can't with actionscript.
    We had the ability to attach with th V6 CreateKScrollBar component.

    //we could create and attach at runtime
    CreateKScrollBar("scroller1",1,txt1);

    //and then apply a style if we wished
    scroller1.setStyle(myStyle);

    This is still an ability....no?
    Last edited by Chris_Seahorn; 08-14-2006 at 10:39 AM.

  4. #4
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by Chris_Seahorn
    This is still an ability....no?
    Yes, that is still possible.

    For the scrollbar the v8 components use I did rewrite the code because when you have a lot of v6 scrollbars on stage at once, they can take up a lot of cpu power. The v6 scrollbar is active and monitors the component you attach it to. If you would move the textfield you attach it to, the scrollbar automatically follows. The v8 one is passive to consume less cpu power.

    Niclas is most likely referring to the built in scrollbar the dynamic textfield has when you create it using the gui.

  5. #5
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Yeah...I just did some tests with bottomScroll and maxscroll and it worked the charm. If the V6 is going to bog on multiple use in the same movie...what is the syntax for attaching a V8 scrollbar Wilbert?

    I sure have a use for this
    Last edited by Chris_Seahorn; 08-14-2006 at 11:06 AM.

  6. #6
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Hmmm...nothing in the newest manual about a v8 scrollbar. Is there an API somewhere?

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Couldn't you use the v8 slider as same?

  8. #8
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I was kind of hoping to alter the forum to attach a scrollbar if needed only but if a V6 will start to degredate speed on multiples (which is bound to happen in a forum) I'll forgo it.

    Thinking about it now...it's not worth the update anyway because as a V8 I couldn't add it to the color selector so if Wilbert decides to answer I'll just store the info for future use. The V6 is normally enough so that's fine for most uses I have. The forum is an odd duck because of the number of different text windows.

    Not sure a Slider will suffice in lieu.
    Last edited by Chris_Seahorn; 08-14-2006 at 11:48 AM.

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    You could attach a slider like this.
    Code:
    o = txt1; // object txt1
    
    m = attachMovie('KC8_Slider','slider',1,{_x:o._x+ o._width,_y:o._y,length:o._height,c:[0xbfbfdf,0xefefff,0xefefff,0x6f6f9f],thin:true});
    m.onMove = function(v){ o.scroll = v; }
    m.setSlider(o.maxscroll,0,0);
    Remember it's passive so if the content of the textfield changes the setSlider function has to be called again to match the new textfield content. That's why it consumes very little cpu load. The v6 checks every enterFrame event for changes.

    It's possible to include it in your color selector because you can just recreate the slider at the same depth as it was before. You just replace the old one with the one with new colors.

    There's also an undocumented (until now) internal function that changes the slider into a scrollbar. It is used by the other v8 components like the listbox and contentpane.
    _setScrollbar(min, max, stp, cur, vis);
    min and max are the minimum and maximum value, stp is the step value (for text this is usually 1 but for images that would be to slow), cur is the current value and vis the amount of lines visible at once (to calculate the size of the bar). So if you want a 'real' scrollbar you could change the setSlider function in the code above to
    m._setScrollbar(0,o.maxscroll,1,0,lines_visible);
    the lines_visible you would have to measure yourself because there is no actionscript function to do so. The v6 handles that problem in another way that doesn't work for this function.

  10. #10
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Hahahaha....very cool

    See....now you went and decided todays activity here Nicely done Wilbert. Glad Zongo asked this question !!

  11. #11
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    By the way, the internal textfield scrollbar also can generate quite a bit of cpu load when you have a lot of them on stage. This happens for example when you use a bit longer wordwrapped html texts because the code of that scroller sets the scroll parameter of the textfield each enterFrame. Apparently the flash player in that case keeps calculating the wrapping all the time. I found this out when I was creating KoolExchange. That's why in the end I changed the scrollbars of the FAQ and Terms of Use of that site to the thin version of the v8 scrollbar.

  12. #12
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    This code is like the code of the week Wilbert. Not only will it speed up the forum since like you say even the internalscrollbars will add cpu load eventually...this little alteration just really makes my day:

    Code:
    o = txt1; // object txt1
    
    if (o.bottomScroll <= o.maxscroll){     
    	   
    	
    m = attachMovie('KC8_Slider','slider',1,{_x:o._x+ o._width,_y:o._y,length:o._height,c:[0xbfbfdf,0xefefff,0xefefff,0x6f6f9f],thin:true});
    m.onMove = function(v){ o.scroll = v; }
    //m.setSlider(o.maxscroll,0,0);
    m._setScrollbar(0,o.maxscroll,1,0,10);
    
    }
    Already tested fine in standalone. I just have to incorporate it into the clip duplication. I think the best and easiest way for me to force the reload if they change the colors will be to only allow the color selector to be initiated in the two frames before the posts clip (threads and cats). This way it's removed from the stage and will read the new values when they step into that posts frame which fires that duplicator. Too sweet!
    Last edited by Chris_Seahorn; 08-14-2006 at 12:32 PM.

  13. #13
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    You know...I've always wondered how you got those scrollbars in the Exchange...especially that "thin" option. OK...I'm off to tear up my forum

    EDIT:
    On a side note...I added a heavily altered Twisted Lister routine to the forum editors that will snake a directory of smilies....read their path, width and height and send the array in for use as a visual smiley selector. It's running now at my site. I've had it handle massive amounts of smilies (right now I think I'm banging 130 pics in but it will read all that exist in the folder it snakes). If I get this scrollbar coding added...I may have to ask you guys to update the myBBS package if that's OK since both of these additions are worth the trouble and the norm for forums.
    Last edited by Chris_Seahorn; 08-14-2006 at 12:39 PM.

  14. #14
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I'm glad you like it.

    It might be possible to connect the _setScrollbar function to the onScroller and onChanged events a dynamic textfield has in case of an input textfield but I'm not sure if that will give the desired result (updating the scrollbar automatically) in that case.

  15. #15
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I think I'll be good on input fields. I prefer they use the mousewheel or up/down arrows in the editors (since we track the caret) but for display of posts...I have a butload of posts that have no need for any scrollbar and that would surely shave off some wasted load.

  16. #16
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    You are right.

    I did make one mistake. I assumed the scroll parameter to be zero based but is seems to begin at 1 so 1 should be the minimum value.

    If you click the text inside a textfield so it has focus and you use the mouseWheel to scroll the text, the scrollbar doesn't move. If you don't like this, you can use the onScroller event. I just tried it.
    Code:
    o = txt1; // object txt1
    
    if (o.bottomScroll <= o.maxscroll){     
    	   
    	
    m = attachMovie('KC8_Slider','slider',1,{_x:o._x+ o._width,_y:o._y,length:o._height,c:[0xbfbfdf,0xefefff,0xefefff,0x6f6f9f],thin:true});
    m.onMove = function(v){ o.scroll = v; }
    m._setScrollbar(1,o.maxscroll,1,0,10);
    o.onScroller = function(){ m._setScrollbar(1,o.maxscroll,1,o.scroll,10); }
    
    }

  17. #17
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I'll save a copy of that. Thanks Wilbert!

    I already added the routine and it works just great. I'll work on the coloring through the day since that's a bit more involved (affects many clips and also the SO) and will let you now how it works out. Already it's awesome to not see all the wasted scrollbars and this day has turned out just perfect

  18. #18
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I'm adding an IP ban and IP Range ban (let's face it...eventually we all will need it unfortunately) also so I'll ask about troubling you guys to once again swap out the ZIP when everything is updated (also all fixes listed in my MOD/Tweaks forum included).

  19. #19
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Hey Zongo!....sorry for hijacking the thread but in the end it helps you as well and I'll let you know what worked best for me.

    The original snippet I pasted above worked great for a single textfield but seemed to stumble on if bottomScroll<maxscroll with dupes (seemed to place them illogically) so I ended up scaling it down to this:

    Code:
     o = this.txt1; // object txt1
    //if it has to scroll so much as a single line...we attach
           if (o.maxscroll > 1){     
    	   
    	
               m = attachMovie('KC8_Slider','slider',1,{_x:o._x+ o._width-15,_y:o._y,length:o._height,c:[0xbfbfdf,0xefefff,0xefefff,0x6f6f9f],thin:true});
                m.onMove = function(v){ o.scroll = v; }
                //m.setSlider(o.maxscroll,0,0);
                m._setScrollbar(1,o.maxscroll,1,0,10);
    
             }
    That works correctly each time.

    I have to tell you....I don't ever see me enabling the internal scrollbar again since this is much smoother and as Wilberts says...less cpu intensive. That and the fact it's a V8 just makes it worth it's weight in gold.

    Good luck man!
    Last edited by Chris_Seahorn; 08-15-2006 at 10:20 AM.

  20. #20
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    One more suggestion Chris.
    If you place a v8 scrollbar over a dynamic textfield like you did in the last code you posted it will cover some text. To avoid this you can place your htmltext between textformat tags. That way you can define a rightmargin for the text so the scrollbar won't cover it.

    <textformat rightmargin="20">my text</textformat>

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