Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Type Checking Not Work On For .. In Loop, Flash 8 - actionscript 2.0
magiccode9
post Sep 6 2008, 02:01 AM
Post #1


Advanced Member
Group Icon

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
Go to the top of the page
 
+Quote Post
Jeigh
post Sep 8 2008, 02:37 AM
Post #2


Whitest Black Mage
Group Icon

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...
Go to the top of the page
 
+Quote Post
magiccode9
post Sep 8 2008, 12:03 PM
Post #3


Advanced Member
Group Icon

Group: [HOSTED]
Posts: 120
Joined: 7-November 05
Member No.: 9,489



I'am sorry haven't made things clear sad.gif

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

This post has been edited by magiccode9: Sep 8 2008, 12:06 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How Can I Bind Dynamic Text In Flash Animation?(3)
  2. Flash 8 - Game Tutorials?(8)
  3. Loading External Actionscript(4)
  4. Great Website(0)
  5. Flash Cs3(3)


 



- Lo-Fi Version Time is now: 2nd December 2008 - 12:07 AM