ok.

there's a Form Application that loads two SWF's as children to the top
level 'Application' screen. the actual form app doesn't do anything
except load the SWF's and manage the show/hides of the children.
basically it's a search + results app, where child1 is the search
form, child2 is the result datagrid. child2 has the contextmenu. all
functionality is in these two SWFs.

i'm loading the child SWF's by setting the contentPath property, with
autoLoad = true on both. child1 is immediately visible, child2 is
hidden until the user runs a search.

here's the relevant code in _root of child2:
// context menu for the call list
var my_cm:ContextMenu = new ContextMenu(menuHandler);
my_cm.hideBuiltInItems();
my_cm.customItems.push(new ContextMenuItem("View/Edit", itemHandler,
false, false, true));
my_cm.customItems.push(new ContextMenuItem("Print Call", itemHandler,
true, false, true));
my_cm.customItems.push(new ContextMenuItem("Print List", itemHandler,
false, true, true));
my_cm.customItems.push(new ContextMenuItem("Email Caller",
itemHandler, true, false, true));

// this function decides which options are available on right click
function menuHandler(obj, menuObj) {
        if (obj.selectedIndex != undefined) {
                // enable all the items
                menuObj.customItems[0].enabled = true;
                menuObj.customItems[1].enabled = true;
                menuObj.customItems[2].enabled = true;
                menuObj.customItems[3].enabled = true;
        }
        else {
                // limited state
                menuObj.customItems[0].enabled = false;
                menuObj.customItems[1].enabled = false;
                menuObj.customItems[2].enabled = true;
                menuObj.customItems[3].enabled = false;
        }
}

// decide what to do on a click
function itemHandler(obj, item) {
        trace(obj + " " + item);
        switch (item.caption) {
                case "View/Edit":
                        // snip
                case "Print Call":
                        // snip
                case "Print List":
                        // snip
                case "Email Caller":
                        // snip
        }
}
this.call_list.menu = my_cm;

and just to be sure i also chucked this code on the datagrid:
on (load) {
        this._parent.getCallList();
        this.menu = this._parent.my_cm;
}

and just to be extra sure i also chucked this on the child2 screen in
the Form App:
on (complete) {
        trace(this.content.call_list);
        this.content.call_list.menu = this.content.my_cm;
}

and for posterity i added this to the _root of the Form App:
// cr4p h4ck
this.search_results.content._lockroot = true;
this.search_form.content._lockroot = true;

that's about it. thanks for spending time on this. it's got me cussin.
also, i'm a bit of a n00bie so if you've got any comments on the code, let fly!
G

---
You are currently subscribed to fugli as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to