SexyElf
07-03-2007, 04:33 PM
Edit - I fixed the problem by using alternative code. If anyone is interested, I have placed the code further below.
Hey all,
I am wondering if anyone has had any luck with creating a dynamic textfield scrollpane all in AS? I'm using F8.
Basically, I am loading htmltext from a textfile into a textfield created in AS. The textfield is recreated each time a new piece of information is gathered from the textfile ("Tips"). It gathers the _height of the previous textfield and places the next textfield underneith it with a 10px spacing.
The problem is not the textfield creation/data entry, but the scrollpane.
I've tried to both add a scrollpane manually and through AS manipulation, and both times the 'textfield' is not added to the scrollpane. When I ask for getScrollContent, it always shows undefined. I even added a setinterval for several seconds and it still returns undefined - basically, it is not a time problem.
This is the second scrollpane file I've done. The first added dynamic questions to a scrollpane, but the questions had textfields that were manually added and had fixed widths/heights. This is different because I need textfields that 'stretch'.
Here is my code:
attachMovie("ScrollPane", "tipField", Depth++);
tipField.setSize(550,130);
tipField.move(10,10);
tipField.hScrollPolicy = "off";
tipField.vScrollPolicy = "auto";
createEmptyMovieClip("display_mc",Depth++);
// Text format
myy = 20;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
// Data population
for(i=0; i<info.tip_count; i++){
mytextfield = ("mytextfield" + i);
display_mc.createTextField(mytextfield,Depth++,20, myy,530,1);
display_mc[mytextfield].setNewTextFormat(myTextFormat);
display_mc[mytextfield].setTextFormat(myTextFormat);
display_mc[mytextfield].autoSize = true;
display_mc[mytextfield].multiline = true;
display_mc[mytextfield].wordWrap = true;
display_mc[mytextfield].html = true;
display_mc[mytextfield].htmlText = eval("info.tip_"+(i+1));
myy+=display_mc[mytextfield]._height + 10;
display_mc[mytextfield].invalidate();
}
// ADD THE MOVIE CLIP TO THE SCROLLPANE INSTANCE
scroll1.setScrollContent(display_mc); // <-- adds to pre-existing scrollpane added manually, doesn't work
tipField.setScrollContent(display_mc); // <-- adds to AS created scrollpane, doesn't work
Thanks for any input/help.
SexyElf
--------- edited code -----------
Fully dynamic, all in AS
Depth = 2;
// Load input file
var info:LoadVars = new LoadVars();
info.load("test.txt");
attachMovie("ScrollPane", "tipField", Depth++);
tipField.setSize(550,130);
tipField.move(10,10);
tipField.hScrollPolicy = "off";
tipField.vScrollPolicy = "auto";
tipField.contentPath = "InfoBoxQuestions"; // <-- precreated empty MC
tipField.content.createTextField(mytextfield,Depth ++,20,myy,530,1);
myy = 20;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
for(i=0; i<info.tip_count; i++){
mytextfield = ("mytextfield" + i);
tipField.content.createTextField(mytextfield,Depth ++,20,myy,530,1);
tipField.content[mytextfield].setNewTextFormat(myTextFormat);
tipField.content[mytextfield].setTextFormat(myTextFormat);
tipField.content[mytextfield].autoSize = true;
tipField.content[mytextfield].multiline = true;
tipField.content[mytextfield].wordWrap = true;
tipField.content[mytextfield].html = true;
tipField.content[mytextfield].htmlText = eval("info.tip_"+(i+1));
myy+=tipField.content[mytextfield]._height + 10;
tipField.content[mytextfield].invalidate();
}
Hey all,
I am wondering if anyone has had any luck with creating a dynamic textfield scrollpane all in AS? I'm using F8.
Basically, I am loading htmltext from a textfile into a textfield created in AS. The textfield is recreated each time a new piece of information is gathered from the textfile ("Tips"). It gathers the _height of the previous textfield and places the next textfield underneith it with a 10px spacing.
The problem is not the textfield creation/data entry, but the scrollpane.
I've tried to both add a scrollpane manually and through AS manipulation, and both times the 'textfield' is not added to the scrollpane. When I ask for getScrollContent, it always shows undefined. I even added a setinterval for several seconds and it still returns undefined - basically, it is not a time problem.
This is the second scrollpane file I've done. The first added dynamic questions to a scrollpane, but the questions had textfields that were manually added and had fixed widths/heights. This is different because I need textfields that 'stretch'.
Here is my code:
attachMovie("ScrollPane", "tipField", Depth++);
tipField.setSize(550,130);
tipField.move(10,10);
tipField.hScrollPolicy = "off";
tipField.vScrollPolicy = "auto";
createEmptyMovieClip("display_mc",Depth++);
// Text format
myy = 20;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
// Data population
for(i=0; i<info.tip_count; i++){
mytextfield = ("mytextfield" + i);
display_mc.createTextField(mytextfield,Depth++,20, myy,530,1);
display_mc[mytextfield].setNewTextFormat(myTextFormat);
display_mc[mytextfield].setTextFormat(myTextFormat);
display_mc[mytextfield].autoSize = true;
display_mc[mytextfield].multiline = true;
display_mc[mytextfield].wordWrap = true;
display_mc[mytextfield].html = true;
display_mc[mytextfield].htmlText = eval("info.tip_"+(i+1));
myy+=display_mc[mytextfield]._height + 10;
display_mc[mytextfield].invalidate();
}
// ADD THE MOVIE CLIP TO THE SCROLLPANE INSTANCE
scroll1.setScrollContent(display_mc); // <-- adds to pre-existing scrollpane added manually, doesn't work
tipField.setScrollContent(display_mc); // <-- adds to AS created scrollpane, doesn't work
Thanks for any input/help.
SexyElf
--------- edited code -----------
Fully dynamic, all in AS
Depth = 2;
// Load input file
var info:LoadVars = new LoadVars();
info.load("test.txt");
attachMovie("ScrollPane", "tipField", Depth++);
tipField.setSize(550,130);
tipField.move(10,10);
tipField.hScrollPolicy = "off";
tipField.vScrollPolicy = "auto";
tipField.contentPath = "InfoBoxQuestions"; // <-- precreated empty MC
tipField.content.createTextField(mytextfield,Depth ++,20,myy,530,1);
myy = 20;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
for(i=0; i<info.tip_count; i++){
mytextfield = ("mytextfield" + i);
tipField.content.createTextField(mytextfield,Depth ++,20,myy,530,1);
tipField.content[mytextfield].setNewTextFormat(myTextFormat);
tipField.content[mytextfield].setTextFormat(myTextFormat);
tipField.content[mytextfield].autoSize = true;
tipField.content[mytextfield].multiline = true;
tipField.content[mytextfield].wordWrap = true;
tipField.content[mytextfield].html = true;
tipField.content[mytextfield].htmlText = eval("info.tip_"+(i+1));
myy+=tipField.content[mytextfield]._height + 10;
tipField.content[mytextfield].invalidate();
}