A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: myMovieClip.onRelease

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    49
    hi

    i used this loop to declare every movieclip in an array as a button:

    for(i=0; i<theArray.length; i++){
    _root["myMovieClip" add i].onRelease = function () {
    _root.theReleasefunction();
    }
    }

    but the function only appears to work on the last moieclip (i=theArray.length)

    what can i do????

    please help

  2. #2
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    why is i = theArray.length when you set i = 0

    you have a list of movieclip names in theArray? or do you just have movieclips named myMovieClip, myMovieClip1, myMovieClip2 etc...?

    Code:
    for(var i; i < theArray.length; i++){
         _root["myMovieClip" + i].onRelease = function () {
              _root.theReleasefunction();
         }
    }

  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    49
    sorry, a typing mistake:

    i=0; i<theArray.length; i++

    in this particular case, i have an array with some properties of the different movies.

    the whole thing:

    function createObstacles() {
    for (i=0; i<obstacles.length; i++) {
    //creates a empty movie as a reference
    _root.master.attachMovie("leer", "obstacle" add i, i+1);
    //loads the external movie into the reference
    loadMovie("tiles/mo_" add _root.obstacles[i][0] add ".swf", _root.master["obstacle" add i]);

    var actual = _root.master["obstacle" add i];
    actual.obj = i;
    actual._y = (obstacles[i][1]*25)+(obstacles[i][2]*25);
    actual._x = (obstacles[i][1]*-50)+(obstacles[i][2]*50);
    actual.obst = i;
    for (row=0; row>(-1*obstacles[i][4]); row--) {
    for (col=0; col<obstacles[i][3]; col++) {
    var actualrow = Number(obstacles[i][1])+row;
    var actualcol = Number(obstacles[i][2])+col;
    _root.theMap[actualrow][actualcol] = "x";
    }
    }
    _root.changeToButton(actual);
    }
    }

    function changeToButton(obj) {
    obj.onRollOver = function() {
    trace("cool");
    };
    }

  4. #4
    Member
    Join Date
    Jan 2001
    Posts
    49
    ------------ please help me -----------

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