I have a dilema. I’m trying to create a flash application that is basically a rich text editor
well, I’m trying to make a menu component to open a window component which has a close button
here is a part of my code (attempt 1):
import mx.controls.Menu;
import mx.controls.MenuBar;
import mx.managers.PopUpManager;
import mx.containers.Window;
var my_mb:MenuBar;
var myProfile:Menu = my_mb.addMenu("My Profile");
myProfile.addMenuItem({label:"View/Edit Profile Information", instanceName:"newInst"});
myProfile.addMenuItem({label:"See My Profile", instanceName:"openInst"});
//THE LISTENERS
var mbListener:Object = new Object();
mbListener.change = function(evt_obj:Object) {
var menuItem_obj:Object = evt_obj.menuItem;
switch (menuItem_obj.attributes.instanceName) {
case "openInst":
var my_win:MovieClip = PopUpManager.createPopUp(this, Window, true, {closeButton:true, contentPath:"openDialog"});
var winListener:Object = new Object();
winListener.click = function() {
my_win.deletePopUp();
};
my_win.addEventListener("click", winListener);
break;
}
**The problem with this script: **when I test the movie, the movie freezes and Flash asks do you want to disable the script and etc…
so I tried doing the same by attachMovie() :
//THE STUFF FROM BEFORE
switch (menuItem_obj.attributes.instanceName) {
case "openInst":
_root.attachMovie("Window","openInst",this.getNextHighestDepth());
openDialog.setSize(623.9,310)
openDialog.closeButton = true;
openDialog.contentPath = "openDialog";
openDialog.title = "Open Document";
//HERE IS THE PROBLEM:
openDialog.close = function() {
trace("Closing...");
removeMovieClip(_level0.openInst);
}
break;
The problem from the 2nd Code Box: I can’t close the box. When I press the X, it won’t close it.
So…basically what I’m asking is…How do I call a Window Component from a Menu Bar Component and let the Window Component also close correctly when the user closes it.
Thanks in advance for your great help!