i have a rollover function that sets alpha values, and i also have a click function that sets the alpha even higher on click. I also have a roll out function to return it to normal when roll out. The thing is i want it to hold the high alpha value on click because that is the web page is selected. It works, but the second i rool out or roll over, it sets the value back.
function fl_MouseOverHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .4, 2, true); }
function fl_MouseOutHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .2, 2, true); }
function fl_MouseClickHandler(event:MouseEvent):void {
var myTweenBigAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .8, 1, true); var myTweenSize:Tween = new Tween(designClip.yellow, "height", Strong.easeOut, designClip.yellow.height, 210, 3, true);
//Other Clips Shrink var myTweenHomeSize:Tween = new Tween(Object(root).home.homeClip.orange, "height", Strong.easeOut, Object(root).home.homeClip.orange.height, 177, 3, true); var myTweenPhotoSize:Tween = new Tween(Object(root).photography.photoClip.white, "height", Strong.easeOut, Object(root).photography.photoClip.white.height, 177, 3, true); var myTweenMusicSize:Tween = new Tween(Object(root).music.musicClip.green, "height", Strong.easeOut, Object(root).music.musicClip.green.height, 177, 3, true); var myTweenAboutSize:Tween = new Tween(Object(root).about.aboutClip.blue, "height", Strong.easeOut, Object(root).about.aboutClip.blue.height, 177, 3, true);
//all other buttons alpha to 20% var myTweenHomeAlpha:Tween = new Tween(Object(root).home.homeClip, "alpha", Strong.easeOut, Object(root).home.homeClip.alpha, .2, 2, true); var myTweenAPhotoAlpha:Tween = new Tween(Object(root).photography.photoClip, "alpha", Strong.easeOut, Object(root).photography.photoClip.alpha, .2, 2, true); var myTweenAMusicAlpha:Tween = new Tween(Object(root).music.musicClip, "alpha", Strong.easeOut, Object(root).music.musicClip.alpha, .2, 2, true); var myTweenAAboutAlpha:Tween = new Tween(Object(root).about.aboutClip, "alpha", Strong.easeOut, Object(root).about.aboutClip.alpha, .2, 2, true);
function fl_ClickToGoToWebPage(event:MouseEvent):void { //navigateToURL(new URLRequest("http://www.google.com"), "_blank"); } }
Basicly, you need to keep in memory which buttons is the current clicked button
Actionscript Code:
var current_button:MovieClip;
in your mouse out, add these lines
Actionscript Code:
if(current_button != e.currentTarget) //do your mouse out actions, so it wont roll out if the button you just clicked is the current button
In your mouse click event function, you need to add some code as well
Actionscript Code:
//if not null, it means a button has already been clicked so we want this old active button to return to normal if(current_button != null) { //current_buttontween your current button to normal //then we associate the new clicked button into the variable current_button = e.currentTarget as MovieClip; }
//then we tween the current button to the high alpha
Why do you use CLICK event in this case?
I think you'd better use MouseEvent.MOUSE_DOWN and MouseEvent.MOUSE_UP instead. This will simplify your work a lot
Why do you use CLICK event in this case?
I think you'd better use MouseEvent.MOUSE_DOWN and MouseEvent.MOUSE_UP instead. This will simplify your work a lot
I don't understand how that would simplify my work, could you please explain further?
function fl_MouseOverHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .4, 2, true); }
function fl_MouseOutHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .2, 2, true); }
if(current_button != null) { //current_buttontween your current button to normal //then we associate the new clicked button into the variable current_button = e.currentTarget as MovieClip; }
function fl_MouseClickHandler(event:MouseEvent):void {
var myTweenBigAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .8, 1, true); var myTweenSize:Tween = new Tween(designClip.yellow, "height", Strong.easeOut, designClip.yellow.height, 210, 3, true);
//Other Clips Shrink var myTweenHomeSize:Tween = new Tween(Object(root).home.homeClip.orange, "height", Strong.easeOut, Object(root).home.homeClip.orange.height, 177, 3, true); var myTweenPhotoSize:Tween = new Tween(Object(root).photography.photoClip.white, "height", Strong.easeOut, Object(root).photography.photoClip.white.height, 177, 3, true); var myTweenMusicSize:Tween = new Tween(Object(root).music.musicClip.green, "height", Strong.easeOut, Object(root).music.musicClip.green.height, 177, 3, true); var myTweenAboutSize:Tween = new Tween(Object(root).about.aboutClip.blue, "height", Strong.easeOut, Object(root).about.aboutClip.blue.height, 177, 3, true);
//all other buttons alpha to 20% var myTweenHomeAlpha:Tween = new Tween(Object(root).home.homeClip, "alpha", Strong.easeOut, Object(root).home.homeClip.alpha, .2, 2, true); var myTweenAPhotoAlpha:Tween = new Tween(Object(root).photography.photoClip, "alpha", Strong.easeOut, Object(root).photography.photoClip.alpha, .2, 2, true); var myTweenAMusicAlpha:Tween = new Tween(Object(root).music.musicClip, "alpha", Strong.easeOut, Object(root).music.musicClip.alpha, .2, 2, true); var myTweenAAboutAlpha:Tween = new Tween(Object(root).about.aboutClip, "alpha", Strong.easeOut, Object(root).about.aboutClip.alpha, .2, 2, true);
function fl_ClickToGoToWebPage(event:MouseEvent):void { //navigateToURL(new URLRequest("http://www.google.com"), "_blank"); } }
tried to do it exactly as you said.
I'm getting 3 errors.
Symbol 'Design', Layer 'Layer 1', Frame 1, Line 35 1120: Access of undefined property e.
Symbol 'Design', Layer 'Layer 1', Frame 1, Line 22 1120: Access of undefined property e.
Symbol 'Design', Layer 'Layer 1', Frame 1, Line 20 1120: Access of undefined property fl_MouseOutHandler.
Well, I can't see where you did as I said. I said it would be better to use MOUSE_DOWN and MOUSE_UP, instead of CLICK. You didn't do it.
I'll try to explain what's the difference.
CLICK event is dispatched when you press your mouse's left button and then release it. So you can only handle this event after these 2 phases are passed. MOUSE_DOWN occurs when you press the left button no matter whether you release it or not, and MOUSE_UP occurs when you release the button. This means you can handle all of those phases separately. You can do something when you press the button, something else when you release it. I hope it helps.
As to your errors, that's typical, look, here you got the keyword "event"
Actionscript Code:
function fl_MouseOutHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .2, 2, true); }
if(current_button != null) { //current_buttontween your current button to normal //then we associate the new clicked button into the variable current_button = e.currentTarget as MovieClip;
im a little confused on the e.currentTarget or event.currentTarget am i calling a specific target like designClip.currentTarget. I'm confused on how this function is used.
Here is where i am.
I use currentTarget to designate the current clip as target on mouseDown.
then on roll out, make a statement that nullifies the actions if the current clip is set as currentTarget.
then i need to set the currentClip as NOT current target when clicked outside.
now i can only roll over once, then it sticks to the roll over alpha, even if i roll out.
I have only applied this code to the design button so far.
function fl_MouseOverHandler(event:MouseEvent):void { var myTweenAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .4, 2, true); }
function fl_MouseClickHandler(event:MouseEvent):void { //if not null, it means a button has already been clicked so we want this old active button to return to normal if(designClip != null) { //current_buttontween your current button to normal //then we associate the new clicked button into the variable designClip = event.currentTarget as MovieClip; }
//then we tween the current button to the high alpha
var myTweenBigAlpha:Tween = new Tween(designClip, "alpha", Strong.easeOut, designClip.alpha, .8, 1, true); var myTweenSize:Tween = new Tween(designClip.yellow, "height", Strong.easeOut, designClip.yellow.height, 210, 3, true);
//Other Clips Shrink var myTweenHomeSize:Tween = new Tween(Object(root).home.homeClip.orange, "height", Strong.easeOut, Object(root).home.homeClip.orange.height, 177, 3, true); var myTweenPhotoSize:Tween = new Tween(Object(root).photography.photoClip.white, "height", Strong.easeOut, Object(root).photography.photoClip.white.height, 177, 3, true); var myTweenMusicSize:Tween = new Tween(Object(root).music.musicClip.green, "height", Strong.easeOut, Object(root).music.musicClip.green.height, 177, 3, true); var myTweenAboutSize:Tween = new Tween(Object(root).about.aboutClip.blue, "height", Strong.easeOut, Object(root).about.aboutClip.blue.height, 177, 3, true);
//all other buttons alpha to 20% var myTweenHomeAlpha:Tween = new Tween(Object(root).home.homeClip, "alpha", Strong.easeOut, Object(root).home.homeClip.alpha, .2, 2, true); var myTweenAPhotoAlpha:Tween = new Tween(Object(root).photography.photoClip, "alpha", Strong.easeOut, Object(root).photography.photoClip.alpha, .2, 2, true); var myTweenAMusicAlpha:Tween = new Tween(Object(root).music.musicClip, "alpha", Strong.easeOut, Object(root).music.musicClip.alpha, .2, 2, true); var myTweenAAboutAlpha:Tween = new Tween(Object(root).about.aboutClip, "alpha", Strong.easeOut, Object(root).about.aboutClip.alpha, .2, 2, true);
function fl_ClickToGoToWebPage(event:MouseEvent):void { //navigateToURL(new URLRequest("http://www.google.com"), "_blank"); } }
here is a link to the website so you can see how its behaving. remember new code is only applied to design button.
function fl_MouseOutHandler(e:MouseEvent)
e.currentTarget or event.currentTarget based on what you got in the function
Basically what this does is to get the object thats "starting" the function.
lets say i got this: Blackbird.addEventListener(MouseEvent.CLICK, run);
function run(e:MouseEvent) {
var bird:String =e.currentTarget
}
the variable bird will in this case hold the object that started the function( in this case the Blackbird).
function fl_MouseOutHandler(e:MouseEvent)
e.currentTarget or event.currentTarget based on what you got in the function
Basically what this does is to get the object thats "starting" the function.
lets say i got this: Blackbird.addEventListener(MouseEvent.CLICK, run);
function run(e:MouseEvent) {
var bird:String =e.currentTarget
}
the variable bird will in this case hold the object that started the function( in this case the Blackbird).
Hope this helps
ok i don't get why its e.currentTarget what is "e"?
and second you state Blackbird, but then at the var, its just bird. Is that a wild card for anything with "bird" in it?
can someone give me an example of how to incorporate this into my code? I honestly get the concept, but i have no idea how to incorporate it because of the complexity of my code. (its complex for me)
Ok i have simplified the code for you:
in this code i have 2 buttons one is named "t" and the secound one is named "b".
im running a if check to check if the button has been clicked or not. NOTISE if i click the secound button the if check for the first button resets. remember you have to add this for all your buttons on all your buttons!
Actionscript Code:
import flash.events.MouseEvent; var tClicked:int=0; var bClicked:int=0; t.alpha=0.3; b.alpha=0.3;
t.addEventListener(MouseEvent.MOUSE_OVER, tovera); function tovera(e:MouseEvent){ if(tClicked==0){ t.alpha=0.5; } } t.addEventListener(MouseEvent.MOUSE_OUT, toveru); function toveru(e:MouseEvent){ if(tClicked==0){ t.alpha=0.3; } } t.addEventListener(MouseEvent.CLICK, toverc); function toverc(e:MouseEvent){ if(tClicked==0){ t.alpha=1.0; tClicked=1; bClicked=0; b.alpha=0.3; } } b.addEventListener(MouseEvent.MOUSE_OVER, bovera); function bovera(e:MouseEvent){ if(bClicked==0){ b.alpha=0.5; } } b.addEventListener(MouseEvent.MOUSE_OUT, boveru); function boveru(e:MouseEvent){ if(bClicked==0){ b.alpha=0.3; } } b.addEventListener(MouseEvent.CLICK, boverc); function boverc(e:MouseEvent){ if(bClicked==0){ b.alpha=1.0; bClicked=1; tClicked=0; t.alpha=0.3; } }
oh and also if you did trace(bird); the output would be Blackbird because thats the object in the string variable
var bird=e.currentTarget;
is the same as
var bird=Blackbird;
because e.currentTarget is set to Blackbird because the addEventListener that ran the function was added to a object named Blackbird.
Last edited by Shattering; 07-21-2010 at 09:48 PM.