Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form question

Status
Not open for further replies.

ImpInTraining

Programmer
Jan 27, 2007
19
US
I'm trying to make a dice-roller program. In the form I am using, it is to be reading various values from TextInput boxes. I'm just not too clear on how to obtain the data from a TextInput box.

For instance, I put a little error checking in there for the one box to decide how many dice to roll. If the Text Box with the Instance Name of "numberDie" is greater than 20, or less than 1, it is to give an error and await another attempted submit button push.

What would be the syntax of obtaining the text from that "numberDie" Text box, and could I use that syntax directly in my programming calculations, or should I copy it over into a variable before putting it to use?
 
> What would be the syntax of obtaining the text from that "numberDie" Text box

numberDie.text

> could I use that syntax directly in my programming calculations, or should I copy it over into a variable before putting it to use?

You must convert it to a Number before using it in calculations, e.g. var n:Number = parseInt(numberDie.text);

Kenneth Kawamoto
 
Ah, many thanks. I have the script doing ... something. Some other bugs to work out though.

I have a text field to respond with the results or print out error messages when they apply. The text field is approximately 57 characters wide, and about 4 or 5 lines high, but the text field is only using about 16 characters wide before wrapping, and only two lines down before the information is extending beyond the visible field.

Is there a way to set the width and height of the text field that I'm missing? Maybe in the Component Inspector?
 
You can set TextField's "_width" and "_height" properties.

You may want to look into "autoSize" property as well.

> Maybe in the Component Inspector?

TextFields are not Component.

Kenneth Kawamoto
 
Ah, right you are. I was confused about the terminology. That particular problem I'm having is with a Text Area, not a "Text Field". My apologies on the confusion.
 
You can set the size of your TextArea Component from "Properties" panel (not from the Component Inspector.)

Also you can set the size via script using "setSize()".

But doesn't TextArea give you the scrollbars when the text is beyond the display area??

Kenneth Kawamoto
 
Well, you'd think so, huh? But it's not. Let me see if I can post what I have so far. Keep in mind, the underlying actionscript is still a little buggy (thus why I'm rolling nothing but 1's)... but that's a work in progress.

Here:
Click on "Products" and then "Dice Roller".
 
I don't know how you managed to do this but your TextArea is 337.85 x 210.4, but the TextField inside (Every TextArea Component contains TextField inside) is 100 x 43.95 - that's why your text wraps at 100 px.

I would delete the TextArea and do it again!

Kenneth Kawamoto
 
If I might ask another question... how could you tell that exactly? I mean, when I look at the TextArea, I don't see anything specific about the TextArea, nor the TextField inside it. Guess I just need to know where to look...
 
Sweet... thanks. I hadn't explored all of Flash 8's bells and whistles yet, particularly the debugging portions.
 
Ok, well... I've tried deleting the TextArea and putting a new one in its place, both by dragging it onto the field, and also by double-clicking and then moving it into position. In both cases, the TextArea starts out small, about the size of text that is visible. When I resize the TextArea, it has no effect on the TextField, apparently.

I suppose if I had to, I could put multiple TextInput boxes in there to simulate the TextArea purpose. At least I know those are working and I don't have to fool around with this TextField problem. Maybe that's what I'll do. Seems like the easier fix.
 
I deleted the TextArea, and am using just a Text Field on top of a white rectangle. Seems to be working fine so far, although I've only tested it superficially thus far. Not sure how it will handle scrolling or wrapping. Time will tell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top