Originally Posted by
5TonsOfFlax
For extra credit, what happens when a single post is taller than columnHeight?
If i wanted to add a scrollbar like UIScrollBar.. where abouts do i need to add that scrollbar to the text?
I have this code:
PHP Code:
var scrollBar:UIScrollBar = new UIScrollBar();
scrollBar.scrollTarget = newsBody;
scrollBar.height = newsBody.height;
scrollBar.move(newsBody.x + newsBody.width, newsBody.y);
addChild(scrollBar);
function updateScrollBar():void{
scrollBar.update();
if (scrollBar.enabled == false) {
scrollBar.alpha = 0;
} else {
scrollBar.alpha = 100;
}
}
Inserted into the NewsPost class like so:
PHP Code:
public class NewsPost extends Sprite
{
public var newsBody:TextField;
public function NewsPost( body:String)
{
newsBody = new TextField();
newsBody.embedFonts = true;
newsBody.multiline = true;
newsBody.wordWrap = true;
newsBody.autoSize = TextFieldAutoSize.LEFT;
newsBody.antiAliasType = AntiAliasType.ADVANCED;
newsBody.styleSheet = IStyleSheet(Gaia.api.getPage("index").assets.stylesheet).style;
newsBody.htmlText = body;
addChild(newsBody);
//Create the scrollBar instance
var scrollBar:UIScrollBar = new UIScrollBar();
//assign the target of the scrollBar to your textfield
//addChild(scrollBar);
scrollBar.scrollTarget = newsBody;
//make the height the same as the textfield
scrollBar.height = 200;
//Move the scrollbar to the righthand side
//scrollBar.move(newsBody.x + newsBody.width, newsBody.y);
//add it to the stage
addChild(scrollBar);
//check if it is required if so show it,put this function right after updating your textfield contents with added text
function updateScrollBar():void{
scrollBar.update();
if (scrollBar.enabled == false) {
scrollBar.alpha = 0;
} else {
scrollBar.alpha = 100;
}
}
// Positions & Sizing
newsBody.x = 90;
newsBody.y = newsTitle.height + 10;
newsBody.width = 350;
}
}
But it's giving me a weird 'flashy' result.. have i put this in the right spot?
Many thanks for any help.