2 Replies Latest reply on Feb 2, 2007 6:15 AM by Jan-Paul K.

    random stars emitting from a point

    xenolith5
      Hi, I'm V new to coding and need a little guidance. I don't want the code written for me just an outline of what I need to do for the following:
      I want to have a point on the stage where stars will emit from. The stars will have a bit of a wiggle!! and fade out after a set distance. Almost like a sparkler.
      I think I need to create a mc of the star with an instance name then use attachmovie to place it on the screen at a set point from the library. I think I then need to create an onEnterFrame function which uses Math.round to create a point for the star to fly to.
      If the star mc had a wiggly motion path and a tweened alpha then in my head this would cause the star to fly to the random point wiggling as it goes and fade out.
      Then I need to repeatedly call this function. If I then place multiple instances of this mc on the stage, each instance should move in random directions.
      So anyone who wants to give a brief outline for me to play with is a star!!
        • 1. Re: random stars emitting from a point
          Jan-Paul K. Level 1
          It seems you pretty much now what to do, I guess I would have the same apporach as you do with this task:

          - create the star MC (just a simple image basicaly, one frame only)
          - set linkage name for the star MC and check the export flag
          - create a function that:
          -- uses attachMovieclip to position an instance of the star on the predefined emitting-point
          -- creates random target coords where the star should fly to
          -- creates 3 new Tween Instances that move the star to the X and Y Position and increases the size of the star
          - create a function that randomly calls the first function to create new stars

          thats it I guess :-)
          • 2. random stars emitting from a point
            Jan-Paul K. Level 1
            ok, here is a quick and dirty solution to your question, but it does not do any garbage collection, so you might add a Listener to one of the Tweens that removes the attached MC once it is faded out.
            Plus there must be a way to modify multiple properties of the mc in only one tween instead of creating 5 Tweens for each star. As I said, only a quick hack.

            Edit:
            Oh, of course for the code to work it requires an mc with the linkage id "star_mc"