dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Possible to Use Variable Identifiers inside Objects?

  1. #1
    Army Web Designer
    Join Date
    Jun 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    140

    [F8] Possible to Use Variable Identifiers inside Objects?

    Is it possible to specify a variable identifier inside a movieClip object?

    code:

    var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
    // I know that the following won't work, but I'd like to specify a variable identifier, so, I would have written it like so:
    var myClip.myNewVar:String = "Why must it be so hard!?";


    Jason Beaudoin
    Web Designer
    Canadian Army

  2. #2
    Senior Member RangrJay's Avatar
    Join Date
    Sep 2005
    Location
    Las Vegas
    Posts
    163
    did you think to try
    Code:
    myClip.onEnterFrame = function():Void
    {
      var myNewVar:String = "maybe this will work";
      delete myClip.onEnterFrame;
    }
    //I have programmed in Flash in a while, but there may be a myClip.onLoad = function...
    //but I'm not sure if that would work.
    Xero Patience Studios
    Web Design
    Software Development
    Graphic/Logo Design

  3. #3
    Senior Member dlowe93's Avatar
    Join Date
    Aug 2001
    Location
    Stumptown
    Posts
    621
    Quote Originally Posted by Beaudoin
    Is it possible to specify a variable identifier inside a movieClip object?

    code:

    var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
    // I know that the following won't work, but I'd like to specify a variable identifier, so, I would have written it like so:
    var myClip.myNewVar:String = "Why must it be so hard!?";


    You're the web designer for the Canadian Army? That's cool.

    Yes, you can create dynamic variable references to movie clips, the problem is that you can't type them.

    So you could do:

    Code:
    var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
    myClip.myNewVar = "Hey! It works!";
    
    //and check it;
    trace(myClip.myNewVar);
    If you really needed/wanted to do so, you could type the variable this way:

    Code:
    var myClip:MovieClip = this.createEmptyMovieClip("myClip", this.getNextHighestDepth());
    var temp:String = "Hey! It works!";
    myClip.myNewVar = temp;
    
    //and check it;
    trace(myClip.myNewVar);
    Hope this helps.

    d.
    dlowe93

  4. #4
    Army Web Designer
    Join Date
    Jun 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    140
    That's great! Thanks guys!
    Jason Beaudoin
    Web Designer
    Canadian Army

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