[AS] Help with scroll text boxes and variables.

6 posts

Flag Post

I’m trying to create a list of names, with corrosponding numbers within a scrollbox.

Ex.
Gold = 1
Silver = 10
Bronze = 20

I’d like to have this information contained within a scrollable dynamic text box, however I have no clue how to put multiple variables into a text box.

I tried having a simple scrollbox with gold,silver,bronze typed manually, and dynamic scrollbox next to it to contain the number values. EX:

STATIC DYNAMIC TEXT
V V
__________ ______
Gold | | 1 |
Silver | | 10 |
Bronze | | 20 |

…but I do not know how to make the dynamic text box load the variables for gold/silver/bronze individually, let alone to place them each on their own line.

(I’ve already created up/down arrow buttons to scroll both text boxes.)

How can I have a single text box load different variables, 1 variable per line?
OR, if that’s impossible (or impractical),
How can I achieve that effect with many text boxes?

 
Flag Post

EDIT: SOLVED!
I’ve made a dynamic text box (with variable “orearray”) that shows both item name and it’s variable quantity;

orearray = (“Iron” + _root.iron newline “Gold” + _root.gold)
to show:
Iron 10
Gold 1

It ultimately was an error with the font type. Solved now.

 
Flag Post

You can make your text box have a mask that only displays 1 line at a time. Add an event listener for a click on the text box to get ‘focus’ (optional) and add a scroll event to make the object that cointains your text move up or down each time the scroll wheel is turned. If that doesn;t make sense I can whip up an example for you.

As for displaying the text in the single text box to get a new line in a string you type "text1"+"\n"+"text2"
So for your example
var goldVar:uint = 1
var silverVar:uint = 10
var bronzeVar:uint = 20

textBoxText.text = "Gold “goldVar”\n"+"Silver “silverVar”\n"+"Bronze "+bronzeVar

Will display in a text box thats big enough


Gold 1
Silver 10
Bronze 20

 
Flag Post

Scroll event should look like this.

yourMoveclipThatContainsYourText.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheel);
public function mouseWheel(event:MouseEvent)
		{
			if (event.delta == 3)
			{
				yourMoveclipThatContainsYourText.y -=  scrollYOffSetScrollSpeed;
			}
			if (event.delta == -3)
			{
				yourMoveclipThatContainsYourText.y +=  scrollYOffSetScrollSpeed;
			}
		}

Where scrollYOffSetScrollSpeed is the height of 1 line of your text box. Also add a if statement to make it so the person can’t scroll it any higher than the top text or any lower then the bottom text box.

 
Flag Post

You should stop editing and just replying by the way… Im answering your questions that you keep editing over. If someone else has a similar problem or similar questions it would be good if they could see what your asking so the answers i’m giving have context.

 
Flag Post

Sorry for all the edits. I appreciate the help, but I figured out a much simpler method;

Using: orearray = new Array("Gold"+_root.gold newline "Silver"+_root.silver +newline+"Bronze"+_root.bronze)

and for the scroll, I essentially wanted to click buttons to scroll, rather than a mousewheel scroll.
Solved that by using
on(Release){
orelist.scroll +-=1;}
on my up/down buttons.

My main problem was the “newline”, and the “.scroll”. I had never used either before.

Thanks though!