Flash and ActionScript 3.0

____________________________________________________

The Balloon Factory

The balloon factory is an interactive flash animation that the class experimented with to understand the basics of ActionScript 3.0. The animation consists of a balloon that can be filled or emptied at chosen rates and the option to allow the balloon to fly. There is also an option to stop the balloon to the desired size. These options are configured by attaching event listeners to the buttons. When these buttons are pressed a certain function is called that houses the code to complete the action. e.g. when the fill balloon button is clicked this code is called

balloon2_mc.height = inflation * 300;
balloon2_mc.width = inflation * 220;

This makes the balloon appear to be filling but in fact it is increasing the width and heights. This is fine if the user decides to let the balloon fill at the generic pace. If they want to change the pace while the balloon is filling or emptying the following code is called.

if(inflation < 1){ inflation += (fillRate * 0.1); balloon2_mc.height =
inflation * 300; balloon2_mc.width = inflation * 220; firstrun==true; }}

if(emptying==true){ if(inflation > 0.1){
inflation -= (fillRate * 0.1);
balloon2_mc.height = inflation * 300;
balloon2_mc.width = inflation * 220;

This program is simple but quite clever as acute calculations are applied to variables that adjust widths, heights and positions to represent actions of a real balloon.

 

____________________________________________________

Mini Sequencer

This flash example is an experiment with sound. To make this simple sequencer we were introduced to particular classes of sound in as3. These included:

Sound Class – This is the main class in which a sound will actually reside. This class is the starting point of any sound related program and is used to start playing a sound.

SoundChannel Class – A sound can be played through a sound channel which provides additional controls over a sound object, the most basic of these additional controls is the ability to stop the playback of a sound.

SoundTransform Class – This class is responsible for altering sound volume and sound panning (manipulating the balance between the left and right speakers).

SoundMixer Class – This class has global control over all sounds played in the Flash player. It’s most basic function is to stop all playing sounds regardless of source.(Chi, B. 2010)

The code below loads and plays 3 mp3′s into the program when the play buttons are clicked. There are also volume controls attached to the sliders which are a component of flash itself. if the check boxes are clicked it allows the sound to loop itself over and over. This is done by using a technique known as recursion. This is where a function has the ability to call itself repeatedly. example below.

function soundComp1(e:Event):void{
c1.soundTransform = trans1;
trans1.volume = vol1;
s1.play();
if(loop1==true){
in1_mc.visible=true;
c1.addEventListener(Event.SOUND_COMPLETE, soundComp1);
}
else{
in1_mc.visible=false;
c1.stop();
}
}

____________________________________________________

Small Game Experiement

This is a small interactive game where the user can use the arrow keys to fly an artist character around the screen to find puzzle pieces of a painting. This was done by creating a series of timers are started when a particular key on the keyboard is pressed. Using timers allows the user to continuously hold down the button to move the character rather than pressing it repeatedly. When a movie clip is rolled over by the character (using the hit test object function) The movie clip of the piece reveals itself and plays. Only when all 5 pieces are found can the game end. In furthering this game I would add another level where the user will piece the puzzle together.


____________________________________________________

The Ball Toss

The code below creates a simple interactive animation where the user can toss a ball. ActionScript has enabled the ball to react realistically the application has values such as Gravity and Virtical Damping. I have plotted the course of the ball using x and y coordinates. The speed is then decremented in relation to gravity and damping when the ball hits the floor the first time and so on.

____________________________________________________

Rocket Launch

The code below creates another interactive animation where the user can control the flight of a rocket. This is done quite simply. When a button is pressed the corresponding action is called within the function. e.g. if the up button is pressed then the y coordinate is decreased. and visa versa for down. The x coordinate is manipulated for left and right.

____________________________________________________

Magnifying Glass

This is a tutorial I completed that was available at flash perfection. this tutorial demonstrates use of the displacementMapFilter. The component color channels for X and Y are set this dictates which colorchannels in the control map the filter will listen to. The code below determines how the pixels will react if they are pushed further than the image boundaries.

DisplacementMapFilterMode.COLOR / DisplacementMapFilterMode.WRAP / DisplacementMapFilterMode.CLAMP / DisplacementMapFilterMode.IGNORE

Then the position is set where the filter affects the image.

Scridb filter

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>