ActionScript Tutorials and Code


Fading In Flash

Fading Objects



This tutorial will teach you how to fade symbols along the timeline which can as you probably well know create some fabulous effects used in the motion picture industry.

Step1:
Create a New flash Document in the standard document dimensions 550px width and 400px height.

Step2:
Use the Text Tool to create a Static Text Box with the text saying something like “Now you see me now you don’t”.

Step3:
Right Click the text box and select convert to symbol from the context menu.

Step4:
Click on frame 10 and press the F6 key which is used to create a new keyframe.

Step5:
Now click on the dropdown box entitled colour: with the value of none and change the value to alpha which will show another box with a percentage click this box and type 0 then hit enter.

Step6:
Click on frame 1 and select Insert->Create Motion Tween

Step7:
You have just mastered fading out an object to fade in you would hae frame one with a alpha effect of 0% and the end of the tween frame with a value of 100% or with the default alpha settings

Alternative Step1:
Create a New flash Document in the standard document dimensions 550px width and 400px height.

Alternative Step2:
Use the Text Tool to create a Static Text Box with the text saying something like “Now you see me now you don’t”.

Alternative Step3:
Right Click the text box and select convert to symbol from the context menu and select MovieClip as the type of symbol.

Alternative Step4:
Now in the properties panel assign the MovieClip the name "fader".

Alternative Step5:
Create a rectangle box from the shape tools. Then Right click and convert to a Button Symbol.

Alternative Step6:
Go to the Actions Panel(F9) while focused on the rectangle box.

Alternative Step7:
Enter The Following code


on(press){
fader._alpha = 0;
}


Alternative Step8:
You have just experienced how to make objects invisible in flash at runtime. This can be done for forms and even NPC's in games. Have Fun and don't be afraid to play around.

Convert hexadecimal value to RGB

  1. function ConvertToRGB(hexNum:Number)
  2. {
  3.    var rgbObj:Object = new Object();  
  4.    var rgbObj .r = hexNum >> 16;
  5.    var tmpVal = hexNum ^ r << 16;
  6.    var rgbObj .g = tmpVal >> 8;
  7.    var rgbObj .b = tmpVal ^ g << 8;
  8.    return rgbObj;
  9. }

    Utilizing guide layers

    Using Guide Layers



    Guide layers are very useful when creating a professional movie. They help you ensure that everything is where it should be. You can use a grid and snap objects to it or you can create your own Guide layer. Guide Layers Also Have Good Application for flash game design for non AI oriented Non-Playable Characters (think Sonic1).

    Step1:
    Create a New flash Document in the standard document dimensions 550px width and 400px height.

    Step2:
    Use the Oval Tool to create a small Circle. Once you have created the circle use the Black Arrow selection Tool to select the Entire Object. Once this is done right-click the object and convert to a symbol.

    Step3:
    Now select Layer 1 and click the add guide layer button.

    Step4:
    Lock Layer 1 and select the Rectangle Tool. Set the fill colour of the rectangle to transparent but give the outline a colour

    Step5:
    Select frame 20 and press F6 and then lock the guide layer and unlock Layer1 then select frame 20 again and press F6

    Step6:
    Click on frame 1 and select Insert->Create Motion Tween. Now move your symbol to the top Left corner of the square.

    Step7:
    Now click on frame 5 press f6 and move the object to the top right corner of the square. Now on frame 10 press f6 and move the object to the bottom right of the square. Finally press f6 on frame 15 and move the object to the bottom left of the square.

    Step8:
    Press the Enter Key and sit back and watch your animation.

    Reference: http://www.geekpedia.com/language22_ActionScript.html


Written by