Jump to content
xisto Community
Sign in to follow this  

Type Checking Not Work On For .. In Loop Flash 8 - actionscript 2.0

Recommended Posts

It seems that the actionscript 2.0 type checking was not work as expected on some place.
When variables was created on for .. in loop.
It will allow any variable type to be used.
Or it is default construt !?

var dayNames1:Array = ["Sunday", "Monday", "Tuesday", 5];for (var dayName:String in dayNames1){	trace(dayNames1[dayName]);	trace(typeof(dayNames1[dayName]));}


Share this post

Link to post
Share on other sites

I'm not exactly sure what your problem is, maybe I'm just overlooking it but everything looks fine to me. I mean you are creating an array with various pieces of data in it, and asking for the types to be printed. In turn, the software is printing the values and the types. The strings and printing string and the numerical value as 'number'. This all seems pretty straight forward to me so I'm not exactly seeing the problem, so can't offer help. maybe if you can be more precise I can offer a better assistance...

Share this post

Link to post
Share on other sites

I'am sorry haven't made things clear ;)

Basically, all things are work without any issues.
But the actionscript 2.0 type checking was not detected a type mismatch issues on the for .. in loop.

The actionscript 2.0 stated that it will check datatype of a variable when it is compiling. Such as,

var currentTime:Date;currentTime = 5;

The second statement will cause an error occured. ( type mismatch errors )

But this does't seem appear on for .. in loop because I declared the loop variable as datatype of `String`

It's a bit trouble when coding and debuging script ;)
Edited by magiccode9 (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.