0

I'm beginning to hate fl.controls.* with a passion.

All I want to do is have the scroll bar enable when the dynamic TextField the scroll bar has set as its scrollTarget gets to much text. It's very simple yet I can't get it to work. I have tried listening to the scroll event on the TextField to then enable the UIScrollBar but it causes the entire screen to flash black for some reason. It's very strange.

The dynamic TextField and UIscrollBar are both on the timeline of a swf that I load. I've tried setting the scrollTarget property of the UIScrollBar in Flash as well as in Actionscript. If you have a solution to this problem let me know.

I think the best solution I have found is to not use classes in fl.controls. :/

Jordan
  • 1,233
  • 2
  • 12
  • 32
  • Have you tried to listen to the change event and then get row height? – The_asMan Sep 16 '11 at 16:20
  • good lord now the help docs aren't working. Anyways I have not tried that. Can you give me some specifics on how that will solve the problem? – Jordan Sep 16 '11 at 16:52

1 Answers1

0

There was a nice example on the adobe docs with this.
The line you are probably missing is.

mySb.scrollTarget = myTxt;

Note if you use flash you need to drag an instance of UIScrollBar into the library.

import flash.net.URLLoader; 
import  fl.controls.UIScrollBar;
import flash.events.Event; 

var myTxt:TextField = new TextField(); 
myTxt.border = true; 
myTxt.width = 200; 
myTxt.height = 16; 
myTxt.x = 200; 
myTxt.y = 150; 

var mySb:UIScrollBar = new UIScrollBar(); 
mySb.direction = "horizontal"; 
// Size it to match the text field. 
mySb.setSize(myTxt.width, myTxt.height);  

// Move it immediately below the text field. 
mySb.move(myTxt.x, myTxt.height + myTxt.y); 

// put them on the Stage 
addChild(myTxt); 
addChild(mySb); 
// load text 
var loader:URLLoader = new URLLoader(); 
var request:URLRequest = new URLRequest("http://www.helpexamples.com/flash/lorem.txt"); 
loader.load(request); 
loader.addEventListener(Event.COMPLETE, loadcomplete); 

function loadcomplete(event:Event) { 
    // move loaded text to text field 
    myTxt.text = loader.data; 
    // Set myTxt as target for scroll bar. 
    mySb.scrollTarget = myTxt; 
}
The_asMan
  • 6,364
  • 4
  • 23
  • 34