Because your function is static.

Either make your var static too:

public static var counter:int=0;

or make your function non-static.

I'm sure you can Google static/non-static class members, but in short,
anything that's non-static is only available from within a class
instance (i.e. someone needs to have called new StringUtils()).

HTH,
   Ian

On Thu, Sep 3, 2009 at 8:23 PM, Isaac Alves<[email protected]> wrote:
> could someone please tell me why in the following script , the flash
> runtime doesn´t recognize the var counter?
> 1120: Access of undefined property counter.
>
> package
> {
>  public class StringUtils
>  {
>        public var counter:int = 0;
>
>    public static function generateRandomString(newLength:uint = 1,
> userAlphabet:String =
> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"):String
>        {
>                trace (counter);
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to