FishEyeMenu Class Update… v1.1

Thanks to a comment posted by doggy, I’ve updated the FishEyeMenu class to listen for MouseDown events and keep track of selected items.  

New Functions:

  • public function get selected():*
  • public function get lastSelected():* 
  • public function set selected( clickedItemEvent:MouseEvent ):void  
New Event Type
  • FishEyeMenu.SELECTED_CHANGED – Triggered upon a change in selected menu item
Once you’ve pushed an item into the FishEyeMenu object, it keeps track of it’s own MouseDown events on the items in it’s array.  When a user clicks on a menu item, it sets the _lastSelected property to whatever Was selected, and sets the _currentSelected property to whatever menu item was clicked.  

You can now add an event listener for SELECTED_CHANGED which will dispatch upon MouseDown on a menu item.

Please note, the getters for selected and lastSelected are going to return the actual Object that you pushed to the menu.  So it will return a reference to the actual TextField or MovieClip or Sprite or whatever you’re using in the menu.  If you check the Example FLA, you’ll see this code as an example

// in the main function
fishEyeMenu.addEventListener( FishEyeMenu.SELECTED_CHANGED , changedHandler );
 
//later in the code:
/**
* Simple test of usage, fishEyeMenu.selected returns the object selected
* so it's just like calling the actual object that was clicked last and
* you can set whatever properties that object has.
* If this were a MovieClip, you could use fishEyeMenu.selected.gotoAndStop()
***/
private function changedHandler( e:* )
{
trace( "Selected Item Changed to : " + fishEyeMenu.selected.name );
trace( "Selected Item Changed to : " + fishEyeMenu.lastSelected.name );

fishEyeMenu.selected.x +=20;

}

In the simple example, calling fishEyeMenu.selected.x += 20; just moves the object you clicked over 20 pixels to the right (+20). But you could also use fishEyeMenu.selected.gotoAndStop( “Selected” ); if you had pushed several Movie Clips into FishEyeMenu… and they had a frame with framelabel “Selected”.  Post comments if you’d like… it only helps make things better.

 

Download FishEyeMenu v1.1 from GoogleCode

View Updated Documentation

FacebookTwitterGoogle+Share

4 Comments

 Add your comment
  1. Hey man this is great!!! :-)

    It worked like a treat except for one thing. It is probably the way I’ve implemented it but I have MOUSE_OVER & MOUSE_OUT states along side the new SELECTED_CHANGE method which change the colour of the highlight. The problem I seem to be getting is when the menu is loaded for the first time, when the user hovers over the buttons and moves over the 1st item it turns to its selected state, am I right in guessing that the fishEyeMenu.selected.name has the default value of the 1st item in the list? The links will better explain. :-)

    MENU – http://www.mydeadpixel.com/menu/FishEyeMenu.html

    AS3 – http://www.mydeadpixel.com/menu/as3.html

    Also how teh devil do I get buttonMode to work with the menu? (a)

    Cheers mate

  2. Glad it’s aaalmost working!
    First up, I realized there was no way to manually set which menu item was selected. Check the GoogleCode link in the post for a version 1.2 with a new function called setSelected(). If you download the new v1.2 package file, it’ll show the usage although its really only one line… fishEyeMenu.setSelected( menu2 ); or whichever default menu item you want to be selected and that should be called in your Main() function. The setSelected method will automatically trigger the SELECTED_CHANGED event, so whatever is supposed to happen when you click a new event, it’ll trigger that as well.

    edit: Oh and as for TextField getting the mouse hand cursor… as far as I know, that’s not possible with textfields. What you would probably want to do is create a MovieClip or Sprite and add the textField into the MC/Sprite… then push the MC/Sprite into fishEyeMenu instead of the menu1/menu2 TextFields. Then you’d just want to make sure you added myMC.useHandCursor = true;

  3. Haelix this is perfect!! Thanks so much for all your help! :-)

  4. Thanks for the tutorial. It has been a great help.
    But I still have a problem that can not resolve.
    I believe it is very basic and easy to be solved:
    FishEye use the menu within a movieclip and I want the user to click on the text of the menu to trigger the frame mc (X) for example.
    My attempts always generate the following report:

    ReferenceError: Error # 1069: Property gotoAndStop not found on flash.text.TextField and there is no default value.
    At Main / changedHandler ()
    at flash.events:: EventDispatcher / dispatchEventFunction ()
    At flash.events:: EventDispatcher / dispatchEvent ()
    at zombieflambe.ui: FishEyeMenu / onMouseDownHandler ()

    Could you please post an example code of a link into the movieclip in Blogger? Type:

    fishEyeMenu.selected.gotoAndStop ( “Selected”);
    What is missing? write the words Menu1, Menu2. Where?
    so go to and stop the frame 1 to 10 ?!

    Now thanks again for the great work and thank you for your attention.

Leave a Comment

Your email address will not be published.