3 Replies Latest reply on Dec 2, 2007 1:29 AM by kid electric

    Strict datatyping causing some problems - String to Int

    kid electric
      Here's my conditional statement (or part of the function, anyway):

      var doCurrentChances:DisplayObject = vbChances.getChildAt(x);

      if (doCurrentChances.text > 0)
      for (var y=1;y<=doCurrentChances.text;y++)
      nameArray[index] = doCurrentName.text;

      Basically, what I am attempting to do is obtain the value of a textinput (which I have already restricted to consist only of integers!)

      Now, I've tried a cast operation as follows:

      var iChances:int = int(doCurrentChances.text);

      which theoretically should work in AS3.0, but...

      but... that doesn't work either! It still gives me the same error:

      1119: Access of possibly undefined property text through a reference with static type flash.

      Will it work if I do a check for "undefined" first? I have forgotten the function to use to check for null/undefined (and I know they are different), but I'm not going to bother looking it up if that won't fix the problem anyway (which, looking at the compiler message, I think it will still throw a fit. After all, it's not smart enough to realize from my code that I have forced the TextInput to contain a number... no undefined and no alpha/punctuation are possible)