How do I get the text that has been created to load into the Scroll Pane component. I had someone already help me with the creation of the Scroll Pane, but how do I get that text to load into that Scroll Pane. thanks
Try this. There may be a simpler way but I don't really use the scrollpane so I don't what it is. Create a movie clip that is completely empty and set it to export for action script with some linkage ID (say, for example, 'mytextbackground'). This is the part I don't know a way around. The scrollpane seems to need something loaded into it so that it can create its internal structure. my_format = new TextFormat(); my_format.font = 'Arial';//or whatever my_format.size = 10;//or whatever size you want //and whatever else you want to set up in the format pane_x = 50;//or wherever you want it pane_y = 100;//or wherever you want it this.attachMovie('ScrollPane','mypane',1,{_x:pane_x,_y:pane_y); mypane.contentPath = 'mytextbackground';//just load something into the pane - there may be a workaround mypane.setStyle('borderStyle','none');//in case you don't want the border if scroll is not required mypane.setSize(100,60);//or whatever size you want text_i_want_in_pane = 'now is the time for all good men to come to the aid of their country'; text_metrics = my_format.getTextExtent(text_i_want_in_pane,90);//I am guessing at this but needs to allow for scrollbar //I just made it ten less than the width of the pane but it is just a guess - I don't know how wide the scroll bar really is x = 10;//some number to pad the text on the bottom (look up getTextExtent in the help file) mypane.spContentHolder.createTextField('mytext',1,0,0,90,text_metrics.textFieldH eight +x);//wraps at 90 pixels mypane.spContentHolder.mytext.wordWrap = true; mypane.spContentHolder.mytext.setNewTextFormat(my_format); mypane.spContentHolder.mytext = text_i_want_in_pane; mypane.redraw(true); All this is written for MX 2004 so, if it is for MX, it will have to be redone slightly. I can't test that script but it looks pretty close.
spContentHolder is the instance name of the movie clip displayed in the MX 2004 scrollpane. Doesn't matter what you load into it or attach to it - its instance name is spContentHolder. This is the clip that is masked and scrolled by the scrollpane.
OK, Everything works, except for one thing. The example you gave does not take into account that I am loading text from an external .txt file. In fact I have multiple files. This is my problems. The size of the text field will be different for each file I load into it. How do I get the height of the text files so the text field changes dynamically? Thanks
After the file is loaded, you should be able to use the getTextExtend to calculate the textfield height and use that when the text field is created. That script I showed does that. If it is not working, are you sure the text has actually been loaded before you create the text field? You need to use the getTextExtent for each text field and calculate a height for each one against the text format object you create.
Don't see what you're looking for? Try a search.
|