HOME       >>       Programming

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


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]));}



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...


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


Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.