PDA

View Full Version : Is it possible to pass a variable from MXML file to .as(Actionscript) file?


tanusree
09-24-2007, 11:16 AM
Is it possible to pass a variable from MXML file to .as(Actionscript) file?

If possible then in the Actionscript file how to access the variable?

Can anyone help me wiyth code example regarding this problem?

iptton
09-24-2007, 11:41 AM
in the MXML:
public var someVar:SomeType;


in as file:
import mx.core.Application;

//use the var
Application.application.someVar;

tanusree
09-24-2007, 01:29 PM
This code is not working.
It's giving the variable name is not found.

iptton
09-24-2007, 01:35 PM
I make a mistake........
someVar and somevar ....
notice the "v" and "V"....

atomic
09-24-2007, 01:47 PM
Don't know if you're really talking about an external .as file, but those are used at compile time, and not at run time...

tanusree
09-24-2007, 03:44 PM
This code is still not working.
It's still giving error.

tanusree
09-24-2007, 03:52 PM
Can anyone help me out to how to do it.

drkstr
09-24-2007, 04:18 PM
Your question doesn't make a lot of sense. What do you mean by "an action script file"? Do you mean a class created in Actionscript? If you post some code or tell us what you're trying to do, we will be able to tell you what you're doing wrong.

Best Regards,
...aaron

tanusree
09-24-2007, 07:41 PM
Yeah you are right. I want pass a variable from MXML file to Actionscript class & access it within the class.

dr_zeus
09-24-2007, 09:27 PM
Create a new variable or property on your ActionScript class and pass your variable through that.

myASClassInstance.myVariable = variable;

Obviously, if you need to detect changes, you should look into using binding.