creatTextField

Hi Guys,
I am creating a textfield with AS and calling on an external HTML field to populate it. While this works fine I cannot get an external style sheet to format it. I am unsure of the problem.

If I place a dynamic textfield on the stage and target the instance the style sheet has no problem formatting the text. But created with AS I can’t get the style sheet to work. Here is my code.

//create field
this.createTextField(“content_txt”, 10, 0, 0, 390, 0);

//create and load styles
var ss:TextField.StyleSheet = new TextField.StyleSheet();
ss.load(“sample.css”);
content_txt.styleSheet = ss;

//text field attributes
content_txt.multiline= true;
content_txt.wordWrap = true;
content_txt.html = true;
content_txt.autoSize = true;

//load in exterrnal information
story = new XML();
story.ignoreWhite = true;
story.load(“home2.html”);
story.onLoad = function () {
content_txt.htmlText = story;
}

Any clues?
Cheers

Ok My bad. I did some fiddling with the css file and all is well.

Although I do have a secondary problem.

My textField is being created inside an MC which resides in the library. A scrollPane on the stage then calls on the MC (via linkage).

At first load the scrollpane loads the MC (with the textField) but does not apply the scrollbar (the textfield text is twice as high as the scrollpane). If I click around a few buttons and then come back to this scrollpane the scrollbar appears and the rest of the text can be viewed.

My thoughts are that the scrollpane is initially loading the MC before it has dynamically created the textField and loaded in the external information. Thus not applying the scrollbar because the MC is blank. Then the information loads in and half of it is not viewable as the scrollpane has no scrollbar.

Is there a way around this? Getting the information into the MC and then applying it to a scrollpane??

Cheers if anybody has any answers.

Call the [font=courier new]UIObject.redraw()[/font] method within the [font=courier new]onLoad[/font] handler. :slight_smile:

story.onLoad = function() {
content_txt.htmlText = this;
_parent.redraw(true);
};

Brilliant!!

Thankyou so much!

You’re welcome. :wink: