Ask a Question related to Macromedia Director Lingo, Design and Development.
-
Rodrigo Alarcon webforumsuser@macromedia.com #1
Global Variables problem
Hi there.. i know this is a very newb question, but any way... need to know something.
I had declared a global variable this way:
on exitFrame me
global gLife
gLife = 4
set the text of member("vida_text") = "Vida: " & gLife & "/4"
end
when i play the movie, i can see that the text of member vida_text is changed to "Vida: 4/4", that's cool, i can even see the variable value on the Message window when I type: ShowGlobals. For what i know this variable is avaliable ALL the time the proyector is running, but when i try to use it for example in a button with this lingo:
on mouseUp
if member ("p1_r1").hilite = 1 then
put gLife
set the text of member("vida_text") = "Vida: " & gLife & "/4"
else
beep
end if
end
I get this error EVEN B4 i start the movie:
Variable used before assigned a value
put gLife?
How can this be posible is the gLife variable is declared as a GLOBAL variable and i can see the value that it contains?
The truth is out there!
Rodrigo Alarcon webforumsuser@macromedia.com Guest
-
Global Variables
I would like to know the preferred way in which to define, store, and retrieve global varialbes in asp.net applications. I have read through past... -
Global variables in AS3
The documentation for AS3 tells me that a variable set as 'public' will be available everywhere. If I set public var myvar:String; at the top of... -
Global/persistent variables
I'm analysing a conversion of a system from Oracle to PG. The system in case uses a lot of PL/SQL packages and lots of them uses public/static... -
Problem with global variables
Hi All, I'm turning mad with global variables... In created a simple test script with 2 functions which worked fine but the other one i need... -
Global variables - application variables vs include file
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include... -
alchemist #2
Re: Global Variables problem
You need to define it as a global in every script you want to have access to
the variable:
global gLife
on exitFrame me
gLife = 4
set the text of member("vida_text") = "Vida: " & gLife & "/4"
end
global gLife -- if this handler is in the same script you don't need this
line. Otherwise, you do.
on mouseUp
if member ("p1_r1").hilite = 1 then
put gLife
set the text of member("vida_text") = "Vida: " & gLife & "/4"
else
beep
end if
end
"Rodrigo Alarcon" <webforumsuser@macromedia.com> wrote in message
news:bqlo2c$pgs$1@forums.macromedia.com...know something.> Hi there.. i know this is a very newb question, but any way... need tochanged to "Vida: 4/4", that's cool, i can even see the variable value on>
> I had declared a global variable this way:
>
>
> on exitFrame me
> global gLife
> gLife = 4
> set the text of member("vida_text") = "Vida: " & gLife & "/4"
> end
>
> when i play the movie, i can see that the text of member vida_text is
the Message window when I type: ShowGlobals. For what i know this variable
is avaliable ALL the time the proyector is running, but when i try to use it
for example in a button with this lingo:variable and i can see the value that it contains?>
>
> on mouseUp
> if member ("p1_r1").hilite = 1 then
> put gLife
> set the text of member("vida_text") = "Vida: " & gLife & "/4"
> else
> beep
> end if
> end
>
>
> I get this error EVEN B4 i start the movie:
>
>
> Variable used before assigned a value
>
> put gLife?
>
> How can this be posible is the gLife variable is declared as a GLOBAL>
> The truth is out there!
alchemist Guest
-
Daniel Pliscoff #3
Re: Global Variables problem
> How can this be posible is the gLife variable is declared as a GLOBAL variable and i can see the value that it contains?
because is declared but not invoked in the behavior
on mouseUp>
global gLife -- invoke the variable first
if member ("p1_r1").hilite = 1 then
put gLife
set the text of member("vida_text") = "Vida: " & gLife & "/4"
else
beep
end if
end
salu2
D.
> The truth is out there!Daniel Pliscoff Guest
-
Arturo Toledo #4
Re: Global Variables problem
You can declare globals both inside or outside of a handler. It´s generally
better to declare your global variables at the beginning of the script,
outdide of handlers... say... as the other guys have already mentioned, you
must declare your globals in every SINGLE script you use them. We all know
that does not always happen in other programming languages but hey!!! say
hello to Lingo.
global gLife
global mLife
global pDeath
-- and then place the handlers...
on mouseUp
bla bla bla
bla bla bla
end
"Rodrigo Alarcon" <webforumsuser@macromedia.com> escribió en el mensaje
news:bqlo2c$pgs$1@forums.macromedia.com...know something.> Hi there.. i know this is a very newb question, but any way... need tochanged to "Vida: 4/4", that's cool, i can even see the variable value on>
> I had declared a global variable this way:
>
>
> on exitFrame me
> global gLife
> gLife = 4
> set the text of member("vida_text") = "Vida: " & gLife & "/4"
> end
>
> when i play the movie, i can see that the text of member vida_text is
the Message window when I type: ShowGlobals. For what i know this variable
is avaliable ALL the time the proyector is running, but when i try to use it
for example in a button with this lingo:variable and i can see the value that it contains?>
>
> on mouseUp
> if member ("p1_r1").hilite = 1 then
> put gLife
> set the text of member("vida_text") = "Vida: " & gLife & "/4"
> else
> beep
> end if
> end
>
>
> I get this error EVEN B4 i start the movie:
>
>
> Variable used before assigned a value
>
> put gLife?
>
> How can this be posible is the gLife variable is declared as a GLOBAL>
> The truth is out there!
Arturo Toledo Guest



Reply With Quote

