dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: "Over nothing" state

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    263

    "Over nothing" state

    Hey all,

    Is there an AS3 command or event listener that can detect when the mouse is not hovering over any active buttons.

    I currently have 4 buttons that when hovered over, change a banner area. I want all of the banners to fade when none of the 4 buttons are being hovered over.

    Any help in this area would be appreciated.

    Thanks
    http://www.stillloading.com
    http://www.threecell.com

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Well you could just listen for the mouseout of the buttons, which would essentially be the same thing. Or you could have a clip the size of the unused area with a mouseover. Or you could put a mouseover event on the stage and make sure mouseover events on the buttons don't bubble up to the stage, etc.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    263
    Thanks for the suggestions.

    Ideally, I'd like to use the mouseOut command rather than an unused area with a mouseOver since this flash file is being inserted into an html page and the unused area would only appear within the flash frame itself.

    Bearing in mind that hovering over the buttons change the banners, the mouseOut doesn't appear to be working in my specific case because the mouseOut of one button sometimes means the hovering over of another button OR the hovering over no buttons. In other words, the way that I have it written, mouseOut is not an accurate indicator of whether no buttons are being hovered over.

    If you anyone has some additional thoughts to share about utilizing the mouseOut command for my specific need, I'd appreciate it.

    I've included my code below as a reference (the banners are Fire, Earth, Air, Water which ideally I'd like to have fade away whenever the user is not hovering over any buttons):

    Code:
    var overTargetFrame:int = 15;
    var outTargetFrame:int = 1;
    
    var banners:Array = [Fire, Water, Air, Earth];
    
    
    for each(var clip:MovieClip in [over_company, over_services, over_port, over_contact]){
    	clip.addEventListener(MouseEvent.ROLL_OVER, onClipOver);
    	clip.addEventListener(MouseEvent.ROLL_OUT, onClipOut);
    }
    over_company.banner = Fire;
    over_services.banner = Water;
    over_port.banner = Air;
    over_contact.banner = Earth;
    
    function onClipOver(e:MouseEvent):void {
    
    	var btn:MovieClip = MovieClip(e.currentTarget);
    	btn.targetFrame = overTargetFrame;
    	//add event listener to button if it doesnt have one
    	if(!btn.hasEventListener(Event.ENTER_FRAME)){
    	   btn.addEventListener(Event.ENTER_FRAME, updateFrame);
            }
     
    }
    
    function onClipOut(e:MouseEvent):void {
    
    	var btn:MovieClip = MovieClip(e.currentTarget);
    	btn.targetFrame = outTargetFrame;
    	
    	//add event listener to button if it doesnt have one
    	if(!btn.hasEventListener(Event.ENTER_FRAME)) {
    		btn.addEventListener(Event.ENTER_FRAME, updateFrame);
    	}
    }
    
    
    function updateFrame(e:Event):void {
    	var btn:MovieClip = MovieClip(e.currentTarget);
    	var which;
    	if(btn.currentFrame == btn.targetFrame){
    	  //when it hits the last frame, remove the listener
              btn.removeEventListener(Event.ENTER_FRAME, updateFrame);
              return;
            }
    
    	if(btn.currentFrame < btn.targetFrame) {
    	   btn.nextFrame();
               for (var i:int = 0; i < banners.length; i++){
                  var banner:MovieClip = banners[i];
                  if (btn.banner == banner){
                     banner.nextFrame();
                  }else{
                     banner.prevFrame();
                  }
               }
    	}else{
    	   btn.prevFrame();
            }
    
    		
    }
    http://www.stillloading.com
    http://www.threecell.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center