A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Having trouble with this piece of code (arrays and addChild)

Threaded View

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    69

    Having trouble with this piece of code (arrays and addChild)

    var myShapes:Array = [tl, tr, bl, br];
    trace(myShapes);

    var long:uint = myShapes.length;
    for (var i:uint = 0; i < long; i++)
    {
    addChild();
    this.x = Math.random() * stage.stageWidth;
    this.y = Math.random() * stage.stageHeight;
    this.vx = 0;
    this.vy = 0;
    this.vz = 0;
    }
    I'm getting an error on the "addChild();" line. I've set up an array made up of different movieclips, now I want to get those movieclips onto the stage and animate them randomly (meaning each one moves around the stage at random with the "animateShapes" function.

    What am I missing here ... I'm guessing it's something really simple.

    ETA: tried "this.addChild(MovieClip(myShapes));" but still getting Error: "Incorrect number of arguments: Expected 1"
    Last edited by Leftyplayer; 09-08-2009 at 06:23 PM.

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