I’m trying to call a function after I load some XML into Actionscript, and I’m just wondering how I call that function. Example:
//Function Declarations function parentFunction() { function callMe() { textField.text = 'lawl'; } }
Now, how do I call the ‘callMe()’ function in a different part of the code, like an onRelease function?
on(release) { callMe(); //doesn't work parentFunction().callMe(); //doesn't work parentFunction.callMe(); //doesn't work }
ActionScript 2.0 is just so wonky! Any ideas?
Are you forced to declare callMe inside of parentFunction? I assume so because otherwise you would just do
function parent() { } function callMe() { }
To be clear, a function can’t own another function unless you provide some scope for that function to live in.
So in JavaScript, you would do this by using the prototype object to declare the callMe function as a method of the object that parentFunction returned.
http://www.howtocreate.co.uk/tutorials/javascript/objects
For ActionScript, read this article on Adobe’s website: http://www.adobe.com/devnet/flex/articles/as_collections_03.html
EDIT: After some more reading it appears the way you did things, you are actually declaring callMe as a private function. See this article which should make the whole private/public javascript issue a lot more understandable.