Using the techniques learned from the Lesson 3 of CS4 ActionScript Assignment create a simple rocket movie clip with flames on and off as appropriate, add a button, add behavior so that half the time the button is clicked, the rocket launches, moving up the screen to the top then turning right to accelerate off screen. Once this is working, add behavior so that 20% of the time the rocket moves up then tilts right, moving at this new angle until it starts to leave the screen, then it tilts right again and moves down the screen. Finally, add behavior so that 30% of the time the rocket just sits on the launch pad with flames off. Name this file yourNameRocketLaunch.fla. Demo your product by the end of next class.

Making the rocket move up or accelerate up the screen is trivial -see below. Adding the complex behavior required here is a simple extension of the techniques used in lesson 3. This is non-trivial, some code snippets are provided to set a foundation. You will need to add an event listener and launch function for the button and based on random probabilities either call goodLaunch, tiltLaunch, or just have the rocket sit with flame off.

Desired behavior (press refresh on your browser.)

Some code snippets used to make the sample project above:

var speed:Number = 1;
var upRight:Boolean = true;
var tiltDown:Boolean = false;

var probability:Number = Math.random();

removeEventListener(Event.ENTER_FRAME, goodLaunch);//used in the launch function based on probability

rocket_mc.gotoAndPlay("flameOn");//used in the launch function based on probability
addEventListener(Event.ENTER_FRAME, goodLaunch);//used in the launch function based on probability

function goodLaunch(e:Event):void {
   if (rocket_mc.y > 10) {
      rocket_mc.y -= 2;
   } else {
      speed += 0.2;
      if (upRight) {
         var spin:Tween = new Tween(rocket_mc, "rotation", Elastic.easeOut, 0, 90, 1, true);
         upRight = false;
      }
      rocket_mc.x += speed;
   }
}

Below are two very simple examples that move rockets up with very simple use of ActionScript.
There is one Rocket in the library and two instances in Frame 1.

Note to get the rockets to move up
the screen is as simple as Frame 2 actions:
rocket_mc -= 2;
rocket2_mc -= 2;
Frame 3 actions:
gotoAndPlay(2);

To have the second rocket accelerate,
declare a speed variable in
Frame 1 actions:
var speed:Number = 1;
Then in Frame 2 actions add/modify:
speed += 2;
rocket2_mc.y -= speed;