sajan Posted March 14, 2008 Share Posted March 14, 2008 HiI created multiple textfields dynamically using action script and assigned scrollbar to each of them,that too dynamically.But the problem is that scrollbar is visible to only the last text field.Other textfields can be scrolled through mouse scroll button.How can i make visible all scroll bars?my code is given below var comment='testing';for(var i=0;i<3;i++){comment=comment+i;var dynamicText="dynamicText"+i;var dScrollbar="dScrollbar"+1;this.createTextField(dynamicText, i, x,y, 200, 50);y=y+40;this[dynamicText].wordWrap = true;textFormat = new TextFormat();textFormat = this[dynamicText].getTextFormat();textFormat.color = 0xCC3366;textFormat.size = 24;this[dynamicText].setNewTextFormat(textFormat);//this.getNextHighestDepth()//dynamicText.TextFormat(size=16);this.createClassObject(mx.controls.UIScrollBar,dSc rollbar,20);this[dScrollbar].setStyle(haloOrange);// Set the target text field for the scroll bar.this[dScrollbar].setScrollTarget(this[dynamicText]);this[dScrollbar].setSize(i, this[dynamicText]._height);// Move it next to the text field.this[dScrollbar].move(this[dynamicText]._x + this[dynamicText]._width, this[dynamicText]._y);//trace(this[dScrollbar]._targetInstanceName);this[dScrollbar].setScrollTarget(this[dynamicText]);this[dynamicText].text = comment;} Link to comment Share on other sites More sharing options...
bairdb Posted March 14, 2008 Share Posted March 14, 2008 Try to give the scrollbar a variable name. dScrollbar = this.createClassObject(mx.controls.UIScrollBar,dSc rollbar,20) and then instead of useing this[dScrollbar]. just call the scrollbar by dScrollbar. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 19, 2008 Share Posted March 19, 2008 You're giving all of the scrollbars the same name:var dScrollbar="dScrollbar"+1;They are all called "dScrollbar1". Link to comment Share on other sites More sharing options...
sajan Posted March 25, 2008 Author Share Posted March 25, 2008 Actually i meant 'i' instead of 1.sorry for that.I am using 'i'.The problem is solved when i used import mx.controls.UIScrollBar; before the code.thanks Link to comment Share on other sites More sharing options...
penguine Posted April 7, 2008 Share Posted April 7, 2008 That was a lot helpful.thank u Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.