A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Little help for a newbie

  1. #1
    Junior Member
    Join Date
    Aug 2016
    Posts
    8

    Little help for a newbie

    Hello everybody!

    I need to load 100 instances of the same clip, everyone in a random position.
    This script does not seem to work:

    Code:
    import flash.display.MovieClip;
    var droplet: drop = new drop();
    for (var n: int = 0; n < 100; n++) {
    	droplet.name = "droplet" + n
    	addChild(droplet);
    	droplet.x = Math.random() * stage.stageWidth;
    	droplet.y = Math.random() * stage.stageHeight;
    }
    Could anyone kindly suggest me the right way?
    Thanks!

  2. #2
    Junior Member
    Join Date
    Aug 2016
    Posts
    8
    ok i managed to make it work with an array:

    droplet[i] = new drop();
    droplet[i].x = Math.random() * stage.stageWidth;
    droplet[i].y = Math.random() * stage.stageHeight;
    addChild(droplet[i]);

    now, i need to removeChild after droplet clip played.
    a removechild within the clip itself seems to dont work.
    Thanks!

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Do you have a class for your MovieClip or simply frame to frame animation?
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Aug 2016
    Posts
    8
    Quote Originally Posted by cancerinform View Post
    Do you have a class for your MovieClip or simply frame to frame animation?
    im afraid the second

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    In the last frame of your MovieClip place these two lines:

    stop();
    this.parent.removeChild(this);

    This will remove the MovieClip after the animation.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    Aug 2016
    Posts
    8
    hey thanks so much. it works indeed, but i got an error in the output window.

    "TypeError: Error #1009: Impossibile accedere a una proprietÃ* o a un metodo di un riferimento oggetto null."

    it is in italian, but basically it means "impossible to read a property or a reference method for a null object"

    do you know what it could be?
    thanks a lot!!!!!!!

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    this.parent must be the timeline to remove the movieclip. If the animation is inside of another movieclip, it would not work. Also the stop() is very important. You can try to create one more frame, where you put the stop(); and in the frame before place this.parent.removeChild(this); if this.parent is the timeline.
    - The right of the People to create Flash movies shall not be infringed. -

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