PDA

View Full Version : Display dynamic text variable to another frame...


GKM
04-14-2005, 12:11 PM
Hi,
I'm recreating a game for a friend of mine and I'm stuck with a quite silly and stupid thing.
The game is about two spaceships that they try to kill each other, they have 5 lives each and I also track the score for both for every hit they make.
In the frame where the game (fighting) evolves I have two dynamic text boxes, with the var(s) player1.point and player2.point, where I display the score for each hit...Everything works fine until now....

Now I want to be able to "transfer" the two dynamic text boxes to a previous frame, where I send the players if either losts all of his/hers (5) lifes and be able to display the final score (for example 120 - 60)...

How I'm supposed to do this??

Thanks :)

Laguana
04-14-2005, 12:44 PM
You would probably set a variable on the _root to be the value, and then refer to that.

something like:


_root.p1Score = player1.point
_root.p2Score = player2.point
// then code which goes back a frame

Then in that previous frame you refer to _root.p1Score and so on.

GKM
04-15-2005, 10:13 AM
Hi,
Thanks for the answer...
My problem still remains though but with a different result...I used to type the code like this...

p1Score = player1.point
p2Score = player2.point
And the result was only getting the text that I have typed for example in the dynamic text box...
Now, after using your code, I'm getting blank text boxes... :confused:
I'm sure that this is a progress... ;)
Any idea why this is happening..?

Laguana
04-16-2005, 02:29 AM
How are you setting the text in the dynamic text boxes?

GKM
04-16-2005, 11:39 AM
Hi,
What do you mean? I have set the two text boxes (copy-paste from the final frame, where it counts the score, to a previous frame, where you get the final result)...The text is only a zero and I just add the variable field, following your instructions...

Laguana
04-16-2005, 03:13 PM
What i would do, is set up the code in the frame to be something like this:


_root.pathtotextbox1.text = _root.p1Score
_root.pathtotextbox2.text = _root.p2Score

Which sets the text to be those variables. I've always been a bit wary of setting a textbox to a variable... but that's just me.

Barn
04-16-2005, 06:20 PM
I've always been a bit wary of setting a textbox to a variable
As well you should.

Any variable displayed in a textField becomes, by definition, a string, rather than a whatever data type it might have been prior (number, boolean), making it necessary to always convert the value to the data type required in performing any non-type-specific operations (such as adding, which will, if a string is found anywhere in the expression, will result in concatenation rather than addition).