var in MX was used to localise variables...
if i used var some = 3 ; in a function, that variable couldnt' be seen outside that function
MP
Printable View
var in MX was used to localise variables...
if i used var some = 3 ; in a function, that variable couldnt' be seen outside that function
MP
You need 'var' if you want ot use typeinf
var name:type = value
you cannot say
name:type = value
So if you want the sort-of type checking that AS2 provides, you HAVE to use var
You need 'var' if you want ot use typeinf
var name:type = value
you cannot say
name:type = value
So if you want the sort-of type checking that AS2 provides, you HAVE to use var
Ok. That works for me as long as there is finally strict
rules to how the game is played.
var in MX was used to localise variables...
if i used var some = 3 ; in a function, that variable couldnt' be seen outside that function
MP
Yep. This is why I was wanting things crystal clear before
I settle into using AS2. I want to begin any new habits
the 'right way'.
Didn't realize this but MX Pro won't run on Winodws Me?
People knock ME but I never had a problem with it.
Still boots faster that any OS the MS ever released. :)
one more yasunobu13 or anyone who can answer...
is the word 'this' still required? I see you used it
in your Node Class. I was hoping never to type that
word again. Sigh...
Thanks for the input everyone.
Chris
The typing is not all that strict.
Its really still loose .. and variable can have any type of data.
By declaring types, the script compile will pick up some blatant type problems.
eg var x:Number = "Hello";
will get an error, but
mystring = "Hello";
var x:Number = mystring;
will 'work' just fine and the Number variable 'x' now has a string value "Hello" in it.
mystring = "Hello";
var x:Number = mystring;
var y:String = x;
And that will fail, even though at runtime x actually contains a string.
That's because the variables are really typed at all when playing, its just a hint ot the compiler so that it can pick up mistakes in some cases (and if it picks up any mistakes, its a good thing).
But it does NOT mean that only a ceratin type of value can be stored in a variable at all
BTW: If you're exporting to FP7, you HAVE to get case correct as well, so
var x:string = "Hello";
won't work. And if you write stuff like mouse.Hide(); you'll has to rewrite your code for FP7 output to be the strictly correct Mouse.hide(); SO WATCH THAT SHIFT KEY!!
OK, I've done a little looking into of types in AS2
Using the Stack class from before
code:
var s:Stack;
s = new Stack();
As was noted by someone else
code:
st:String = new String(); // Errors
var st:String = new String(); // does not error
with classes
code:
s.push("N"); // Errors, type mismatch
st = "N";
s.push(st); // does not error
trace(s.pop()); // traces: N
var st:String = "N";
s.push(st); // errors, type mismatch
var st:String = new String("N");
s.push(st); // errors, type mismatch;
As you see, strict typing holds for all cases except when a non-typed variable holds the information.
strange. I expect to see the question as to why this happens come up every so often.
mystring = "Hello";
var x:Number = mystring;
will 'work' just fine and the Number variable 'x' now has a string value "Hello" in it.
This should never be allowed. 'x' should be guaranteed to
be a number, no questions asked, period.
This is how bugs end up in code.
Why release AS2 if they really didn't fix it?
I'm really bummed over this. I was looking forward
to not having deal with this issue anymore.
Chris
Yeup .. they've got the type checking wrong .. it should be as per the (yet to be approved) JavaScript 2 specs, which say values have to either be able to be implictly coerced to the type of the variable when assigning to a typed variable .. or you get an error.
The typing in AS2 is next to useless because it is easy for code to avoid it.
What really SHOULD happen is that
x = "Hello";
var y : Number = x;
is that it should be equivalent to
x = "Hello";
var y : Number = Number(x);
But AS2 doesn't do that.
nice one MM:rolleyes:
Or at least it should generate a 'Possible incorrect assignment'
warning. Then you could use some typecast method, as Roger pointed
out, if that's really what you wanted to do.
Maybe in time a third party 'strict syntax compiler' plug-in
will become available. I'd buy that.
Chris
Flash MX 2004 and Flash MX Professional 2004 - "It's like dating really hot twins, except you have to pick one."
... really.
:)Quote:
Originally posted by gSOLO_01
Flash MX 2004 and Flash MX Professional 2004 - "It's like dating really hot twins, except you have to pick one."
... really.
Where did that come from ??
Macromedia's Homepage.Quote:
Originally posted by roger_onslow
Where did that come from ??
I just need some confirmation from someone with experience. Is it really just like dating really hot twins? If so, I'll buy them both...
No, it's more like dating two sisters, one having a few extra tricks up her sleeve.
If in doubt go for the pro.
That, my friend, is called prostitution.Quote:
Originally posted by gSOLO_01
Is it really just like dating really hot twins? If so, I'll buy them both...
Macromedia is whoring out their skanky goods to whomever will buy. ;)
Well, some people have to pay to get dates. That why all of these match/dating services are so successful... or not.Quote:
Originally posted by CNO
That, my friend, is called prostitution.
Ah, so in other words, you have to pay to subscribe to a service that shows you pictures of a nubile 20-year old, when in actuality the end product is nothing like you expected?Quote:
Originally posted by gSOLO_01
Well, some people have to pay to get dates. That why all of these match/dating services are so successful... or not.
Sounds like a pretty accurate analogy. :p
:DQuote:
Originally posted by CNO
Sounds like a pretty accurate analogy.
is it me or is AS2 just a fancy markup for AS1?
I only base this on seeing my class defined as a global function and the ability to publish AS2 for flash player 6
well after a quick look at teh new Flash MX Professional 2004... there isn't much new....
- Spell check
- New programing language
- Not so good intreface (I prefer the on in Flash MX)
- New components
- Able to add items on the right click menu
- Some bug fixes
- and center mouse weal is working....
Quote:
Originally posted by CNO
Product activation don't come cheap.
Someone made a really good point on one of the other discussion forums - since these companies claim that rampant piracy drives up the cost of the software, shouldn't the new security scheme make the software cost less, not more?
What new security schemes did they add?