1. what is different between:andCode:Set Variable: "bob" = 5
i have read a few things and not much describing how thay are different.Code:bob = 5
2. Var is like a temporary Variable right? so it deletes itself once it's used right?
Printable View
1. what is different between:andCode:Set Variable: "bob" = 5
i have read a few things and not much describing how thay are different.Code:bob = 5
2. Var is like a temporary Variable right? so it deletes itself once it's used right?
no var is not temporary. I have never had a var delete itself or used a set variable.
hi blue you must be thinking about a varibale defined within a function. if you define a variable in a function, that variable is available only within that function and as soon as the function has run it will go back to being undefined.
have a look at this to get a better understanding
Code:
hello();
function hello(){
trace("first call: " + greeting);
var greeting:String = "hello there";
trace(greeting)// this will output 'hello there'
}
trace(greeting) // this will output undefined
hello(); // this will help u to see that the variable was destroyed as the first call will now say undefined
yeah thats what i ment so thanks.
1.what is different between:
Code:
Set Variable: "bob" = 5
and
Code:
bob = 5
i have read a few things and not much describing how thay are different.
Personally ive never myself or seen anyone else create a variable using the 'Set' keyword within flash? Does this techinque even exist?
( the only place i use Set w.r.t variables is in my ASP pages)
cosider the following variable
var greeting:String = "hello there";
//this variable is available everywhere
function sums(){
var someN:Number = 5; //this is available only within this function due to using the var keyword
}
function sumMore(){
someN = 5; // as we have not used the var keyword it is just the same as defining this variable on the timeline that this function exists (although i woudnt recommend this method)
}
Hope this helps..
ah! so using "var bob" is sorta like using "_global.bob" and "_root.bob"
sorta being key word cuz i know they are different.
Am i on the right track?
yes or no?