Share this Page URL
Help

Chapter 12. Functions > The _global Identifier - Pg. 254

Functions _root.myFunction () _parent.myFunction() _parent._parent.myFunction() _root.myMovie.myFunction() //invokes //invokes //invokes //_parent //invokes //located the function the function the function timeline the function on the _root in the _root timeline in the _parent timeline in the _parent of the in myMovie which is timeline 254 As mentioned before, using dot syntax is no longer a necessity when trying to reach a function from a timeline that's different from the one it was created on because of the _global identifier. The _global Identifier The global identifier, which was introduced back in Flash MX, has the power to allow functions and other data types to be reached from the entire movie. It can transform any variable, array, function, or object into a globally available data type. This way, you can create all the variables, functions, and whatever else you need to call upon in the main timeline and reuse them. The generic template looks like this: _global.datatype We could go on for several pages talking about this object, but for this chapter, we'll use it in the context of functions. Therefore, let's look at the generic template: _global.functionName = function(parameters:ParameterType):ReturnType{ //script to be run } Now that you have seen the general form of a global function, let's jump right in and create one.