A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: <! var type checking and _global object syntax.

  1. #1
    Senior Member
    Join Date
    Sep 2002
    Posts
    398

    <! var type checking and _global object syntax.

    Hi, I am a litttle bit confused about variable scope when using AS2 syntax and variable checking.. I can assign a variable as a boleean as below..
    Code:
    var firstTime:Boolean = true;
    now how can I attach this to the _global object??
    Code:
    var _global.firstTime:Boolean = true;
    gives errors.. Is any variable defined on the _root _global by default?? Can someone help me out on this??

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Omit the word var.

    The word var is used to define local scope (such as when a variable is local to a function). The purpose of _global is to give you _global scope. No 'var' is needed.

  3. #3
    Senior Member
    Join Date
    Sep 2002
    Posts
    398
    Thanks for your reply..
    I realise this but this code
    Code:
     _global.firstTime:Boolean = true;
    also gives me errors.. as well as
    Code:
    firstTime:Boolean = true;
    which seems to suggest that to opt into the type checking I have to use the "var = ".. ie
    Code:
     var firstTime:Boolean = true
    compiles without error..
    //
    however I can't seem to use the var and define on the _global.. any other ideas? Also some nice stuff on your site. Have checked it out a few times in the past

  4. #4
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Probably need to omit the type-specifier.

    _global.firstTime = true;

    I'm not hugely familiar with where type-specifiers generate syntax errors, since I don't use the feature.

  5. #5
    Senior Member
    Join Date
    Sep 2002
    Posts
    398
    Thanks for your help.. I have been trying to get used to using type checking as a matter of habit.. defining on _global has always stumped me though!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center