|
|
|
|
![]() ![]() |
Sep 6 2008, 02:01 AM
Post
#1
|
|
|
Advanced Member Group: [HOSTED] Posts: 120 Joined: 7-November 05 Member No.: 9,489 |
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 !? CODE var dayNames1:Array = ["Sunday", "Monday", "Tuesday", 5]; for (var dayName:String in dayNames1) { trace(dayNames1[dayName]); trace(typeof(dayNames1[dayName])); } CODE 5
number Tuesday string Monday string Sunday string |
|
|
|
Sep 8 2008, 02:37 AM
Post
#2
|
|
|
Whitest Black Mage Group: [MODERATOR] Posts: 1,371 Joined: 20-May 05 From: NB, Canada Member No.: 5,281 myCENTs:65.99 |
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...
|
|
|
|
Sep 8 2008, 12:03 PM
Post
#3
|
|
|
Advanced Member Group: [HOSTED] Posts: 120 Joined: 7-November 05 Member No.: 9,489 |
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, CODE 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 This post has been edited by magiccode9: Sep 8 2008, 12:06 PM |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 2nd December 2008 - 12:07 AM |