|
| You are here: Categories » Computers and technology » Flash
|
Something else that you will be seeing a lot of as you learn ActionScript is dot syntax. Dot syntax is a way of grouping objects and functions that is used in many object-oriented programming languages.
Here is an example of dot syntax. Suppose that you want to take the square root of a number. Flash has a built-in square root function. It is a part of a group of math functions called the math object. To use the square root function, you first have to use the name of the math object, which is simply Math. The name of the function is sqrt. So this is how you would use the math object's square root function:
var a = Math.sqrt(4);
Another common way to use dot syntax is to address a property of a movie clip. Suppose that you have a move clip named myClip and you wanted to determine its horizontal position on the screen. That would be the _x property of the movie clip. So the code would look like this:
var a = myClip._x;
You can also use dot syntax to reference global variables inside other movie clips. So if you have code in a movie clip and are using a global variable inside that movie clip, you can access it from the root level like this:
var a = myClip.myVariable |
|
Leave a comment or ask a question
|
|
Total comments: 0
Disclaimer
- The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
|
|
|
Using Mathematical Operators in ActionScript - You want to modify something over time, such as the rotation or position of a movie clip.
Use the compound assignment operators to change a variable or property in increments. Or, if increm (more...)
Enhancing Standalone Projector - You want to create an enhanced Standalone Projector with features such as borderless playback, custom titles, no Flash menus, and so on. Use a third-party tool such as SWF Studio or SWFKit to c (more...)
Creating Flash Buttons - Buttons are one of the three main types of symbols that you use in Flash. The others are movie clips and graphics.
Making a New Button
There are many ways to create a button. One (more...)
Bouncing Ball Script - Start a new Flash movie. Create a movie clip that has a ball graphic inside it.
You can name the instance of the movie clip, myClip, but our code will not depend on the name of the clip. (more...)
ActionScript: Creating Reusable Code - You want to perform a series of actions at various times without duplicating code unnecessarily throughout your movie.
Create a function and then call (i.e., invoke) it by name whenever you (more...)
3D Scaling with ActionScript - Although Flash is not capable of real 3D graphics, the kind seen in popular computer games, you can create the illusion of 3D by using scaling.
Scaling an object is a great way to give your (more...)
Movie Clip Scripts - Movie clip scripts, like button scripts, use handlers. Instead of using the on keyword that button scripts use, we will use the onClipEvent keyword. Here is an example of a movie clip script:
(more...)
Decoding an RGB Value - You want to extract the red, green, and blue components from an RGB value returned by Color.getRGB( ).
Use the bitshift right and bitwise AND operators.
You can extract the red, gre (more...)
|
|
|