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
Printable View
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
You can't with actionscript. Double-click on it and set "has scrollbar" property to no.
We had the ability to attach with th V6 CreateKScrollBar component.Quote:
You can't with actionscript.
//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?
Yes, that is still possible.Quote:
Originally Posted by Chris_Seahorn
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.
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 :)
Hmmm...nothing in the newest manual about a v8 scrollbar. Is there an API somewhere?
Couldn't you use the v8 slider as same?
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.
You could attach a slider like this.
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.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);
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.
Hahahaha....very cool :thumbsup: :thumbsup:
See....now you went and decided todays activity here ;) Nicely done Wilbert. Glad Zongo asked this question !!
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.
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:
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!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);
}
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.
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.
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.
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); }
}
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 :thumbsup: :thumbsup:
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).
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:
That works correctly each time.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);
}
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!
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>
Hey Wilbert!
These things are awesome. I'm starting a new "Code of the week" forum and this is the number one post. You could get rich with your component skills man......unreal.
Quote:
Originally Posted by w.brants
That was me...I was subtracting -15 to test until I knew it was a go. I've since squared it away...good eye man!
Hi Chris
Wher do I have to insert the code, that adds the scrollbar?
I know that Im a noob :-D
Niclas
Hang tight Zongo..I'll make a movie that has two dynamic textboxes. One with text that exceeeds the visible space and one that doesn't so you can see how the code is placed and how it works depending on the text length. BRB.
That woud be so cool!
Nice board, nice people :-)
Niclas
http://actionscript.hobby-site.com/e...ongoZongo.html
This uses that second example Wilbert posted that lets you also click inside the text and scroll with a mousewheel (as well as with the bar itself). Save this man...to me...it's just one of the best snippets I've seen since buying KM and exactly what you wanted in your original post. Wilbert is our resident script guru and this is just a perfect example of why ;)
I better explain how maxscroll is used in that.
if(o.maxscroll >1){
If so much as one line of the text inside the field exceeds the visible space (number of lines) in the field...it will attach the bar. If it is even one line less than the visible space...it will not. They are fast too just like he said. I played with them all night ;)
ok, that works fine. But there is one Problem left :-)
How can i remove the scrollbar? I need this functionality, becaus the text inside the textfield is dynamic. So if a short text is loaded into the textfield, the scrollbar remains.
thx,
Niclas
Has to be your coding. My forum is using code like that now ( every bit of text in my fields is delivered via MySQL/PHP) and is acting perfect with that exact thing. Some posts are long...some short. It attaches as it should. Remember...it needs to be initiated after the text is loaded. If you reload or the text changes at runtime (which my forum does if people edit their posts) you have to make sure to reload the routine. Post your fun file if need be :)
For example...my posts are brought in with a loadvars. On success the text is sent to the field and then my clip is told to advance one frame where I initiate that routine. It then checks the textsize and attaches if need be. If any user edits a post...on submit the whole sequence is reloaded as above so it's always based on the current text value.
If you want to hide it, you can use the _visible property.
Like Chris suggested you can use maxscroll. In case the textfield is named 'txt1' and the scrollbar 'slider', You could use something like thisIn case maxscroll is bigger than one the expression will be true so the scrollbar will be visible. Otherwise visibility will be set to false.Code:slider._visible = txt1.maxscroll > 1;
ok, I modified the zongozongo.fun. Its still a quite simple example. But if you set the text und then remove it, the bar stays. I execute the code everytime the button a button is pushed.
www.maduria.de/diverses/ZongoZongo.fun
Niclas
Oh, w.brants was too fast. I didnt read that post. Now everything is fine :-)
Thank you guys
Niclas
We're thinking of kidnapping him...tying him down and tickling him with a feather to see what other secrets he holds ;)
Hey Chris
Do you know, how I can remove the bevel of the scrollbar? Are there more parameter to set the looking? Coldnt find anything in the www.
And one last important thing: How can i scroll the text to the beginnen with actionscript?
THX,
Niclas
You can set a text to the beginning with the scroll parameter.The bevel can be controlled with the s array. You can place it after the c array you use to set the colors.Code:myTextField.scroll = 1;
,c:[0xbfbfdf,0xefefff,0xefefff,0x6f6f9f],s:[0,0,0]
The first value is the amount of bevel, the second the angle, and the third the alpha of the slider shadow (between 0 and 1)