0
votes

As the title suggests, I am trying to create a function in Actionscript 2 that calls for a value and function but I can't seem to get it to use the function. Here is my code.

function fadeOut(seconds, callBackFunction){
_root.fader.activated = true;
_root.fader.secs = seconds;
if(fader.box._alpha >= 100){
        callBackFunction();
        trace("This part of the code is being called");
    }
}

Then this is how I call the function

function BlankFunction(){
        trace("working");
    }
_root.fadeOut(5, BlankFunction);

So I get the trace saying "This part of the code is being called" but i'm not getting "Working" from the BlankFunction used as the callback. Is there a possible way to create a function in AS2 that calls for a callback function?

1

1 Answers

2
votes

You can call it using callBackfunction.call(null). The null specifies the target of this within the called function. See also http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001074.html

I suggest typing it as :Function in the parameters of fadeOut as well: function fadeOut(seconds:Number, callBackFunction:Function)