The Dot Syntax

written by: Milan Midovich; article published: year 2007, month 06;


In: Root » Computers and technology » Flash » The Dot Syntax

Dutch French Spanish Portuguese Italian German Japanese Chinese Korean Russian Arabic Bookmark and Share this Article

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 

Disclaimer

1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here.

link to this article