A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [CS3] Functions not functioning

  1. #1
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219

    [CS3] Functions not functioning

    Can any one tell me why this don't work?

    function buttonAction(buttonName:MovieClip, buttonMove:String) {
    buttnName.gotoAndStop(buttonMove);
    }

    aboutButton.onRollOver = function() {
    buttonAction(aboutButton, over);
    };



    Thanks

    RSB

  2. #2
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    I believe this should work:

    PHP Code:
    function buttonAction(buttonName:MovieClipbuttonMove:String) {
    _root[buttonName].gotoAndStop(buttonMove);
    }

    aboutButton.onRollOver = function() {
    buttonAction(aboutButtonover);
    }; 
    OR

    PHP Code:
    function buttonAction(buttonName:MovieClipbuttonMove:String) {
    buttonName.gotoAndStop(buttonMove); //You forgot the "o" here
    }

    aboutButton.onRollOver = function() {
    buttonAction(aboutButtonover);
    }; 
    Needs an update...

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    unless over is a variable, it should be a string:
    code:

    aboutButton.onRollOver = function() {
    buttonAction(aboutButton, 'over');
    };


    A equivalent and cleaner way is using this:
    code:

    aboutButton.onRollOver = function() {
    buttonAction(this, 'over');
    };



    Notice that using _root is not recommended and if you're using array notation, buttonName can't be a MovieClip and should be a String instead.

  4. #4
    flash animator guy
    Join Date
    Oct 2006
    Location
    Daly City
    Posts
    219
    Thanks for the input.

    The problem was a dub one on my part.

    I was missing an "o" in the word button, and I needed the string argument being passed to be in quotes.

    As for the use of "this" that a good point.

    Thanks again

    rsb

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