PDA

View Full Version : adding scroll bar to dynamic text field



potamus
August 24th, 2003, 01:39 PM
I am using some code I found in the forum to create my custom text fields and am having trouble getting a scroll bar to show up.

MovieClip.prototype.$createTextField = MovieClip.prototype.createTextField;
MovieClip.prototype.createTextField = function(instanceName, depth, x, y, width, height) {
if (arguments.length<6) {
return undefined;
}

this.$createTextField(instanceName, depth, x, y, width, height);
this[instanceName].defaultTextFormat();
return this[instanceName];
};
ASSetPropFlags(MovieClip.prototype, null, 1, 0);
TextField.prototype.defaultTextFormat = function() {
// add TextField properties here

this.multiline = true;
this.wordWrap = true;
this.scroll = true;
this.border = true;

this.text = "hello world hello world hello world";


var myTextFormat = new TextFormat();
// add TextFormat properties here
myTextFormat.font = "Tahoma";
myTextFormat.color = 0x000000;
myTextFormat.size = 10;
this.setNewTextFormat(myTextFormat);
this.setTextFormat(myTextFormat);
};
ASSetPropFlags(TextField.prototype, null, 1, 0);


createTextField("webMain", 2, 200, 200, 20, 188);


so... if i give the text portion more than the box can show there is still no scroll bar in sight. Any ideas?

Thanks.

kode
August 24th, 2003, 02:19 PM
I don't think I understand the problem... could you attach your FLA? :-\

claudio
August 24th, 2003, 02:28 PM
I dont understand it either... as far as i know, theres no way to dinamically add a scrollbar for your textfield, unless you attach it from the library. :-\

potamus
August 24th, 2003, 02:30 PM
Kax,
Problem is there is no scroll bar as you will see. Here is the .fla, thanks a lot.

Potamus

kode
August 24th, 2003, 02:44 PM
Do you think that setting the scroll property to true, the scrollbar will show up? Well, the answer is no. The scroll property sets the vertical position of the text in the TextField.

This is what I think you want to do, see attachment. ;)

potamus
August 24th, 2003, 03:02 PM
Once again you have answered my question perfectly kax, thanks a lot.

potamus

kode
August 24th, 2003, 03:03 PM
You're welcome, potamus. =)