I was just wondering cause I dont really know my flash…
In Visual Basic you can declare a variable for example:
Dim myvariable As Integer
This only allows the variable - myvariable - to hold numbers and wont allow any other data type.
Since Flash doesnt require this its sometimes easier. But declaring also has it advantages because whenever you modify that variable it will act as whatever you stated at the begining. I know in flash you can just change the data type whenever you wish to modify it but i was wondering if there is a way to declare it at the begining so that it will always act as that data type.
Flash is not strongly typed at all, so you can do pretty much anything with anything. I don’t have Flash here so I can’t test it, but I wonder what that code would return:
my_str = new String ("12");
my_str *= 2;
trace (my_str);
Aha! It returns 24, so it won’t behave like a string anyway. The only advantage of declaring variables with the constructor is that class methods execute faster
the real reason I needed this was because I had to make a game for an assignment for school. Everyone basically uses Visual Basic and there was marks in the theory part for “meaningful variable names” and “data types”.