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
Tags: Actionscript 3, FishEye Menu, Tutorials
This will be a quick post on some gotcha’s to keep an eye out for when loading your ActionScript 3 game swf from a preloader swf. Nothing revolutionary here, back in mid-December, I had posted a blog on ActionScript 3’s Event Handling and the stopPropagation method and just the other day working on the code for a new game project, I ran into a situation where I should’ve used the method, didn’t, and ran into some issues.
Note: If you’re here looking for code on how to write a flash preloader, Lee Brimlow’s video tutorial on Preloading in AS3 gives a beautiful example. When I was originally learning how to code a preloader, that tutorial, and a couple of other tutorials around the net that escape my memory at the moment, were absolutely perfect.
Read the rest of this entry »
Tags: Actionscript 3, Code Examples, Game Development, Tutorials
A friend of mine that enjoys bitching until I help her with whatever popped into her head that moment messages me tonight. “Hey for my site [that you'll make for me for free because i'm a girl and your friend] I want a menu system like that one I showed you [which you're supposed to magically remember out of all the sites you've seen on the whole internet in your life].” After she re-sent me the link, a beautiful site called ilovedust I took a look at the slick little fish-eye style menu and said, “Yeah that’s Animation, I do code. Not pretty stuff like that.”
After 5 minutes of receiving complaining message (but mostly once my game was finished that I was playing at Kongregate, I actually thought about what was happening in that menu, and after about 20 minutes of coding, had a workable menu. I thought I’d post the code here and make a little tutorial out of it.
I love TweenLite. And TweenMax. And pretty much everything at GreenSock. Once you learn the class, it makes everything so easy. For those that are here who are AS2 coders… a) Upgrade! and b) They also have AS2 versions of all of their code. There are a number of other Tween libraries to choose from. Some perform better than others. But TweenLite was the first for me that ‘made sense’ in my budding AS3 days, which still continue.
This is a quick little example of making a 5 menu-item menu that does stuff when you mouse-over. You could probably think of a million ways to optimize this code; putting the menu items in a loop to initialize and things like that. I’m just going to lay it out, and you can make your own better.
Read the rest of this entry »
Tags: Actionscript 3, Tutorials, TweenLite
One of the most frustrating things about Joomla is it’s lack of thorough documentation. Yeah, there’s an API… yeah there’s a Wiki… but it just seems like there are a lot of gaps and holes that don’t necessarily have to exist. Here’s a quick tutorial on how to implement languages in your component in Joomla! 1.5.
First off, lets talk about why this tutorial is important. Let’s say you’re creating a component to give site admins a way to easily create a special Links (yes, there’s already one for Joomla, it’s 2am, just go with me on this) section. On the back-end, you’ve got an “Add Link Category” page that takes admins to a nice form that lets them create a category for links in this component. So you’ve got text for “Name:” and “Description:” and maybe even “Category Image:” if they want to use an image with the text. You finish your component and release it, and someone in the Joomla community wants to make a Spanish version of your component. They would have to dig into your source code and basically re-write all of your inline html that you’ve written; essentially necessitating a while new release of your component in an “English version” and “Spanish version.”
Read the rest of this entry »
Tags: Joomla, PHP, Tutorials
Ok folks, a number of tutorials have been written about creating a Tower Defense ( TD ) style game using Flash. The problem I ran into was that none of them seemed to be using Actionscript 3, or they were helpful but just not what I was looking for. So, I am hereby writing one as I work on mine.
Read the rest of this entry »
Tags: Actionscript 3, Game Development, Tutorials