Suggestions to make navigation class better

I’m hoping someone here has a couple suggestions for a generic navigation class I’m working on. I got it to work exactly how I wanted it to, but maybe someone can think of some ways to make it better.

Here’s the script:


package {
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.EventDispatcher;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import Error;

    public class Navigation {
        private var _movieclips:Object;
        private var _links:Object;
        private var _mouseover:Object;
        private var _mouseout:Object;
        private var _mouseclick:Object;
        private var _currentclip:Object;
        private var _oncurrent:Object;
        private var id:int;
        private static const IS_CURRENT:String = "is current";
            
        public function Navigation() {
            
        }

        public function set clips(array):void {
            _movieclips = array;
        }
        public function set links(array):void {
            _links = array;
        }
        public function set checkcurrent(object):void {
            _currentclip = object;
        }
        public function set mouseover(funct):void {
            _mouseover = funct;
        }
        public function set mouseout(funct):void {
            _mouseout = funct;
        }
        public function set mouseclick(funct):void {
            _mouseclick = funct;
        }
        public function set oncurrent(funct):void {
            _oncurrent = funct;
        }
        
        public function go():void {
            if (_movieclips.length != _links.length) {
                throw new Error("Navigation: Length of 'Navigation.clips ("+_movieclips.length+")' does not equal length of 'Navigation.links ("+_links.length+")'");
            }
            for (var i:int = 0; i < _movieclips.length; i++) {
                if (_movieclips* == _currentclip) {
                    if(_oncurrent != null){
                        _movieclips*.addEventListener(IS_CURRENT, _oncurrent);
                        _movieclips*.dispatchEvent(new Event(IS_CURRENT));
                    } else {
                        throw new Error("Navigation.checkcurrent: 'Navigation.oncurrent = function' expected.")
                    }
                } else {
                    _movieclips*.id = i;
                    _movieclips*.mouseChildren = false;
                    _movieclips*.buttonMode = true;
                    if(_mouseover != null){
                        _movieclips*.addEventListener(MouseEvent.MOUSE_OVER, _mouseover);
                    }
                    if(_mouseout != null){
                        _movieclips*.addEventListener(MouseEvent.MOUSE_OUT, _mouseout);
                    }
                    _movieclips*.addEventListener(MouseEvent.CLICK, (_mouseclick == null)?(defaultClick):(_mouseclick));
                }
            }
        }
        
        public function defaultClick(event:MouseEvent):void {
            navigateToURL(new URLRequest(_links[event.target.id]), "_self");
        }
    }

}

The idea was that I would declare a new navigation, assign a series of movieclips and links to it, then declare functions for the MOUSE_OVER, MOUSE_OUT, and CLICK events.

I would use it like this:


import Navigation;

var nav:Navigation = new Navigation();
nav.clips = [about_mc,brands_mc,seasonal_mc,styles_mc,nightlife_mc];
nav.links = ["about.php","brands.php","seasonal.php","styles.php","nightlife.php"];
nav.mouseover = onMouseOver;
nav.mouseout = onMouseOut;
nav.checkcurrent = about_mc;
nav.oncurrent = onCurrent;
nav.go();

function onMouseOver(event:MouseEvent):void {
    event.target.alpha = .5
}

function onMouseOut(event:MouseEvent):void {
    event.target.alpha = 1;
}

function onCurrent(event:Event){
    event.target.alpha = 0;
}

Anyone have any good suggestions? I’m open to anything to make this more universal and usable.

Thanks