Whats wrong with this?
myButton.onPress=function(){
//
}
Alternatively, use delegate to call a function from the correct scope.
myButton.onPress=Delegate.create(this, myButton_Click)
On Mar 28, 2006, at 1:06 PM, Mike Anderson wrote:
Hello All,
I am getting very confused here, on how to get the "onRollOver" and
"onRollOut" events to be broadcasted whenever the mouse moves over a
Flash Component, contained within a MovieClip using a Class File.
The component in this particular instance, is the Push Button. When
reading the documentation, the only "events" that are mentioned is the
"click" event. To my knowledge, when using a Class File attached to a
MovieClip containing a Push Button component, there is only one
type of
syntax that can be used for adding listeners.
For example:
myButton.addEventListener( "click", myButton_Click );
And you usually place this statement inside of the onLoad function of
the MovieClip class itself.
Then the function that handles the event, conforms to the method of
how
functions must be written inside of a Class File:
private function myButton_Click( evtObj:Object ):Void
{
//code here...
}
Since you can't use a listener object (like you would if you were
simply
putting functions in the root of the movie itself), and then have a
statement of listenerObject.onRollOver = function() within a Class
File,
I am wondering how I can force the onRollOver and onRollOut events to
get properly broadcasted.
Please keep in mind, I am trying to keep 100% of my code inside of my
Class Files. I know a simple solution could be simply highlighting
the
actual Push Button within the MovieClip, and then directly apply an
"on(event)" function to temporarily accomplish my goals - but this
totally defeats the purpose of creating a separation between Flash App
and Source Code.
I also looked at the SimpleButton.as Class File in which the Button.as
Class is based on. Oddly enough, there are "onRollOver" and
"onRollOut"
functions in there, but it doesn't Dispatch Events - it simply
activates
the "highlight" option when the user rolls over the button. I thought
that was pretty weird... I manually edited the Class File, so that a
Dispatch Event of "onRollOver" and "onRollOut" would be
broadcasted, but
still no dice...
Could any of you point me in the right direction, on how to accomplish
this using only Class Files? Since V2 components, AS 2.0, and Class
Files are being pushed so hard as the preferred way of doing
things, it
simply baffles me why these other events wouldn't be available to the
developer. Sorry, but "click" just isn't doing it for me - I need
more
events out of my components.
Thanks in advance,
Mike
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com