A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: sending parameters with onEnterFrame

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    102

    sending parameters with onEnterFrame

    function myFunc(param1,param2) {
    trace(param1 + "_" + param2);
    }

    myMovieClip.onEnterFrame = myFunc;

    ////////

    Is it possible to send the parameters in the code above???
    If you try:
    myMovieClip.onEnterFrame = myFunc("monkey","donkey");
    then it won't work... :-(
    /Tommy Salomonsson
    www.salomonsson.se

  2. #2
    Senior Member stoc's Avatar
    Join Date
    Nov 2001
    Location
    Romania, Arad
    Posts
    428
    I suggest you to store those vals in global vars ... and to use it from there ... :

    code:

    function myFunc() {
    trace(_global.param1 + "_" + _global.param2);
    }

    _global.param1 = param1
    _global.param2 = param2
    myMovieClip.onEnterFrame = myFunc;



    ...and i think it is not possible;
    if you still wanted to use that function with parameters you can use setInterval :

    code:

    framerate = 30 /// u can pseudo set here the framerate
    milisec = int(1000/30)
    interval = setInterval(myFunc,milisec,param1,param2)

    function myFunc(p1,p2){
    trace(p1 + "_" + p2);
    }


    Stoc Digital Studio - Web Applications Development
    http://www.stoc-studio.ro

  3. #3
    FK Romeo martiansam's Avatar
    Join Date
    Oct 2001
    Location
    Bombay, India
    Posts
    223
    Hi there it will work. You need to call the function defined within the onEnterFrame function.

    Code:
    function myFunc(param1,param2) {
    	trace(param1 + "_" + param2);
    }
    
    
    this.movieclipname.onEnterFrame = function(){
    	myFunc("monkey", "donkey");
    }
    Hope this helped.
    sameer rao

    there...you see!!

  4. #4
    Senior Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    102
    Thanks for your answers.

    I think it's strange that you have to use workarounds to send parameters to a function...

    hmmm...
    /Tommy Salomonsson
    www.salomonsson.se

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center