Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / April 2005



Tip: Looking for answers? Try searching our database.

myFunction.apply() issues... can anybody tell me what I'm doing wrong?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EricNY523 - 30 Apr 2005 18:02 GMT
I'm using the Function.apply() method to send a dynamic number of arguments to
another function, and i'm running into much frustration.... it seems, whenever
I send an argument, it will trace the argument, but execute nothing else inside
the function, but... if the argument is Undefined, everything else runs fine...
I have no clue what is going on. can anybody help me with this?

My code is below:

/* ===== This is all inside of a class ===== */

var myDelay:Number = 1000;             // Delay in ms
var myString:String = "test string";         // A Test Variable to Pass Around

// interval_int = setInterval
(this,FunctionToRun,delayAmt,intervalToClear,functionToRunAfterDelay,parameter1,
parameter2,...)
delay_int =
setInterval(this,"DelayRun",myDelay,"this.delay_int",myFunction,"test string")

private function DelayRun (delayInterval,functionName:Function) {
        clearInterval(eval(delayInterval));
        arguments.shift();        // Remove the DelayIntrval that was Cleared.
        arguments.shift();        // Remove the FunctionName Argument
       
        functionName.apply(null,arguments);
}
               
private function myFunction(testArg) {
        trace("Test: " + testArg);                // Traces Argument when its Sent
       
        RunAnotherFunction();                // Only runs when testArg is NOT sent
}
EricNY523 - 30 Apr 2005 18:32 GMT
The problem was in this line:

functionName.apply(null,arguments);

It needed to be:
functionName.apply(this,arguments);

Now... would anybody be able to explain why this is? b/c I just tried it out
of dumb luck.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.