A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: controling duplicated movie clips

  1. #1
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660

    controling duplicated movie clips

    hi, i'm developing a shooting game, in which i am duplicating the bullet (ship) to shoot at a guy.

    i have an array as you can see here.


    Code:
    		for (i=1; i<=50; i++) {
    			_root.ship[i] = new shipparent();
    			duplicateMovieClip(_root.ship, "ship"+[i], i);
    			_root.ship2._x = _root.gun._x;
    			_root.ship2._y = _root.gun._y;
    		}
    	}
    in stead of using ship2, i would like to use what ever is the next unused ship... and im not quite sure how to do this.

    does any body else know?
    thanks a bunch

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    FL, USA
    Posts
    442
    Do you mean...
    Code:
    for (i=1; i<=50; i++) {
    duplicateMovieClip(_root.ship, "ship"+i, i);
    _root["ship"+i]._x = _root.gun._x;
    _root["ship"+i]._y = _root.gun._y;
    }
    ??

  3. #3
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660
    it didn't work... im not exactly sure why...

    but i think it be better if i used a varible to control which ship to use...

    i tried setting shipNum = 2

    and then using this code but it didnt work...


    for (i=1; i<=50; i++) {
    _root.ship[i] = new shipparent();
    duplicateMovieClip(_root.ship, "ship"+[i], i);
    _root.ship[shipNum] ._x = this._x;
    _root.ship[shipNum] ._y = this._y;
    }

    is there any way to do this?

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    156
    try _root["ship"+ shipNum]._x instead. Also add shipNum++ inside your for loop.

    this will give you essentially the same as the previous example. the last one should have worked.

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