View Full Version : Declaring a Global Variable
jjhoal
10-15-2007, 09:49 AM
I have two MovieClip, MC1 and MC2, inside MC1 I declare "var i = 1".
Now I need to access "var i" inside MC2, anybody knows how to declare a variable which I can access anywhere in my code?? Whether I am inside MC1 or MC2?:confused: :confused:
supriyopaul
10-15-2007, 09:52 AM
declare your var like dis:-
_global.i = 1
panel
10-15-2007, 09:59 AM
use static
Create class with static variable
Put this code in file Parameters.as
package
{
public dynamic class Parameters
{
public static var variableName:String;
public function Parameters()
{
}
}
}
usage
Parameters.variableName = "abc";
BTW
in fou wanna validate variable before asigning make it private and use getter/setter
jjhoal
10-15-2007, 10:47 AM
thanks for that tip, but anyway? can I declare multiple variable inside that package? Which all I can access?
panel
10-15-2007, 10:52 AM
Yes and you are declaring them in class not in package.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.