Hi there
I want to display a list of purchases with their name and price. I want the price aligned right and the item aligned left. Should I try to do it in two text fields and one scrollbar? Or should I put the two text fields in a movie clip and scroll the movie clip? The text is dynamic and I don’t know how long the list will be.
If anyone can head me in the right direction that would be great.
Thanks
Just to follow up in case anyone else has a similar question, I found I can scroll two dynamic textfields with one scrollbar using onScroller
theField_txt.onScroller = function (scrolledField) {
trace("scroll is " + this.scroll);
trace("maxscroll is " + this.maxscroll);
trace("hscroll is " + this.hscroll);
trace("maxhscroll is " + this.maxhscroll);
};
I found this code at http://safari.oreilly.com/059600396X/ch18-1899-fm2xml
I’ve attached a zipped file with an .fla and the external text file with the code in action.
The code looks like this:
var transaction_fmt:TextFormat = new TextFormat();
transaction_fmt.color = 0x000000;
transaction_fmt.font = "Arial"
transaction_fmt.size = 12;
_root.transaction_mc.createTextField("item_txt",100,10,0,200,160);
with (_root.transaction_mc.item_txt) {
multiline = true;
wordWrap = true;
type = "dynamic";
selectable= false;
border = false;
html = true;
//autoSize = "left";
htmlText=_root.shoppingLoadVars.itemList;
setTextFormat(transaction_fmt);
}
_root.transaction_mc.createTextField("price_txt",101,390,0,80,160);
with (_root.transaction_mc.price_txt) {
multiline = true;
wordWrap = true;
selectable= false;
type = "dynamic";
border = false;
html = true;
//autoSize = "left"
htmlText=_root.shoppingLoadVars.priceList;
setTextFormat(transaction_fmt);
}
//scrollbar one
initiateOne={_targetInstanceName:"price_txt",horizontal:false};
//attach the scrollbar with actionscript:
_root.transaction_mc.attachMovie("UIScrollBar","myScrollbar1",11,initiateOne);
//position scrollbar and set hieght
myScrollbar1._x=Number(450);
myScrollbar1._y=Number(price_txt._height)-162;
myScrollBar1.setSize(price_txt._height)-10;
_root.transaction_mc.price_txt.onScroller = function (scrolledField) {
_root.transaction_mc.item_txt.scroll= this.scroll;
};