A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Am I doing this right?

  1. #1
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476

    Am I doing this right?

    I've got this button calling up a function and I'm passing another function as a variable. This is the button code:
    PHP Code:
    _root.rightButtonMC.goButton.onRelease = function() {
            
    _root.loadSection(_root.bounceLeft());
            
    //_root.bounceLeft();
        
    }; 
    Here's the other code I'm calling up with it. Even if I take out the "bump" variable, it plays "_root.bounceLeft()" no matter what.
    PHP Code:
    loadSection = function(bump){
        
    _root.frontMC.play();
        
    _root.frontMC.onEnterFrame = function(){
            if(
    _root.frontMC._currentframe == 4){
                
    _root.frontMC.stop();
                
    bump;
                
    _root.frontMC.onEnterFrame null;
            }
        }


  2. #2
    Maybe i'm being dense but your code doesn't seem to make sense.

    When you have :
    code:
     _root.rightButtonMC.goButton.onRelease = function() {
    _root.loadSection(_root.bounceLeft());
    //_root.bounceLeft();
    };



    It WILL run the _root.bounceLeft() function. It's expecting to pass to _root.loadSection() whatever _root.bounceLeft() returns.

    What you need instead I think is this:
    code:
     _root.rightButtonMC.goButton.onRelease = function() {
    _root.loadSection("_root.bounceLeft");
    //_root.bounceLeft();
    };



    then you need:
    code:
     loadSection = function(bump){
    _root.frontMC.play();
    _root.frontMC.onEnterFrame = function(){
    if(_root.frontMC._currentframe == 4){
    _root.frontMC.stop();
    eval(bump);
    _root.frontMC.onEnterFrame = null;
    }
    }
    }



    Give that a go!
    ----------------------------------
    http://www.benhull.co.uk

  3. #3
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476
    That caused the bounceLeft to not run, but it did return a trace of "bounceLeft()" for "bump". It seems the eval(bump) didn't make it run. Thanks for the help. I'm in a teeny bit over my head and I'm kindo of figuring this out as I go. I'm not really a programmer.

  4. #4
    Ok, I've sussed it...

    code:

    _root.rightButtonMC.goButton.onRelease = function() {

    _root.loadSection("_root.bounceLeft");

    //_root.bounceLeft();

    };



    loadSection = function(bump){

    _root.frontMC.play();

    _root.frontMC.onEnterFrame = function(){

    if(_root.frontMC._currentframe == 4){

    _root.frontMC.stop();

    eval(bump)();

    _root.frontMC.onEnterFrame = null;

    }

    }

    }

    ----------------------------------
    http://www.benhull.co.uk

  5. #5
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    Sorry to interrupt but why did you write eval(bump) (); ? with two parentheses?

    Edit: oh yeah now I get it lol, cus it's a function it needs the parentheses and only the name is stated in "bump"
    Last edited by PhobiK; 08-04-2005 at 03:15 PM.
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

  6. #6
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476
    You're a genius! thank you very much.

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