Flash Help

  • Started
  • Last post
  • 2 Responses
  • tommyo

    Okay I'm just trying to get this function to work. I need an MC with the name 'line1_MC' to duplicate itself. I need the naming of the variables to be somewhat dynamic since I'm going to use this function with a 'for loop'. Thoughts?

    var curNum = 1 //Sets the 'lineInst' variable to line1_MC
    var lineInst = "line" + curNum + "_MC"; //Will return line1_MC
    var newLineInst = "line" + (curNum+1) + "_MC"; //Will return line2_MC
    var lineY = 70; // Returns value of 70

    function addLine (origLine, newLine, lineY) {
    origLine.duplicateMovieClip(newL... this.getNextHighestDepth(), {_x:2.1, _y:lineY});
    }

    addLine (lineInst, newLineInst, lineY);
    trace (lineInst);
    trace (newLineInst);
    trace (lineY);

  • nuggler0

    The variables that are different for each loop should be changed within the function. This works if you have line1_MC on stage:
    var curNum = 1;
    var lineY = 70;
    function addLine(origLine, newLine, lineY) {
    origLine.duplicateMovieClip(newL... this.getNextHighestDepth(), {_x:2.1, _y:lineY});
    }
    for (i=20; i>0; i--) {
    curNum++;
    addLine(line1_MC, "line"+(curNum)+"_MC", curNum*10);
    }

  • tommyo0

    Man I owe you a beer. Thanks for your help!!

    Cheers!!