A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Actions Script Help - Flash Starfield

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    2

    Actions Script Help - Flash Starfield

    Hi I was wondering if someone could help me with this one.

    I'm following this tutorial http://orangesplotch.com/blog/flash-...ield-tutorial/ that is about creating a flash starfield.

    And it's all good, but what I want to do is be able to have multiple "star" movie clips that fly out (i.e, different shapes and different colours) I was wondering if any one could help me with the action script to do this.

    I'm
    Attached Files Attached Files

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    multiple as in different looking clips?

    the color shouldnt be an issue..

    but hanvent looked at the code to see how its done.. (for adding in multiple clips to use)

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    replace this line:

    Code:
    var curStar:MovieClip = universe_mc.attachMovie("star", "star_"+i, i);
    with this:

    Actionscript Code:
    shapes = ["star", "square", "circle"];
    randomNum = Math.round(Math.random()*shapes.length);
    var curStar:MovieClip = universe_mc.attachMovie(shapes[randomNum], "shape_"+i, i);

    where in the shapes array, you add the linkage names of the different movieclips in your library. For different colors, after the last line above, add this:

    Actionscript Code:
    randomColor = new Color(curStar);
    randomColor.setRGB(Math.random()*0xFFFFFF);

    Hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    2
    Quote Originally Posted by Nig 13 View Post
    replace this line:

    Code:
    var curStar:MovieClip = universe_mc.attachMovie("star", "star_"+i, i);
    with this:

    Actionscript Code:
    shapes = ["star", "square", "circle"];
    randomNum = Math.round(Math.random()*shapes.length);
    var curStar:MovieClip = universe_mc.attachMovie(shapes[randomNum], "shape_"+i, i);

    where in the shapes array, you add the linkage names of the different movieclips in your library. For different colors, after the last line above, add this:

    Actionscript Code:
    randomColor = new Color(curStar);
    randomColor.setRGB(Math.random()*0xFFFFFF);

    Hope this helps
    Thanks for the info Nig_13, worked perfectly!

    Cheers again!

  5. #5
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,836
    You could use as to generate the stars to begin with. Isn't too hard to do.
    .

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    @swak: that's not what he wanted. He simply wanted to add more movieclips to the star moveclips with random properties, and besides, drawing that start with drawingAPI would take a lot more time and piles of code, and most importantly, precision to draw the star correctly by imagning it in your mind as you code it. Why go through all that hassle, when you can just draw a star using the polygon tool?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,836
    hmm, I was thinking of just a circle for the star. Oh well. Sorry for not reading properly.
    .

Tags for this Thread

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