Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : scroll dynamic text box?



miphi767
3/10/2004 10:31:40 PM
Hi Everyone. I am working on a small app that will read from a text file. The
space where this will go is somewhat confined, so I want to apply vertical
scrolling to it.

My text file contains two variables: &headline and &special.
I have two fields on the timeline linked to these variables via a
loadVariablesNum("textfile.txt", 0 )action.

Now when I attach a scroll bar to the &special dynamic field, it will not
scroll, but if I duplcate the field and hard code the text, the dynamic field
will scroll (if both fields share the same Instance Name)

I also tried creating a movieclip that contains the fields and use a scroll
pane, but the text will not come up in the text fields within the linked MC in
the scrollPane

would someone have an idea on how to accomplish this?

Thanks,
MP
Jack.
3/10/2004 10:54:30 PM
create a dynamic textfield and attach your scrollbar to it
when all data is loaded using a LoadVars.onLoad event

this example loads two variable/value pairs from a text file
&txt1=blah blah&
&txt2=more blah&
and switches between them on a button action,
load and delete a scrollbar to stage (loads Library)
and use its Linkage ID to attach to the textfield,

hope some of this is of help to you :)

lv = new LoadVars();
lv.onLoad = function(){
txt1 = lv.txt1; txt2 = lv.txt2;
text1();
};
lv.load("test.txt");

function text1(){
this.createTextField("tf1", 10, 50, 50, 210, 80);
tf1.multiline = tf1.wordWrap = tf1.border = true;
tf1.borderColor = 0x00ff00; tf1.textColor = 0xff0000;
tf1.text = txt1;
this.attachMovie("FScrollBarSymbol", "scr", 11);
scr.setSize(80);
scr._x = tf1._x + tf1._width;
scr._y = tf1._y;
scr.setScrollTarget(tf1);
};

function text2(){
scr.setSize(160);
tf1._height = 160;
tf1.borderColor = 0xff0000; tf1.textColor = 0x0000ff;
tf1.text = txt2;
};

btn1.onPress = function(){
pressed = !pressed;
pressed ? text2() : text1();
};

stop();
AddThis Social Bookmark Button