View Full Version : Displaying variables on screen
crassus
01-10-2003, 08:29 AM
how can i actually express the contents of a variable on screen with a text-field (so that the text-field changes when the variable does)?
thanks
crassus
Mortimer Jazz
01-10-2003, 09:21 AM
What will be causing your vaiable to change? Will it change over time or will it be changed by a user-event (ie when the user presses a button, or moves their mouse etc etc)?
Also, are you using Flash 5 or Flash MX? There are slight differences between the way text is handled between them.
Assuming flash 5 (this will also work in MX, althought not the preferred way to do it...) draw a dynamic textbox and give it a VAR name of yay. Next create a button and place the following code on the button:
on(release){
yay="spanky!";
}
When the user event occurs (button press) the textbox will be updated - but of course on subsequent presses of the button the content will remain the same. So now to see a clearer example of the content being updated use the following code:
on(release){
yay = count++;
}
and on the first frame of your timeline place the line of code count=0;
Each time you press the button your textbox will be made equal to the value of count, plus 1 (which is what count++ does)
Hope this helps :)
Mort
crassus
01-10-2003, 09:35 AM
didn't work yet. to be honest i don't know of any dynamic textbox - just of normal textboxes. if you mean a normal textbox - how can i give it a var name?
it's a little complicated for me as my version of flash (by the way: flash 5) is in german.
simontheak
01-10-2003, 09:58 AM
There are 3 different types of text box:
- Static/Normal (Just puts the text on the screen)
- Input (Lets users type into the box)
- Dynamic (Let's you do a load of fancy stuff!)
It's been a while since I used Flash 5, but if I remember correctly you can choose which type of box you want in the text panel (where you choose the font and colour of the text you want)
Oh and one last thing ... make sure you enter YAY in the variable name box and not the instance name box - that's one thing that screwed me up for ages. The variable box is (I believe) in the text panel again.
crassus
01-10-2003, 10:09 AM
wow, it worked.
many thanks for the information!
crassus
Mortimer Jazz
01-10-2003, 10:14 AM
I think your best bet would be to get one of the many beginners actionscript books available. They will give you step-by-step instructions with corresponding photos/illustrations of what to do, which should be invaluable if you have a German copy of Flash and the language difference is causing problems.
There are also some German speaking forums which may be better suited to yo :)
If you can't afford a book then there are plenty of great flash tutorials on the web. There's also a great tutorials section here but nothing directly related to this particualr problem.
Hope this helps
Crash Resistant
01-10-2003, 01:23 PM
Seriously.
Mortimer Jazz
01-10-2003, 03:58 PM
yeah, okay okay :rolleyes:
For a beginner you can choose to start learning Flash from several different sources. crassus has chosen the forums, but at his/her current stage of learning I'm suggesting that it's perhaps not the best option.
"it's a little complicated for me as my version of flash is in german" - well a forum isn't going to be the best way for crassus if people are going to have to explain where everything is each time..... whereas pictures in a book will transcend the language barrier. The posts will be unecessarily time consuming for both parties involved.
Also, trying to get answers via a forum, when you're not even sure of the very basics (ie creating a dynamic text box) could be an arduous drawn-out process which will not be particularly beneficial to crassus anyway.
ie:
Q: How do I draw a straight line
A: Use the line tool and hold down shift simultaneously
Q: Where's the line tool?
There you go. Happy now? ;)
*some people are SO picky!* - lol
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.