# 2 textfields 1 scrollbar?

**URL:** https://forum.kirupa.com/t/2-textfields-1-scrollbar/260957
**Category:** flash
**Created:** [May 21, 2008, 1:49pm UTC](https://forum.kirupa.com/t/2-textfields-1-scrollbar/260957 "2008-05-21T13:49:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![oldgreymare](https://avatars.discourse-cdn.com/v4/letter/o/838e76/32.png) [@oldgreymare](https://forum.kirupa.com/u/oldgreymare)
#### Post date: [May 21, 2008, 1:49pm UTC](https://forum.kirupa.com/t/2-textfields-1-scrollbar/260957/1 "2008-05-21T13:49:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![oldgreymare](https://avatars.discourse-cdn.com/v4/letter/o/838e76/32.png) [@oldgreymare](https://forum.kirupa.com/u/oldgreymare)
#### Post date: [May 21, 2008, 8:00pm UTC](https://forum.kirupa.com/t/2-textfields-1-scrollbar/260957/2 "2008-05-21T20:00:52Z")

</div>

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

```php
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](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:

```php

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

```
