Call Functions within Function - Flash Actionscript 2.0

I'm attempting to call a function after I load some XML right into Actionscript, and also I'm simply asking yourself just how I call that function. Instance:

//Function Declarations
function parentFunction()
{
    function callMe()
    {
     textField.text = "lawl";
    }
}

Now, just how do I call the "callMe()" function in a various component 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 so rickety! Any kind of suggestions?

2
2022-06-07 14:30:43
Source Share
Answers: 3

Of training course a function can "own" an additional function. this is ECMAScript bear in mind. Simply proclaim a variable within your function and also assign a function to it. You can after that call your function by utilizing the "call" method.

function foo() trace ("foo") ;

var bar = function()
{
    trace("bar");
};

bar.call();

foo() ;

0
2022-07-11 01:21:36
Source

I'm a bonehead. I neglected the entire "a function can not possess an additional function" point, so I identified an additional means to do it. Many thanks!

0
2022-06-07 14:45:02
Source

Are you compelled to proclaim callMe within parentFunction? I think so due to the fact that or else you would certainly simply do

function parent() function callMe()

To be clear, a function can not possess an additional function unless you give some extent for that function to stay in.

So in JavaScript, you would certainly do this by utilizing the model challenge proclaim the callMe function as a method of the object that parentFunction returned.

http://www.howtocreate.co.uk/tutorials/javascript/objects

For ActionScript, read this write-up on Adobe is internet site: http://www.adobe.com/devnet/flex/articles/as_collections_03.html

EDIT: After some even more analysis it shows up the means you did points, you are in fact proclaiming callMe as a exclusive function. See this write-up which needs to make the entire private/public javascript issue a whole lot extra easy to understand.

2
2022-06-07 14:44:03
Source