Pop-ups are parented by SystemManager, not Application.  If you will
search the archives you will find a solution to this.

Tracy

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Dan Vega
Sent: Monday, December 29, 2008 12:03 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Custom Event Problem

 

I thought about that as well but it did not work.

Thank You
Dan Vega
[email protected] <mailto:[email protected]> 
http://www.danvega.org <http://www.danvega.org> 



On Mon, Dec 29, 2008 at 12:01 PM, valdhor <[email protected]
<mailto:[email protected]> > wrote:

Try changing the bubbles property to true. The event needs to bubble
to the top so that the application sees it.



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Dan Vega" <danv...@...> wrote:
>
> For the file manager I am writing I am having an issue with
dispatching a
> custom event. I have a tree on the left with a custom tree item
renderer. In
> that renderer I have setup a context menu so the user can
rename/remove/add
> directories easily.
> 
> private function renameDirectory(event:ContextMenuEvent):void {
> _renamedir = new RenameDirectory
> _renamedir.oldDirectoryName = data.name;
> _renamedir.parentPath = data.parent;
> //add modal window
> 
>
PopUpManager.addPopUp(_renamedir,DisplayObject(Application.application),
true);
> //center modal window
> PopUpManager.centerPopUp(_renamedir);
> }
> 
> My RenameDirectory component works well and does the renaming just
fine. The
> problem I am having is once the folder is renamed i need to refresh
the tree
> to show the changes. I figured for all of my options
(add/remove/delete)
> would just dispatch a custom event. Here is my RenameDirectory.mxml
That is
> dispatching my custom event.
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute"
> title="Rename Directory" width="300" height="125"
> showCloseButton="true" creationComplete="centerWindow()"
> close="closeWindow()">
> 
> <mx:Metadata>
> [Event(name="refreshTree",type="events.RefreshTreeEvent")]
> </mx:Metadata>
> 
> <mx:Script>
> <![CDATA[
> import mx.rpc.remoting.mxml.RemoteObject;
> import mx.controls.Alert;
> import mx.managers.PopUpManager;
> import events.RefreshTreeEvent;
> 
> public var parentPath:String;
> public var oldDirectoryName:String;
> 
> private var ro:RemoteObject = new RemoteObject();
> 
> private function centerWindow():void {
> PopUpManager.centerPopUp(this);
> }
> 
> private function closeWindow():void {
> PopUpManager.removePopUp(this);
> }
> private function renameDirectory(event:Event):void {
> var _old = parentPath + "\\" + oldDirectoryName;
> var _new = parentPath + "\\" + newDirectoryName.text;
> if(_new != _old) {
> // rename the directory
> ro.destination = "ColdFusion";
> ro.source = "FFManager.src.cfc.FileManager";
> ro.renameDirectory(_old,_new);
> ro.showBusyCursor = true;
> 
> dispatchEvent(new RefreshTreeEvent("refreshTree"));
> closeWindow();
> }
> }
> ]]>
> 
> </mx:Script>
> 
> <mx:HBox verticalCenter="0" horizontalCenter="0">
> <mx:TextInput id="newDirectoryName" text="{oldDirectoryName}"
> width="200"/>
> <mx:Button label="Save" click="renameDirectory(event)"/>
> </mx:HBox>
> 
> </mx:TitleWindow>
> 
> And my custom event.
> package events {
> 
> import flash.events.Event;
> 
> public class RefreshTreeEvent extends Event {
> 
> public static const REFRESH_TREE:String = "refreshTree";
> 
> public function RefreshTreeEvent(type:String,
bubbles:Boolean=false,
> cancelable:Boolean=false) {
> super(type, bubbles, cancelable);
> }
> 
> }
> }
> 
> 
> **************** The problem I am having is that I am unable to
listen for
> this event in my main application. If I add
> 
> this.addEventListener(RefreshTreeEvent.REFRESH_TREE,reloadTree);
> 
> The reloadTree method is never called. What am I doing wrong?
> 
> Thanks again..
>

 

 

Reply via email to