Reputation: 1650
I would like to know, in Flex 4.5.1, if there is a way to create a static variable in a member function, something like bellow:
public function myFunction():void {
static test:Object = null;
}
Thanks for your answers.
Upvotes: 0
Views: 791
Reputation: 14221
You can't declare class members inside functions but you can only initialize them there. Why not declare it outside function?
private static var test:Object;
public function myFunction():void {
test = null;
}
Upvotes: 1
Reputation: 20230
No, you have to define static variables in a class, but you can assign a value later in your function.
public class MyClass {
private static var test:Object;
public function myFunction():void {
test = new Object();
}
}
Upvotes: 2