ActionScript Writing Pattern on Frame

ActionScript Writing Pattern on Frame
Both ways of writing the script in last post, that is writing the script in the button and in the movieclip, can be written in any other form of writing, script placed inside a frame. The main thing to remember in writing action on the frame is an instance name. Instance name is one of the most important identity in a flash that distinguish between one object with another object.


Naming rules of instance name are:
  • Instance Name can be equal with symbol name.
  • Instance Name may not use spaces, dots, and other punctuation.
  • Using same name with a command in flash not allowed, for example: object, level, break and others.
  • Not allowed to use numbers only for instance name, but an instance name can be followed by number. Wrong example: 12, 13, and other, Right examples: ball1, ball_2 and other.
  • There should be no same instance name.
  • To simplify writing the script, you can add "_mc" to movieclip symbol and "_btn" to button symbol. Example: "Ball1_mc", "button1_btn".
  • Two or more same symbol may be used, but must have different instance name.

How to write action on the frame is as follows:
  • Create circle object with oval tool. Select object that we make then convet to symbol by pressing F8 (menu insert>convert to symbol). Choose Movie Clip in Type option then type ball_mc in name option. 
  • Click ball in the stage, then open instance panel and type “ball” in instance name.
  • Create a new layer then change name to action, then rename layer 1 to ball. Adding new layer we’ll ease us in action writing on frame, thus will not bother other object.
  • Click frame 1 in action layer, open action panel (press F9 or menu windows>action if action panel is not opened), then type :
ball.onEnterFrame = function() {
//move object to right
this._x += 10;
};
  • Run Movie by press CTRL+Enter, so we can see the same result that we create in movie clip action writing.


The explanation of writing script in frame :
  • Writing script in frame have 3 type, that is writing in a movie event block or mouse event, example onEnterFrame=function(){ and writing without movie event or mouse event, then the third writing type is combination of both type, example will show in next post.
  • Basically writing action in frame same with writing script in movie clip, but in frame there is function() script in use of instance name.
  • Note the difference between the writing on the frame and the writing on moviclip here:

Line 
In Frame
In Movie Clip
Different
1
ball.onEnterFrame =function{
onClipEvent(enterFrame){
Changes in writing from movie clip to the frame is the use of instance name before movie events and the use of  function () script
2
//Moving object to right
//Moving object to right
Comment line is same in all writing patern
3
this._x+=10;
_x+=10;
use of this command must write in frame
4
};
}
for writing in frame, in the end of movie event function closed by ";"

  • If we want write action button in frame, then that we must change is : movie event change to mouse event.
    Example : button_btn.onRelease=function(){};.

Advantage of writing script in frame:
  • Compare with writing script in movie clip that is complicated, writing script in frame is more easier for programmer who familiar with other programming language like C++, Java, Delphi or Basic.
  • Easy to write certain function or looping command which frequently used.
  • Because all of script written in frame, so if we want check action of all object will be easier without select each object (movie clip).

Post a Comment

0 Comments

-------- MASUKAN KODE IKLAN 1 --------
-------- MASUKAN KODE IKLAN 2 --------
-------- MASUKAN KODE IKLAN 3 --------
To Top