A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Replace MC Instane names from variables AS2

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    11

    Replace MC Instane names from variables AS2

    Hi!
    I am using AS 2.0 and Flash Player 9.
    I want to change MC Instance names and target paths, by using variables.

    As an example, this is the traditional working code.

    enter_btn.onPress = function () {
    clip1_mc.gotoAndPlay("label1");
    };



    I want to do someting like this.
    This code does not work but it shows what I am trying to solve.

    var clipname = "clip2_mc";
    enter_btn.onPress = function () {
    clipname.gotoAndPlay("label1");
    };


    Do you know the solution?
    Thanks from Jotte

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    PHP Code:
    var clipname clip2_mc
    Since clip2_mc is not a String but an Object, remove the quotes.

    gparis

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Posts
    11

    Solution

    Thanks gparis for your input!

    Here is another solution that I found to solve the problem, it works.


    // This is a tutorial that shows how to chage MC Instance names or target paths with variables
    // Tested for AS2 and Flash Player 9
    // The full MC names used are clip1_mc and clip2_mc

    clipname = "1_mc"; // Change between var 1_mc or 2_mc
    labelname = "gobig"; // Change between var gobig or go small
    enter_btn.onPress = function () {
    //_root["clip"+clipname].gotoAndPlay(1); // Works
    _root["clip"+clipname].gotoAndPlay(labelname); // Also Works with label targeting
    };


    Regards from Jotte

Tags for this Thread

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