Hi List,

I have the following piece of code:

        function getShowMenuFunction (menuID:String):Function {
                return Delegate.create (this, 
                           function (evt) { 
                                var loc = null;
                                
                                if (SimpleTriggerEvent (evt) == null) {
                                        loc = {x:_root._xmouse,
y:_root._ymouse};
                                } else {
                                        loc = SimpleTriggerEvent
(evt).getGlobalCoords();
                                }
                                
                                var theMenu:MenuView = MenuView
(this.menuManager.getItemByID (menuID));
                                theMenu.show (loc.x, loc.y);
                           }
                        )       
        }

What it does is, it returns a function that when called, shows a menu
corresponding with the given id.
The function will be called somewhere else at which point a
SimpleTriggerEvent (triggered by a button for example) will be passed.

Now... It works, BUT I was surprised it did, especially with respect to the
menuID field.
Looking at the parameter passed (menuID) and the line : var theMenu:MenuView
= MenuView (this.menuManager.getItemByID (menuID));
I am wondering if this is a valid way to do this, or did I just get lucky
and should I approach the passing of the menuID param another way? Seems
like a perfect case of programming by coincidence which Im trying to
avoid:).

Greetz
Hans


 

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to