whats the difference between saying
var box:Object;
and
box = new Object();
i know var box:Object; passes syntax but will trace undefined I just don't understand why it is there as an option.
and what is the difference between using
var box = new Object();
and
box = new Object();
Hi,
the difference between
and
| Code: |
| myObj=new Object(); |
is, that with the first statement you declare a variable with a type of object.
The second statement creates a new object and assigns the newly created object to the variable myObj.
Therefore, when you try to access myObj before the second statement, you will get an "undefined" message. After assigning an object, you can access this object via the variable myObj.
HTH
Makli
ok that makes sense. but what about my 2nd question?
what is the difference between using
var box = new Object();
and
box = new Object();
When you use
var myObject:Object;
you declare a local variable in the codeblock, where you place the declaration. Only when you use the var-statement, you can use strict typing.
A variable you have already declared cannot be declared again as a local variable.
HTH
Makli
how do local varibles work in flash? are they local to that scene?
and how is it declared if you do not use var?
var myNumber:Numer = 5;
is the same as
myNumber = 5;
The first one is just strict data typing.
They are both local to that code block. If you want a variable that is accessable anywhere on that frame, declare it like this:
_root.myNumer = 5;
And in the whole timeline:
_global.myNumber = 5;
Dont use scenes when using actionscript.