A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to use []

  1. #1
    Member
    Join Date
    May 2002
    Location
    Sweden
    Posts
    68

    How to use []

    Hi!

    Let's say i have a code looking something like this:

    Code:
    something.setvar();
    [variable].usethis();
    ...
    
    object.prototype.setvar = function() {
      _global.variable = this;
    }
    
    function usethis() {...}
    Using the [].usethis() dosn't work, but if i shuld use something like _root[].usethis() it does. How can i use [].usethis()? I need this because _global.variable contains the whole instancename, like "_level0.object.object".

    I'm not sure how to explain this, it's kind of confusing

    It shuld look something like this when compiled:

    Code:
    something.setvar();
    _level0.object.object.usethis();
    ...
    
    object.prototype.setvar = function() {
      _global.variable = this;
    }
    
    function usethis() {...}
    The _global.varibale is dynamical and depends on what object called the setvar();

  2. #2
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    Code:
    variable = _level0.object.object;
    variable.usethis(); // the same as _level0.object.object.usethis();  
    //no need to evaluate it...
    //that is, as long as variable is not a string

  3. #3
    Member
    Join Date
    May 2002
    Location
    Sweden
    Posts
    68
    Great!! Worked just fine thanx!!

    When do i need to evalute it acualy?

  4. #4
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    eval when you are using strings.

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