A custom, shipped event from custom mxml component isn't triggering the eventListener parent App

I have a problem trying to fix now... Here's what happens:

(1) I have a custom, event that is just CustomEvent.as that extends event.

(2) when I close a TitleWindow, calling dispatchEvent (myEvent), where myEvent is an instance of the CustomEvent.

(3) I checked the event get sent, because the Boolean that returns the dispatchEvent method is set to 'true '.

(4) the eventListeners on the application parent never called.

I use this process on another custom event and eventListener and it works.  It does not for this one.  Here is my code:

/ * The custom event class

**/

package me.events.Events

{

import flash.events.Event;


/public class CustomEvent extends Event

{

Public static const WINDOW_CLOSED:String = "windowClosed";

public void CustomEvent (type: String, bubbles: Boolean = true, cancelable: Boolean = false)

{

super (type, bubbles, cancelable);


}

}

}


/ * The MXML component

**/

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

" < = xmlns:mx mx:TitleWindow ' http://www.Adobe.com/2006/MXML "layout ="absolute"width ="400"height ="300"title ="replaced"showCloseButton ="true"borderStyle ="solid"cornerRadius ="0"creationComplete ="init (); "close ="windowCloser (); » >

< mx:Label x = "10" y = "10" text = "" project name: "fontWeight ="bold"/ > "

< mx:Label x = "10" y = "50" text = "' Description of the project:" fontWeight = "bold" / > "

< mx:Script >

<![ CDATA [ ]

import me.events.CustomEvent;

Public static const WINDOW_CLOSED:String = "windowClosed";

public void init (): void {}

private function windowCloser (): void { }

var myEvent:CustomEvent = new CustomEvent();

dispatchEvent (myEvent);

PopUpManager.removePopUp (this);

}

]]>

< / mx:Script >

< / mx:TitleWindow >


/ * The parent application

**/

" < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationPolicy ="all"creationComplete ="init (); » >


< mx:Script >

<![ CDATA [ ]


private function init (): void { }

this.addEventListener (CustomEvent.WINDOW_CLOSED, myHandler);

intro = model.getIntro ();

PopUpManager.addPopUp (intro, this, true);

PopUpManager.centerPopUp (intro);

}


private void myHandler(e:CustomEvent):void { }


//THIS IS NEVER CALLED!

}


]]>

< / mx:Script >


< / mx:Application >


If you display the TitleWindow as a popup, which is probably the problem, because the pop - up is not in the same display as the application list below systemManager. You may need to add the event listener to the systemManager.

See my Flex 3 post recipe book where I use custom events and add event listeners to the systemManager:

http://www.Adobe.com/cfusion/CommunityEngine/index.cfm?event=ShowDetails&ProductID=2&postI d = 11246

If this post has answered your question or helped, please mark it as such.

Tags: Flex

Similar Questions

  • How to reference an ActionScript file in a custom MXML component

    I have a custom MXML component located in a folder with this path:
    src/com/LoginForm.mxml
    I have functions in an ActionScript file located here:
    src/as/SharedObjects.as

    I would like to refer to the AS file in the MXML component. I tried two different ways, but no work:
    < mx:Script source="as/SharedObjects.as"/ > and.
    include "ACE/SharedObjects.as";
    I get the error "unable to open included file...". »
    If I copy the AS file in the same folder as the component, an include statement in the script component works:
    include 'SharedObjects.as ';

    But I reference the same FILE in the other application MXML and other files HAVE, so I don't want to keep two copies of it.

    What I'm doing wrong here? Thank you!

    Greg,
    The line:

    has worked!
    Thanks for the help. I just could not 'get it '! It was the ".." that I had not tried.
    ntsiii, thanks for your help, too.
    Have a great day.

  • Is that what I can pass the "Builder" parameters to the custom mxml component

    I would like to create a generic dialog box (popup) using mxml and then have my subclass of dialog boxes specific to application it.  I would spend at least a parameter to the instantiation, so there the reference to its parent window.  My code looks like this so far

    private static var DebugPopup:DebugViewer;

    public static void creationComplete(event:Event):void {}
    MainWindow = event.target as DisplayObject;
    DebugPopup = new DebugViewer (MainWindow);  //only works if no parameter passed
    }

    -DebugViewer.mxml looks like this - some code removed for reasons of brevity-

    < mx:TitleWindow >

    < mx:Script > <! [CDATA]
    Import mx.managers.PopUpManager;

    [Bindable] public var ParentWindow:DisplayObject;

    [Bindable] public var buffer: String = "Insert power ici\n;

    public void log(text:Object):void {buffer += text + "\n";}   }

    public void display ( parent: DisplayObject): void {}
    PopUpManager.addPopUp (this, parent);
    PopUpManager.centerPopUp (this);

    }
    []] > < / mx:Script >
    < mx:TextArea width = "400" height = "300" text = "{buffer}" / >

    < / mx:TitleWindow >

    I would like to set the parent window when I instantiate the dialog box, rather than go through the show method.  Is there a way to do this in a mxml component or I have to go to ActionScript.  I intend to make a general class of dialogue which is then subclssed by all of the specific dialogue of my application.

    You can do this:

    DebugPopup = new DebugViewer();
    DebugPopup.ParentWindow = MainWindow;
    
  • Sending events from instances of the class

    Hello
    I have problems with dispatching events from instances of class.
    In a simple MXML application, I added an event listener for a custom event.
    In accordance with the rules of good practice MVC, I have a template with a single instance (singleton pattern) class. This instance has no reference to my MXML component. When my model receives the data from the server, I want to send an event of this forum (which isn't in the displayList!). I could solve that problem with a model of the observer, but there is no way to any shipment of the event?
    Help much appreciated!
    Dany

    Hello Cesare,

    It works indeed! Thanks a lot for your help here!

    Dany

  • Easiest way to send an event from a custom component

    Hello
    I have a custom login form, and I would like to create an event that is raised when the authentication returns true from the server. Right now I have a result event in the component to handle the Boolean condition of webservice. I tried simply instantiating a new event (public var auth:Event = new Event () ;) inside the element and the distribution of this event of the logic of the Manager resultEvent. But, outside the element, not no symbol bit next to the auth event lightning bolt as appropriate to call an event from the mxml.

    I want to be able to instantiate this event since the mxml listener and manage the event from outside the custom component. Should which model I use to encapsulate the event?

    Thank you
    JED

    Amy Blankenship was very helpful with his post to:
    http://flexdiary.blogspot.com/2007/08/dispatching-events.html

    Handycam was also OK, but missed me the key I needed.

    And would work on the idea of Greg, but I wanted to encapsulate the event so that the handler in myComponent.parent could be instantiated in this component.

    Here's what I ended up doing:

    in the mxml component


    [Event (name = "authenticated", type = "flash.events.Event")]

    The logic of management in the method

    private void testValidation(event:ResultEvent):void
    {if(event.result == true) dispatchEvent (new Event ("authenticated")) ;}}

    in the main application

    When you use the meaning of code in Flex Builder, "authenticated" came as a selection of events valid.

    Thanks again everyone,
    JED

  • 12 c: queryListener custom af:table component - how to get the filter values?

    Hello

    in a queryListener custom on an element of af: table, I am trying to print the values of the filter fields (for example to do a validation)

    public void onQuery(QueryEvent pQueryEvent)
     {
     RichTable vRt = (RichTable)pQueryEvent.getComponent();
     CollectionModel vModel = (CollectionModel)vRt.getValue();
     JUCtrlHierBinding vData = (JUCtrlHierBinding)vModel.getWrappedData();
    
     ConjunctionCriterion vCc =
     pQueryEvent.getDescriptor().getConjunctionCriterion();
     for (Criterion vCriterion: vCc.getCriterionList())
     {
     if (vCriterion instanceof AttributeCriterion)
     {
     AttributeCriterion vAttCriterion =
     (AttributeCriterion)vCriterion;
     AttributeDescriptor vAttDescriptor =
     vAttCriterion.getAttribute();
     System.out.println("Type: " + vAttDescriptor.getType());
     System.out.println("Name: " + vAttDescriptor.getName());
      System.out.println("Value: " + vAttCriterion.getValue());
     
     }
     }
    
     JSFUtil.invokeMethodExpression("#{bindings." +
     vData.getIteratorBinding().getName().replace("Iterator",
     "Query") + ".processQuery}", Object.class,
     QueryEvent.class, pQueryEvent);
     }
    
    
    

    However... the value of the filterfield (System.out.println ("Value:" + vAttCriterion.getValue ());) is always null after the seizure of a filter value and pressing on enter the af: table.

    The table is the filter properly.

    How can I get the values of the filter fields in the queryListener?

    Kind regards

    Koen Verhulst

    Keon, in my blog JDev 12 c: how to reset a filter on an af:table channel 12 c | JDev & amp; ADF Goodies that I use

    /**

    * method to reset filter attributes on an af:table

    * @param actionEvent event which triggers the method

    */

    publicvoidresetTableFilter(ActionEvent actionEvent) {

       FilterableQueryDescriptor queryDescriptor = (FilterableQueryDescriptor) getEmpTable().getFilterModel();

       if(queryDescriptor != null&& queryDescriptor.getFilterConjunctionCriterion() !=null) {

           ConjunctionCriterion cc = queryDescriptor.getFilterConjunctionCriterion();

           List lc = cc.getCriterionList();

           for(Criterion c : lc) {

               if(cinstanceofAttributeCriterion) {

                   AttributeCriterion ac = (AttributeCriterion) c;

                   ac.setValue(null);

               }

           }

           getEmpTable().queueEvent(newQueryEvent(getEmpTable(), queryDescriptor));

       }

    }

    to reset the values. You should be able to get the values of the same way.and print the values to set them to null instead.

    Timo

  • Change the list with Custom MXML itemRenderer DP problem

    Hello

    I have a list of spark with a custom MXML itemRenderer which has two States.

    One or the other is based on a property of data.isTrue, as follows:

    override protected function getCurrentRendererState (): String

    {

    If (Data.isTrue) {return 'TrueState' ;}

    Back to 'FalseState ';

    }

    When data.isTrue is set to true, the TrueState has the value that has a small arrow on the right side.

    When the dataProvider is replaced by a new collection, it restores all data correctly, except the image that is always visible when isTrue was true to the previous data set.

    To the overview, the arrow disappears.

    How can I fix this please?

    You may need to add a substitution of data layer that calls invalidateRendererState

  • Questions about custom DataGridColumn component converter

    Hey guys,.

    I am very new to flex, but he really likes.

    Part of my task is to display data with the DataGrid control. Sounds very simple, isn't? However, the data themselves are a mess, and he needs a custom code to make it presentable. My problem is the following:

    one of the columns is supposed to be a positive number. If the number is less than 0, then do not display or display an empty cell. I tried in several ways:

    1 tried to use < mx:Text text = "{((data. TotalGFA < 0)? "": data. " TotalGFA)}"/ >. He complains unmatched ' > '.

    2 tried to use a function < mx:Text text = "{getPositiveNumber (data." TotalGFA)}"/ >. He complained of function not defined

    3 tried extending mx:Text and the substitution of the text box. But I couldn't find any help.

    Is this possible? How to make it work?

    Thank you

    C

    You can simply use the DataGridColumn labelFunction.

    You have problems with your second appearance being itemRenderers

    scope differently from the parent app.

  • Link to mxml component in Flex

    I have component text.mxml. that shows me the following:
    < mx:DataGrid id = "dgShowHistory" width = "100%" >
    < mx:columns >
    < mx:DataGridColumn headerText = "ID" / >
    < mx:DataGridColumn headerText = "Number of cases" / >
    < mx:DataGridColumn headerText = 'Number group' / >
    < mx:DataGridColumn headerText = "Name" / >
    < mx:DataGridColumn headerText = "Status" / >
    < / mx:columns >
    < / mx:DataGrid >

    Now the in column case number I want to add a link to SearchCaseNumber.mxml...
    So let's say that the number of cases has the following:
    File number
    1234
    1235
    1236
    I would like to be highlighted as a link and when I click on these he takes me to the SearchCaseNumber.mxml put the 1234 automatically in search and if possible to fill all the fields on this basis.

    In SearchCaseNumber.mxml
    < mx:TextInput id = "CaseSearch" width = "81" / >

    The sale is to add a listener for the itemClick event to text.mxml itself (because it will bubble of the events of the grid) whenever use you and manage this click using case-sensitive appropriate in SearchCaseNumber.mxml.

    A more robust and more modular way to do this would be for your text.mxml listen to events itemClick on the grid, and in this dispatch from the listener a custom wrapping more event structured information on if clicked on. For example, you can send something like a CaseClickEvent, something personalized that extends the event and adds caseNumber, groupNumber, caseName fields and the State (or even just tie a subject of the case, if you have business objects in your model).

  • How to raise an event from the arrayCollection collection?

    I'm passing data from a model to a view in the following files. It works fine, but I want to send a message on the screen when an arrayCollection collection is filled. I know that I could create a custom event, but I do not understand why the eventhandler I created will not work. Please tell me what I'm doing wrong.

    Thank you.

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    [Bindable] private var databaseDataArrayCollection:ArrayCollection = new ArrayCollection collection;
    [Bindable] private var: model = new modele();
    [Bindable] private var: controller = new Controller();
    private function init (): void {}
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model = Model.createInstance ();
    controller.getData ();
    }
    private void change(e:Event):void {}
    trace ("changed in sight")
    }
    []] >
    < / mx:Script >
    < mx:DataGrid dataProvider = "{model.databaseDataArrayCollection}" > "
    < mx:columns >
    < mx:DataGridColumn id = "first name" dataField = "first name" headerText = "FIRSTNAME" / >
    < mx:DataGridColumn id = "lastName" dataField = "lastName" headerText = "LAST NAME" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Application >

    Model.As

    package {}
    Import mx.collections.ArrayCollection;
    [Bindable]
    public class {model
    public var databaseDataArrayCollection:ArrayCollection = new ArrayCollection();
    private static var: model = new model;
    private static var num:Number = 0;
    public void modele() {}
    }
    Public Shared function createInstance (): model {}
    NUM ++
    if(Model == null) {}
    model = new modele();
    }
    return the template;
    }
    }
    }

    Controller.As

    package {}
    import com.simon.cms.UrlString;

    import flash.events.Event;

    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    Import mx.rpc.http.HTTPService;
    Import mx.utils.StringUtil;

    [Bindable]
    public class {controller
    private var: model = new modele();
    public var httpService:HTTPService = new HTTPService;
    private var login_string:UrlString = new UrlString();
    public void Controller() {}
    model = Model.createInstance ();
    }
    public void getData (): void {}
    var params: Object = new Object();
    httpService.url = login_string.login;
    httpService.method = "GET";
    httpService.addEventListener (ResultEvent.RESULT, extractData);
    httpService.send (params)
    }
    private void extractData(event:ResultEvent):void {}
    httpService.removeEventListener (ResultEvent.RESULT, extractData);
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model.databaseDataArrayCollection = event.result.student.task;
    }
    private void change(e:CollectionEvent):void {}
    trace ("Changed in the collection")
    }
    }
    }

    You use "=" this is a reversal/replacement.  There is no chip

    assignment that will update.

    You could do

    model.databaseDataArrayCollection.source =

    Event.Result.Student.Task.source;

    That should translate into a CollectionEventKind.RESET in original HQ as it

    now a new set of data.

  • shipping events

    Hi all:

    I'm trying to find a way inform a data component in the previous component have been modified. My first time through my application, everything works fine as long as I move forward through the app... events fire, my main application file goes to the correct state, etc. However, if I go back and change the information on one of my previous screens, I need to find a way to tell the successive screens of information has changed and that they must call RemoteObjects with a new set of parameters for information updates. I am sending an event from screen 2 to say my main application file to change the State of the 2 back to the screen 1 screen, then screen 1 return to the 2 screen, but when I change my selection on the screen 1, screen 2 information is not updated.

    Here's what I've tried so far:

    1. I tried to send my application file event main IE screen 2 my initial selection had changed, but my event handler on the screen 2 never took the event. Can I still do? Seem me to remember reading something that said that it was possible to dispatch events up the chain component (from child components upward as much as the main file of the application), but not down, but I can't remember where I read that if I have not been able to check for myself.
    2. I tried just re - initialize Screen 2 of DataProvider with updated info (for example, to do something like my main application file):
    3. if(iWentBack == true)

      {

        screen2ComponentID.getRemoteObjectDataResult = null; to clear the previous selection

        screen2ComponentID.getRemoteObjectDataResult.token = remoteObject.remoteFunction (newSelectionFromScreen1); to get the data updates to my new selection

      }

      When I try this, I erased successfully out of my previous data, but on the screen 2 I just get null on my data provider (so I don't get the updated results of my call to the remote object). I tried simply calling the method init() of Screen 2 of the main application mxml file, but that produces the same results (nulls on screen 2). I'm trying to do the impossible here?

    Thanks in advance for your suggestions!

    ~ Amanda

    Hi amandamartino,

    Can you please what is your application structure in which you placed the screens... something like below

    One thing you can do here is to ship an event regarding systemManager in your main application and also try to listen for the event regarding systemManager in your screen2.

    So in your main application send you an event like this...

    In your main application

    Application.application.systemManager.dispatchEvent (new Event ("mainAppDataChanged"));

    In your 2 screen will listen w.r.t. systemManger as event below...

    Application.application.systemManager.addEventListener ("mainAppDataChanged", onMainAppDataChanged);

    private void onMainAppDataChanged(event:Event):void

    {

    Application.application.systemManager.removeEventListener ("mainAppDataChanged", onMainAppDataChanged);

    write your logic and update changes to data here...

    }

    Be sure to remove the event listener that I made in the onMainAppDataChanged() function...

    Do you take the event in the screen2 shipped from the main application...

    If this post answers your question or assistance, please mark it as such.

    Thank you

    Jean Claude Chari

  • Need help for OFA... Add custom region Embedded standard page in the module iproc

    Hi gurus,

    I have a requirement where in iproc page standard box... I need to add a custom regionRN

    This custon regionRN hold 4 dropdown lists dl1, dl2, dl3, dl4... All have values YES/NO

    a > when the user selects dl2 that YES, a pop-up window should open with some message... Please suggest how to achieve?

    b > when the user selects dl3 as no.... then only the 4th dl4 drop-down list should visible or true rendering

    Once the user selects it every three or four drops to the bottom of the list, then when the user clicks a button on the standard page as save or submit this drop-down list of all the selected values must go and insert into a custom table?

    and whenever the user navigates forward or backward from inside the session or change the generated query that time, previously selected in the drop-down list values must be kept on the page.

    --------------------------------------------------------------------------------------------------------

    My analysis and workaround:

    1 created a new Stacklayout RN and attached to the page using personalization, created a new CO custom, AM and for YES/NO VO and VO for the database table custom

    2. I am able to select values from drop-down lists and be able to insert in the table BE using package... instruction callable but not able to maintain the session i.e. When will transmit to the user or to the back then the saved values is not, displayed how t get it suggest it please?

    How do I start the table base VO in my PR to reach the recorded values and need to update the drop-down list lists while the page is loading, please suggest?

    3. How can I get the event of the standard page button in my custom CO?

    4. How do I get a popup feature?

    Please send me a message on [email protected]

    Please please help

    Thank you

    Mahesh

    Please share some links or doccs or code or anything that can help me.

    Hello Manu,

    You cannot open a region like this. You would need a new page of little OAF who would open as popup. What really happening setForwardURL called a new page, but since we have an emebded javascript in the URL it behaves like a popup.

    With the help of OADataBoundEmebdedURL analysis just this URL for any security issues.

    PopURL = string

    "OA.jsp?page=/xx/oracle/apps/xx/webui/xxPGL¶mOne={@viewAttr1}¶mTwo={@viewAttr2}";

    JsUrl = OABoundValueEmbedURL

    new OABoundValueEmbedURL (imagebean, ' openWindow (auto, "",) ")

    popURL,

    "', 'longTipWin', {width:}" + 800 +.

    ", height:" + 800 +.

    "}(, false); return false; ») ;

    You can call forwardURL on the action of messageChoice.

  • MXML Component that is not on the Web

    I have a custom component that serves as a VBox container for several button elements are accessible by scrolling up and down with the actionscript functions.

    Initially, I put this directly in my project and it worked great - however, my boss wants to use it in several places. My first instinct was to copy the code and paste it into a MXML component.

    When I drag the component on the canvas, he makes it in Flex builder Design view and I see that everything is there... but, when I go to build the project and test it in the browser - nothing is displayed on the canvas!

    Any ideas of what could be the cause?

    I had the same problem as you said here. I have pasted the code in a mxml component and added to a canvas. I noticed that you have not set a height and width for this element, so I did it and everything worked well.

    Kind regards
    Peter

  • How to raise events from within an event to an another event-structure

    Hello

    I have two events-structures (struct1 struct2) that are running on the same parallel of time in a loop.

    Currently there is a keydown event in struct1, so when I press a button, then the corresponding event runs in struct1.

    STRUCT2 is used to execute a custom-Petite runtime menu entries.

    What I want to do is to choose a menu entry (which runs a struct2 event) and the of inside this event I want to trigger an event in struct1 (means simulates keypress?).

    Is this possible?

    Thanks for the help

    Use the event to the button, not the keydown event.

    Then in the second structure of the event, use the Value property (signs) of the ok button to trigger the value Change event.

    Felix

  • Help to create the MXML component

    I can't understand how to create a simple component in FB4:

    I create a folder in the src folder, called "components".

    I click with the right button on components and select new > MXML component

    In the resulting dialog box, in front of the light, when I pess the search button, all I get is a choice, "spark.components.Group.

    I don't know where to go from there.

    So how, exactly, I created a component based on, say, ComboBox?

    Just type "Combo" in the text field to the light and select ComboBox spark or MX ComboBox control from the drop-down.

    Peter

Maybe you are looking for