Forums: Flash:

 

Why isn't this simpler?

first
 

DjUtopia Why isn't this simpler?

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.

IM N UR MOCKA ST34L1NG UR B34NZ!!1!

quote
 

DjUtopia

Basically I want something akin to what Baron Ruhstoff has here: rocket60.com/#/work

IM N UR MOCKA ST34L1NG UR B34NZ!!1!

quote
 

baron ruhstoff

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

 

DjUtopia

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.

IM N UR MOCKA ST34L1NG UR B34NZ!!1!

quote
 

Storm

book_head.onRollOver = over;
book_head.onRollOut = out;

case sensitive

 

DjUtopia

I had those capitalized in the flags too, but I started from scratch and I think I have it.

Thanks!!

IM N UR MOCKA ST34L1NG UR B34NZ!!1!

quote
 

baron ruhstoff

My first thought was the case as well, but since you weren't reporting any compiler errors... shrug.gif

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");
}

 

JLM

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);
}

 

JLM

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/

 

JLM

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);
}

 
first
 

Forums: Flash: Why isn't this simpler?

 
New Post
 
You must be logged in to post