Code+Examples+for+CLIPS+Scenes

Adding Fireworks
code format="actionscript" // CODE TO ADD FIREWORKS TO AN ACTIVITY import edu.clips.util.ubMath;

// create the sound for the fireworks fireworkSound = defineNewSoundEffect("shortfireworks", false, false); var numberFireworks:Number = ubMath.randint(0, 6); for (count = 1; count <= numberFireworks; count++) { // delay the start of the fireworks by count * 500 milliseconds timeoutInterval = setTimeout(this, "displayFireworks", count * 500, count); TimeOutsArray.push(timeoutInterval); } function displayFireworks(count1:Number) { // attach the firework movie; it will automatically play // there are 4 colours of fireworks in the library so randomly choose 1 colour to attach // randomly select _x and _y this.attachMovie("firework" + ubMath.randint(1, 4),       "firework" + count1 + "_mc",this.getNextHighestDepth,        {_x:200 + ubMath.randint(0, 350), _y:100 + ubMath.randint(0, 100)}); //start the firework sound at 50% volume fireworkSound.startSoundEffect(0,1,false,50); } code

Adding a Poof
code format="actionscript" // EXAMPLE OF CODE to ADD A POOF TO AN ACTIVITY

// attach the ub_PointPoof movie clip which is in the library this.attachMovie("ub_PointPoof","poof_mc",this.getNextHighestDepth );

/* when you need to call the poof, use the .Go( playSound:Boolean, newX:Number, newY:Number) function built into ub_PointPoof NOTE: You cannot attachMovie AND immediately call the poof_mc.Go; the attachMovie has to happen at least 1 frame before the first call to .Go*/

// will move the poof to (x,y) = (100, 150), // and play the "poof" sound effect as it poofs onscreen

poof_mc.Go( true, 100, 150 );

// often this is placed inside a button onRelease event, // or some function that is called when things should be deleted from the stage code