Static methods and properties are really useful for the kind of things you might leave on the root or in the global scope. For example if you had a variable called "foo" and you need other classes to be able to access it you could put in a class like so...
class ExampleClass
{
private static var $foo;
public static function get foo ()
{
return $foo;
}
public static function set foo ( value )
{
$foo = value;
}
}
then when you need to access it import the class...
import ExampleClass;
then you can read the variable like this...
var i = ExampleClass.foo;
and set it like this...
ExampleClass.foo = "baa"
You can also have static methods too...
class ExampleClass2
{
public static function myMethod ( )
{
// do stuff
}
}
which you can call like this...
import ExampleClass2;
ExampleClass2.myMethod();
Main Topics
Browse All Topics





by: wildbrookmediaPosted on 2006-10-23 at 12:14:02ID: 17790876
functions and classes: http://proto.layer51.com/d efault.asp x .com/2005/ flash8-sou rcecodes/
m/Article/ tabid/54/A rticleID/r oot- and-sc ope-in-fla sh/Default .aspx .com/flash /8/main/ww help/wwhim pl/ common/ html/wwhel p.htm?cont ext=LiveDo cs_Parts& f ile=000013 10.html ides/conte nt.asp?g=f lash& seqNu m=145&rl=1
learn from the best: http://blog.andre-michelle
about root: http://www.actionscript.co
writing custom classes: http://livedocs.macromedia
http://www.informit.com/gu