Jump to content
Sign in to follow this  
sajan

Assign scrollbar to multiple dynamic textbox

Recommended Posts

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;}

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You're giving all of the scrollbars the same name:var dScrollbar="dScrollbar"+1;They are all called "dScrollbar1".

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...