Prototype hacking is not really a great way to do this in the Flex world.  I’d recommend creating some sort of registry where you can store the XML for different components.  Then when a component needs to find its menu XML it would look it up in the registry.

 

You could take a similar approach to how Cairngorm and the Flex Book come up with ServiceLocators.

 

MenuRegistry.mxml

<mx:UIComponent xmlns:mx=http://www.macromedia.com/2003/mxml visible=”false” width=”0” height=”0”>

  <mx:XML id=”menu1”>

    …

  </mx:XML>

 

  <mx:XML id=”menu2”>

  </mx:XML>

 

  <mx:Script>

    var menus : Object;

    function registerMenu(componentName, menuName) : Void {

      if (menus == null) menus = new Object();

      menus[componentName] = menuName;

    }

 

    function getMenu(componentName) : XMLNode {

      var menuName = menus[componentName];

      if (menuName == null) return null;

      else return this[menuName];

    }

  </mx:Script>

</mx:UIComponent>

 

In your Application you then create a menu registry and make it invisible, etc.

 

<mx:Application …>

 

  <MenuRegistry id=”menuRegistry” />

 

</mx:Application>

 

And then wherever appropriate you call Application.application.menuRegistry.registerMenu(“someComponent”, “menu1”) and when looking up the menu you’d use the getMenu as appropriate.

 

Those component names could be done by class or whatever naming mechanism makes sense for you.

 

HTH,

Matt


From: Seth Voltz [mailto:[EMAIL PROTECTED]
Sent: Friday, January 28, 2005 3:07 PM
To: [EMAIL PROTECTED]
Subject: Re: [flexcoders] Images moveable and running top-most

 

Ahh, yes. I just set modal to false and it's almost done. The last problem I have is how to attach a menu XML object to a particular something on the screen. The way I set up the default menu is

 

Application.application.getContextMenu = function ( ) { return defaultMenuXML; }

 

but this doesn't work on other classes because they're not dynamic (yes?) I tried fiddling with the prototypes of UIObject to see if I could add an empty instance of getContextMenu via

 

mx.core.UIObject.prototype.getContextMenu = function ( ) { }

 

but that produces no compile errors and still doesn't seem to work (I try to set that function to a new one at runtime and that produces a compile time error.)

 

Any suggestions?

Seth

 

On Jan 28, 2005, at 12:36, Tracy Spratt wrote:

 

I found this in an earlier thread, does it apply?

 

 

 

 

 

On Mon, 27 Dec 2004 20:11:37 -0000, apdog <[EMAIL PROTECTED]> wrote:

 

 

 

> This helps recreate the problem.  We discovered that if you bring up a

 

> TitleWindow in modal mode (which is the default when one uses the

 

> popupWindow method found on the Application class) thenthe menu item

 

> sublists are hidden behind other components placed on the TitleWindow

 

> such as the Tab Navigator.

 

 

 

I can see the problem using the MXML code you provided.

 

 

 

> I did have one Macromedia person confirm these results.  If you get

 

> the same results, I would hope in the future, modal TitleWindows would

 

> not preclude the use of MenuBars.

 

 

 

It looks like a bug. Modal windows are at the highest depth (z-order), which is why you see the drop-down menus appear below them.

 

 

 

I'm not sure if this will work for you, but you can try navigating through all the menus in the menu bar and setting their depths to be above the depth of the window. You can do this in the

 

creationComplete() of the TitleWindow.

 

 

 

  e.g.

 

 

 

  function myCreationComplete()

 

  {

 

    for (list of menu items)

 

      item.setDepthAbove(this); // above the window

 

  }

 

 

 

You'll have to take care of submenus as well.

 

 

 

Manish

 

 

 

 

 

 

 

From: Seth Voltz [mailto:[EMAIL PROTECTED]

Sent: Friday, January 28, 2005 5:36 AM

To: [email protected]

Subject: Re: [flexcoders] Images moveable and running top-most

 

 

 

Good call, Matt. Thanks!

 

I have a fair amount of the code working but I've hit a few snags. The current orderof operations is when a mouseDown event is captured somewhere in the app, create a popup with the context menu manager. The manager then plays an animation and pops up a menu. The problem I have is the menu the popup creates is placed below the popup itself and doesn't seem to want to respond to events (or fire its own).

 

Is this a standard thing for menus and popups? Any help would be appreciated.

 

Thanks,

Seth

 

On Jan 27, 2005, at 02:42, Matt Chotin wrote:

 

Have you tried using the PopupManager to do some of this stuff?

 

 

 

Matt

 

 

 

From:Seth Voltz [mailto:[EMAIL PROTECTED]

Sent:Wednesday, January 26, 2005 12:16 AM

To:[email protected]

Subject:[flexcoders] Images moveable and running top-most

 

 

 

Hello again,

 

 

 

So I've decided to take a crack at the click-and-hold contextual menu discussed a while ago here and have some pseudo code, some flash animations and a fresh install of Flex running on my laptop (wee, took a few tries to figure out Mac installation. Purrs right along now, though.)

 

 

 

So I've run into a slight problem: My low level flash coding experience is not all that great and I'm starting to see _root show up in the code that I've been trying to piece together. The goal for my first test is to take an embedded image (an animating SWF) and place it anywhere within the applications SWF above all other objects. Here's the messy code I have so far (mostly pulled from CursorManager.as)

 

 

 

index.mxml

 

<?xml version="1.0" encoding="utf-8"?>

 

 

 

<mx:Application initialize="myInit()" xmlns:mx="http://www.macromedia.com/2003/mxml">

 

 

 

<mx:Script>

 

<![CDATA[

 

import de.richinternet.utils.Dumper;

 

import mx.managers.*;

 

import mx.events.*;

 

private var menu_animation : MovieClip;

 

[Embed("assets/dot_animation.swf")]

 

var menu_dot:String;

 

function myInit ( ) {

 

popMenuInit ( );

 

}

 

function popMenuInit ( ) {

 

if ( menu_animation._target == undefined ) {

 

menu_animation = DepthManager.createClassObjectAtDepth ( UIObject, DepthManager.kCursor );

 

LowLevelEvents.addUndetectableMovieClip ( menu_animation );

 

 

 

menu_animation["contextMC"].removeMovieclip ( );

 

menu_animation.attachMovie ( menu_dot, "contextMC", 1 );

 

}

 

menu_animation.x = 300;

 

menu_animation.y = 300;

 

}

 

]]>

 

</mx:Script>

 

 

 

<mx:Panel label="Test" widthFlex="1" heightFlex="1">

 

</mx:Panel>

 

 

 

</mx:Application>

 

 

 

Any ideas what I'm doing wrong? No errors when I run it but also no image. I can loadthe SWF in an <mx:Image> tag and it works great.

 

Originally I tried menu_animation._xand ._ybut recieved a compiler warning that I shouldn't do this. Is this a Flex 1.0 thing? (I can't find my 1.5 trial disc)

 

 

 

Thanks again,

 

Seth

 

Yahoo! Groups Links

 

• To visit your group on the web, go to:

 

http://groups.yahoo.com/group/flexcoders/

 

 

 

• To unsubscribe from this group, send an email to:

 

[EMAIL PROTECTED]

 

 

 

• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Yahoo! Groups Links

 

        •       To visit your group on the web, go to:

http://groups.yahoo.com/group/flexcoders/

 

        •       To unsubscribe from this group, send an email to:

[EMAIL PROTECTED]

 

        •       Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

 

Reply via email to