I am trying to have a button that grows on mouseover, then shrinks on mouseout.
WTF? Its killing me.
I have this in AS2, with "over" and "out" being the proper frames, but nothing is happening.
book_head.onRollOver = Over; book_head.onRollOut = Out;
function over() { this.gotoAndPlay("Over");
}
function out() { this.gotoAndPlay("Out");
}
Anyone have an easy answer?
-edit-
I am programming dumb, so I'm sorry for the elementary question.
Basically I want something akin to what Baron Ruhstoff has here:http://rocket60.com/#/work
It's been a while since I've done anything in AS2 so I might be* missing something, but have you confirmed that the handlers are firing?
*most definitely am
No, I'll take a look.
I am not opposed to doing it in AS3, it just seemed more complicated, but if that is what would be better I am down.
book_head.onRollOver = over; book_head.onRollOut = out;
case sensitive
I had those capitalized in the flags too, but I started from scratch and I think I have it.
Thanks!!
My first thought was the case as well, but since you weren't reporting any compiler errors... :shrug:
fyi:
book_head.addEventListener(MouseEvent.MOUSE_OVER, onOver); book_head.addEventListener(MouseEvent.MOUSE_OUT, onOut);
function onOver(me:MouseEvent):void{ book_head.goToAndPlay("Over"); }
function onOut(me:MouseEvent):void{ book_head.goToAndPlay("Out"); }
In AS2 delegate can be useful and using a special one allows you to pass more information.
inside your main class.
import com.dynamicflash.utils.Delegate;
private function setupRollOvers() { book_head.onRollOver = Delegate.create( this, goto, book_head, 'Over' ); book_head.onRollOut = Delegate.create( this, goto, book_head, 'Out' ); }
private function goto( mc: MovieClip, frame: String ) { mc.gotoAndPlay(frame); }
to save you searching for the Delegate as DjUtopia may not be used to using opensource classes, below is the class used, I think the author is the creator of several flash books, you don't really need to understand the code just how to use the static method.
/*
Delegate.as v1.0.1
Copyright (c) 2005 Steve Webster
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
class com.dynamicflash.utils.Delegate { public static function create(target:Object, handler:Function):Function { // Get any extra arguments for handler var extraArgs:Array = arguments.slice(2);
// Declare delegate variable (MTASC compatibility)
var delegate:Function;
// Create delegate function
delegate = function() {
// Augment arguments passed from broadcaster with additional args
var fullArgs:Array = arguments.concat(extraArgs, [delegate]);
//var fullArgs:Array = arguments.concat(extraArgs);
// Call handler with arguments
return handler.apply(target, fullArgs);
};
// Return the delegate function.
return delegate;
}
}
you will need to put it in the correct folder structure.
com/dynamicflash/utils/
And if you wanted to use AS2 haXe you could use callback, I have not used as2 haXe so may not be quite right.
private function setupRollOvers() book_head.onRollOver = callback( this, goto, book_head, 'Over' ); book_head.onRollOut = callback( this, goto, book_head, 'Out' ); }
// maybe (frame, mc) I am not sure. private function goto( mc: MovieClip, frame: String ) { mc.gotoAndPlay(frame); }