answersLogoWhite

0


Best Answer

In Flex, you access a private variable by calling it from within that class. Remember, the "private" modifier means it cannot be directly accessed outside of the class you declare it in (note I say "directly accessed" you can indirectly access it via public functions which I will show below).

Example:

declare your variable at the top of your class like this:

private var myVariable:String;

Then, inside one of your functions of that class, you can access the variable and/or assign it this way:

public function changeMyVariable(value:String):void {

// sets the private variable to a custom string

myVariable="test String";

trace("myVariable is set to "+myVariable);

// sets the private variable to the argument passed in

myVariable = value;

trace("myVariable is now set to" +myVariable);

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you access private variable in flex?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a default access specifier for variable in c sharp?

Default access specifier in c# is private. if you don't specify it automaticaly takes it as private.


Which is public to all access class or struct or function or variable?

The default access specifier for a class is private. The default access specifier for a struct is public. It does not matter if it is a function or a variable.


What is the difference between a global variable and a private variable?

The accessibility. The global one: almost everywhere in the code may reference to the global variable directly. The private variable, is private to the declaring module (class, method, assembly) only. Outside of that module has no access to it directly.


What specifies private access modifier and private base class?

A private variable is something that is not visible outside the class. A private class is one that cannot be inherited


What kinds of access can a class member have?

Public, protected and private access members.


Java Which access modifier is preferred for instance variables?

Usually Private is the preferred access modifier for instance variables. Benefits: 1. No other class can access this variable directly. They can do only through the getter/setter methods 2. Only the methods in that particular class can use this variable


What is the purpose of public in java programming?

Public, Protected, and Private specify what has access to a routine or variable. Public is the most generous, meaning that variable or routine can be accessed from both inside and outside that program. Protected means that the variable or routine can be accessed broadly within the program, but not from outside. private means that variable or routine is only accessible to routine it is part of.


Which is java default access specifier?

There is no such thing as an access specifier in Java. There are access modifiers.The default access modifier if unspecified is to allow access to classes in the current package only, except within an interface where the default is 'public'


What is difference between struct variable and class object?

structure variable can access the variable but class object can access the function also


Is it possible to access the private variable in CPP from outside the class?

Private variables can only be accessed from outside of a class by using any public function of that same class. Or this can be accomplished by using Friend functions.


Is it true default access modifire?

Default access modifier is package. So when you want a method or object variable to be visible within a package, you don't have to insert an access modifier. For public, private or protected, you need to metion them in your java code.


What is Intel Flex Memory Access?

Intel® Flex Memory Access facilitates easier upgrades by allowing different memory sizes to be populated and remain in dual-channel mode.