GIGJ.COM welcome to my space |
HOME Very dumb AS3 question...what happened to Rollovers? |
| Very dumb AS3 question...what happened to Rollovers? | | Published by: admin 2009-01-07 |
| Ok in as2 i would write it as:
rect1.onRollOver=function(){
...do something
}
how do I code this in AS3 now? I am finding it quite hard to adapt to this new code, as2 was easier i think
Jpixels
In a function, this refers to the object where the function was defined not to the object calling it. So no. You could use the Event object, that is passed to the function, to reference the broadcasting object though (through event.target). This will allow you to use one function for multiple movie clips.
I don't want to complicate things, but ideally you would create a class for the movie clip which will handle everything internally. This is especially useful if you have multiple instances.
maybe this is the right place for my question.
rect1.onRollOver = myfunction(myvar1, myvar2);
function myfunction(var1, var2) { ... }
how do i do this one in as3?! passing custom variables to the function i call. not only the event like in
rect1.addEventListener(MouseEvent.MOUSE_OVER, rollOver);
function rollOver(evt:MouseEvent):void {
//do something
}
What else have you done in your FLA because that code shouldn't throw that error.
Things like package and extends are for external classes.
rect1.addEventListener(MouseEvent.MOUSE_OVER, rollOverRect);
function rollOverRect(evt:MouseEvent):void {
rect1.x=rect1.x+100;
}
ok now its saying:
1046: Type was not found or was not a compile-time constant: rect1.
any ideas?
aaaah thank you very much.
i'm going to be here a lot because I want to make a transition to as3 :)
I was reading somewhere it said u should always start with package, but a small app I downloaded just had a bunch of listeners and functions...So u dont always need to add that package and extends stuff?
thanks again
One question..shouldnt you be using this.x instead of the name of the object?
thank you
rect1.addEventListener(MouseEvent.MOUSE_OVER, rollOver);
function rollOver(evt:MouseEvent):void { FlashMove - BlogSite News flog:: Which leads to an obvious question -- with Intel-powered iMacs now shipping, and Some impressive, some very dumbmany painful. http://www.flashmove.com/blog/index.php?id=13&page=13HOME |
//do something
}
ok thanks, its coz I was messing about with the 'linkage' properties, took them off, now it works!
I am not trying to hijack this thread, but in the interest of not repeating threads I am going to bud in. I am learning as I go.
Background:
My site when you roll over a button will play a quick animation.
news_btn.addEventListener(MouseEvent.MOUSE_OVER, rollOver);
function rollOver(evt:MouseEvent):void {
news_btn.gotoAndPlay(2);
}
Now, news_btn is the name of the movie clip that I want to rollover, when they rollover I want to have news_btn leave the first frame in it's own time line and play the animation. I have this code in the first frame of the news_btn movie clip timeline in the actions layer. Eventually when I get this working I will rewind it back to 1 to give it a seemingly flawless animation. But one problem at a time.
my errors generated were:
1120: Access of undefined property news_btn. news_btn.gotoAndPlay(2);
1120: Access of undefined property news_btn.news_btn.addEventListener(MouseEvent.MOUS E_OVER, rollOver);
I believe i kept it generally the same as you had it, but I am not sure why it is not working. :) any advice would work. I have a feeling it has to do news_btn, but that is the name of the movie clip. I thought I had to be specific which movie clip I want to change frames in or it will change the main clip. should I use .this?
news_btn.addEventListener(MouseEvent.MOUSE_OVER, rollOver);
function rollOver(event:MouseEvent):void {
this.news_btn.gotoAndPlay(2);
}
make sure you have the instanceName set on the button.
Nortel Unveils Vision, Strategy for Israeli High-Performance Net
Busy Friday Leads to Strong Close for Net Stocks
|
You are looking at:gigj.com's Very dumb AS3 question...what happened to Rollovers?, click gigj.com to home
|
#If you have any other info about this subject , Please add it free.# | |
|