|
-
[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
-
Intermediate Game Dev
I believe this should work:
PHP Code:
function buttonAction(buttonName:MovieClip, buttonMove:String) { _root[buttonName].gotoAndStop(buttonMove); }
aboutButton.onRollOver = function() { buttonAction(aboutButton, over); };
OR
PHP Code:
function buttonAction(buttonName:MovieClip, buttonMove:String) { buttonName.gotoAndStop(buttonMove); //You forgot the "o" here }
aboutButton.onRollOver = function() { buttonAction(aboutButton, over); };
Needs an update... 
-
Registered User
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|