Basic actionscript on Aobe Flash

In this post, we will discuss the basics of writing action scripts. Here we are not all correct tutors, so we need your criticism and suggestions, and if there are errors in writing or submission, please tell us. Listen carefully

{getToc} $title={Table of Contents}

Writing Actionscript

Adobe Flash provides an action panel for writing actionscripts. To bring it up you can press f9 on the keyboard or select the window menu > actions so that the action panel will appear. Keep in mind that in the default settings the action panel has appeared, usually parallel to the properties. To detect whether or not the action panel has appeared, you can choose window > action. Make sure the action option is ticked or not, if it is checked, it means that the action panel is already active.




Action Script is a programming language used by Flash software to control objects or movies contained in Flash. Actually Flash can also not use ActionScript in its use, but if you want more complex interactivity then ActiosScript is needed.

style="font-family: inherit;">Actionscript function

Action scripts have several functions or roles that can help in designing Flash sites or movies, including:
a. Creating a site navigation system
This relates to how the Action Script can manage the user to explore the site or program that has been created. Thus, the site animation that has been created is not just a mere “advertising film”, unless it is really like that (in the case of cartoons using Flash).
b. Adding interactivity with users
With the action script the user can interact with every element in a Flash movie, whether it’s a movie clip button or text.
c. Creating a dynamic site or Program

/>

ActionScript 3.0

In June 2006, ActionScript 3.0 debuted with Adobe Flex 2.0 and its corresponding player, Flash Player 9. ActionScript 3.0 is a fundamental restructuring of the language, so much so that it’s completely different from using virtual machines. Flash Player 9 contains two virtual machines, AVM1 for code written in ActionScript 1.0 and 2.0, and AVM2 for content written in ActionScript 3.0. Actionscript 3.0 adds limited support for hardware acceleration (DirectX, OpenGL).

/>

Object


An object is a data type such as sound, image, text, which is used to control the movie. All objects are part of a class. Objects in Flash can range from visible images to something abstract (not visible), such as dates, data, or detection of mouse input. Objects can be recognized and used after first being given a name. The process of naming an object is called instantiating. In addition to defined objects, in Flash there are predefined classes consisting of objects that can be used in movies. Some of them, MovieClip, Color, Sound, Button, Stage, Text Field, and Text Format.

Based

on the location of the script, the type of ActionScript in flash is divided into 3, namely:

1. ActionScript on the frame

ActionScript on the frame is Actionscript that is placed on the frame, or also often called FrameScript. This FrameScript can only be done on a keyframe or blank keyframe. To see the frame that has been given a script, there is a small ‘a’ sign indicating the existence of a script.

2. ActionScript on MovieClip
ActionScript embedded in a MovieClip is often called MovieScript. the thing to remember is to make movieScript, of course there must be a MovieClip where we put the ActionScript. MovieClip has the following language (syntax).
onClipEvent(event) { command }
The meaning of the above movieScript syntax is:


The word ‘onClipEvent’ indicates that this command is intended for the MovieClip where the script is placed.
the word ‘event’ indicates events that occur in the MovieClip. Actually, there are 9 events in MovieClip including: load, enterFrame, unload, Mouse up, Mouse Down, Key down, Key up, and data. and enter Frames. The word ‘command’ denotes the commands that can be given to the MovieClip.

3.

ActionScript on Button


The thing to remember is ActionScript on the button, of course there must be a Button where to put the ActionScript. In general, the syntax used in writing ActionScript on a Button is almost the same as writing MovieScript. Pay attention to the following syntax;

on (event) { command }
The meaning of the movieScript syntax above is: The word ‘on’ indicates that this command is intended for the MovieClip where the script is placed and this is the main requirement for the script used on the Button. The word ‘event’ indicates the event that occurs on the Button. There are 7 events on the button, namely press, release, rollOver, rollOut, dragOver, dragOut, and keypress. However, only two events that are often used are press and release.

What is the use of ActionScript? ActionsScirpt has many uses, for example ActionScript can be used
for:
– Make great presentations
– Creating interactive Games
– Creating Online Games
– Creating an Interactive Web
– Creating interactive CDs
– Create Simulations and animations in learning
– ActionScript can also communicate with other programming languages ​​such as PHP and ColdFusion
– and many others..Object and Frame ActionsThe basic structure of an action
is: whenSomethingHappens(input) { doAction }

Control Mechanism on Objects with AS 3.0

The control mechanism is realized by using feedback, which samples the output. This feedback is used to control both the input and the process. The goal is to arrange for the system to run according to the purpose.

Setting Object Properties with AS 3.0

1. Use of the Trace command

The Trace command is used to display information in the Output panel. The Output panel is only used to test the running of the program, not as the main display of the program. The main display of the program is our stage.

2. Variable Declaration

The variables that will be used in our script must be declared first. Some types of variables that are often used include: TextField, Number, String, Array, Sprite, Shape, and MovieClip. We can also create our own variable type in the form of a Class object for our application. The variable declaration command has the general form:

var VariableName:VariableType;
or the following second method also gives the same result:
var VariableName:VariableType=newVariableType();
You can add the following program to your code to make “Hello World” appear on your Stage.
var mytext:TextField=new TextField();
mytext.text=”Hello World”;
stage.addChild(Mytext);

Continue to test the results of your program by pressing the keyboard Ctrl + Enter, then you will see the words “Hello World” on your Stage.

3. Events, Listeners, and Event Handlers

All user interactions in Flash are managed by “events.” Some examples of events are: mouse click, mouse move, keyboard input, file loading, and others. In this book, we will use many event settings to design user interactions. In ActionScript, an object can listen for events that occur to itself by using the addEventListener method on the object. This method takes two arguments, namely:

•What event will be listened to, for example MouseEvent or KeyboardEvent
•What function will I do when I listen to the event.


In our example, the line:Startbutton.addEventListener(MouseEvent.CLICK,pressButton); function pressButton(mevt:MouseEvent):void{ FUNCTION CONTENTS}

Has the following purposes:
The button with the instance name Start button will listen for the Mouse Click event (MouseEvent.CLICK)
•When the Start button is clicked with the mouse, the button press function will be called and executed. The pushbutton function is called an event handler. An event handler must be a function with one input value (eg in our example it is mevt:MouseEvent) and return no value (i.e. have an output type of void).




learning flash is easy!
On this page we will discuss in more detail about flash, from motion animation, framing, to action script. For beginners, this is perfect for you. Ok, continue to follow our discussion

RahmanCyber Tutorials

Editors who write various Useful Tutorials
http://www.rahmancyber.net

Facebook : /rahmancyber | Twitter : @RahmacyberNet



Create by Ipadguides in category of Blog