Dispatching Event ...first trial ....

Hello
.....see code next....EventTrial object will dispatch an
"trialObjectCreated" event. This is caught correctly with the
method test in the same object. The object "MyFirstApplication"
which creates the EventTrial object also listens to the same event.
But it seems it doesn't "hear" it being generated. Any idea what I
did wrong...
results showing in console:
test dispatched from eventTrial
event dispatche....
[object EventTrial]
[SWF]
F:\FlexSourceData\myFirstApplication\bin\myFirstApplication-debug.swf
- 1.854 bytes after decompression
Thanks
package{
import flash.events.Event;
import flash.events.EventDispatcher;
public class EventTrial extends EventDispatcher {
public function EventTrial(){
this.addEventListener("trialObjectCreated",test);
dispatchEvent(new Event("trialObjectCreated"));
trace ("event dispatche....");
private function test(event:Event):void{
trace("test dispatched from eventTrial");
package {
import flash.display.MovieClip;
import flash.events.Event;
public class myFirstApplication extends MovieClip {
private var eventTrial:EventTrial;
public function myFirstApplication() {
addEventListener("trialObjectCreated", show);
eventTrial = new EventTrial();
trace(eventTrial);
private function show(event:Event):void {
trace ("trialObjectCreated");

You need to add the listener to the EventTrial instance which
is firing the event.
I'm not sure if it will work though, since you fire the event
in the constructor.
Try this:
- Add a method 'fire' to EventTrial which dispatches the
event (and take the event dispatch out of the constructor)
- In your myFirstApplication constructor, create an
EventTrial instance and then add the event listener to that
instance:
public function myFirstApplication () {
this.eventTrial = new EventTrial();
this.eventTrial.addEventListener("trialObjectCreated", show);
this.eventTrial.fire();
}

Similar Messages

  • [Embed(source="...   And dispatching events and trace commands not working

    Hi,
    I have a main swf that Embeds another swf.  In the embedded (child) swf I have trace commands and it dispatches events. 
    I embed the child swf like this:
    [Embed(source="../assets/child.swf", symbol="ChildMC")]
    public var ChildMC:Class;
    var child_mc = new ChildMC();
    child_mc.addEventListener(Event.COMPLETE, childComplete);
    addChild(child_mc);
    function childComplete(event:Event):void
    at the end of the timeline in the child swf I have: dispatchEvent(new Event(Event.COMPLETE));
    When I test the main swf, I can see the child swf, but the main swf can't catch any of the dispatched events and I don't get any trace commands from the child swf.
    How can I catch events from an embedded swf?
    thanks!

    I did a quick sample with two fla's.
    The first loads in a child swf and then calls a funtion on the main timeline:
    var url:String = "loadTestChild.swf";
    var urlRequest:URLRequest = new URLRequest(url);
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete);
    loader.load(urlRequest);
    addChild(loader);
    function loader_complete(evt:Event):void {
       evt.currentTarget.content.callMeFromParent();
    The child swf has this code on the main timeline:
    function callMeFromParent ():void {
              trace ("called from parent whoop");
    Running the parent, the trace is called.
    So with this you should be able to call any function you have in the child from the parent.

  • EVENT FIRST COMMAND AFTER SELECT

    Dear friends
    I'm now using Gemalto Developer's Suite and I want to test this event. However, I try different ways but fail to accomplish my test.
    Do you know any materials, or just anything about this event? I searched throughout various sources, materials but all I have now is a small piece of information in GSM 43.019
    Upon reception of the first command received by the GSM application after it has been selected or after the ATR if it is the default application, and before the Status >Word of the processed command has been sent back by the GSM application, the toolkit framework shall trigger all the toolkit applets registered to this event.
    If the first command received by the GSM application is a toolkit applet triggering command (e.g. TERMINAL PROFILE), the toolkit applets registered on the >EVENT_FIRST_COMMAND_AFTER_SELECT event shall be triggered first.
    The ProactiveHandler and the ProactiveResponseHandler shall not be available at the invocation of the processToolkit method of the toolkit applet on the >EVENT_FIRST_COMMAND_AFTER_SELECT event.From this material, I think it's quite vague to understand clearly this event.
    Thanks in advance,
    Jason
    Edited by: Jason Gosling on Oct 19, 2011 7:29 PM

    hi Jason.
    This is automatic event that was born by OS instead mobile.
    When OS received the first command "00 A4 04 00 00 0xXX + AID APPLET GSM" from User, OS will look in the ToolkitApplet Registry table and find the applet with EVENT FIRST COMMAND AFTER SELECT, then OS call method "process toolkit" of this applet.
    the called applet will do something that it want. Maybe send data to ME.
    When method done, OS continue action normally.
    This is for GSM applet on JavaCard. And the GSM applet is not default program.
    For the case: GSM is default, that mean OS automatic select GSM APPLET when it starts, no need to any command form ME or User, OS auto create this event and look toolkitapplet to run processToolkit method.
    hope this is fun !!

  • On-dispatch-event trigger related to mscomm (load weight from weight scale

    aoa!
    please guide me to pick weight from weight scale.
    i m using mscomm32 ocx for this purpose.
    clarify the role of on-dispatch-event trigger and specify all events
    regarding mscomm and also explain how to trap events for accomplish
    task.
    thanks in advance.
    Tool used:developer 6i & oracle 10g windows xp(sp2)professional.

    Thanks, but I've already seen this thread and done the steps described on it.
    Actually, my question is very specific... How to populate the fields LinkVal and LinkUnit of the registry...
    I read all the threads here in SDN and they don't answer my question...
    I'd be glad if someone had already done tcode HUPAST works for Filizola...
    Tks again.

  • Questions on Dispatching events

    Hey all,
    I have been trying to get a grasp on dispatching events and have a few questions I am hoping you will all be nice enough to clearify for me.
    Do I have to have a custom Event class to dispatch a custom event?
    If so do I have to create a new intance of the event each time I want to dispatch an event. Example:
    dispatchEvent(new MyEvent(MyEvent.TASK_COMPLETE));
    or can I just dispatch an event once an instance has already previously been created.... example:  dispatchEvent(MyEvent.TASK_COMPLET);?
    Thanks,

    hi
    if you dont need to pass any data along with the event then you dont need a custom event, you can just use a custom event name. eg: dispatchEvent(new Event("myEventName"));
    if you want to dispatch the same event multiple times, you can (but not sure why you would want to do that?), eg:
    var e:Event = new Event("myEventName");  [or new MyCustomEvent("myCustomEventName", myCustomData) ]
    dispatchEvent(e);
    dispatchEvent(e);
    dispatchEvent(e);
    dispatchEvent(e);
    dispatchEvent(e);
    dispatchEvent(e);

  • Dispatching events from JNI

    I've got an application that is trying to watch for mouse events anywhere and everywhere. The goal is to be in-the-know when there is mouse activity going on in general, with the Java app running in the taskbar.
    I have determined that I'll likely need JNI to accomplish this, as paying attention to mouse activity over the whole operating system is somewhat operating system dependent. : )
    Nevertheless, I'd like Java code to handle the events, and I can't seem to find any way for JNI to dispatch events back to the Java side of things. My hope was to catch the events thrown by the system in C/C++ and then simply dispatch them again to act as a middle-man.
    If anybody can tell me how I might accomplish this using JNI, or even a step in the right direction, I would greatly appreciate it. Or, if I'm barking up the wrong tree, please please let me know.
    Thanks,
    - J

    Steps in order
    1. Determine how to capture the events in C/C++. There is no java in this step.
    2. Write an API in C/C++ that models the functionality that you want to use in java. There is no java in this step.
    3. Write java/jni that uses the API in 2. There is java in this step.
    As a callback you will need to use the jni attach thread method.
    You better be careful as messing up on any of the steps above can render your mouse inoperable for the entire OS, so learn the keyboard shortcuts.
    I think that someone posted code like this in the past. I could be mistaken however.

  • Dispatching event from Javascript

    Can I dispatch events from javascript to flash player? I am trying to do so by calling dispatchEvent() on flash player dom object but the event is not passing inside flash player. Any links or clue?

    To be specific ... I can catch a right click and supress it. But I want to send it to flash (lets say) as a left click. Problem is when i do that, javascript listner for dom element will get fired for left click but there wont be any events in flash.
    SO the question is can i fire events on flash from outseide or is it outside the public APIs?

  • Dispatching events between different classes

    Im trying to dispatch and event from an XML class.
    dispatchEvent(new Event (XMLClass.INDEX_CHANGED));
    and catch it in the display class
    import AS.XMLClass;
    private var _xml  = new XMLClass();
    _xml.addEventListener(XMLClass.XML_LOADED, swapImage);
    I know that im missing something because the application works
    and the function runs but its not dispatching the event the event
    or maybe it's not catching the event in the display class, even though everything else is working
    and im not gettin' any errors.

    that's exactly what i did.
    i have 3 classes
    AS.XMLClass
    AS.ControlClass
    AS.DisplayClass
    It's like a slideshow thing.
    I have a button on stage thats connected to the control class and every time you press it
    it changes the index of the image in the xmlclass and everytime that the index is changed the xmlclass needs to
    dispatch and event that the index has changed and the display class is going to catch the event and change the image
    everything is working except the xmlclass dispatch event or the displayclass catch event
    XMLCLASS
    public static const INDEX_CHANGED:String = "indexChanged";
    private function dataLoaded(event:Event):void{
                trace("xml file is loaded");
                data = new XML(loader.data);
                dispatchEvent(new Event(XMLClass.XML_LOADED));
                totalItems = data.images.photo.length();
                setCurrentIndex(currentIndex);
    CONTROL CLASS
    import AS.XMLClass;
    private var _xml = new XMLClass();
    public function leftButtonClicked(){
                _xml.setCurrentIndex(_xml.currentIndex = _xml.currentIndex - 1);
            public function rightButtonClicked(){
                _xml.setCurrentIndex(_xml.currentIndex = _xml.currentIndex + 1);
    DISPLAY CLASS
    import AS.XMLClass;
    private var _xml  = new XMLClass();
    _xml.addEventListener(XMLClass.XML_LOADED, swapImage);
    public function swapImage(event:Event){
                trace("working....");

  • Dispatching Event in ItemRenderer Component?

    Am I going about this the right way? Here's my situation:
    I have a custom itemRenderer for a List. This itemRenderer consists mainly of a checkbox and label, but has a few additional details in it (which is why I'm not using a drop-in itemRenderer). I want to detect when the selection of the checkbox changes, so I was thinking of creating a custom event in the itemRenderer and then bubbling it up to the list.
    Or is there a way I can detect when a user checks a checkbox from the lists itself?
    Thanks!

    I found this article which explains this topic very well also: http://weblogs.macromedia.com/pent/archives/2008/03/itemrenderers_p_2.html
    (It appears that these may be referencing the same series of articles on different sites.)
    However, I am now conflicted, because if I the version without bubbling, I am tying the itemRenderer directly to my component; whereas with bubbling I don't need to make that association. I may opt for the bubbling route after all, because I want to keep my itemRenderers generic enough to use in any of my custom controls, and not just in a certain type.
    For more clarification: the hangup is where the event gets triggered on the listData.owner. To do this, it appears that it must be type-cast first, and then manipulated. Any ideas on how to get around that? Here's Peter's example:
    ====================================
    First, you have to add metadata to the CatalogList control to let the compiler know the control dispatches the event:
         import events.BuyBookEvent;
         import mx.controls.TileList;
         [Event(name="buyBook",type="events.BuyBookEvent")]
         public class CatalogList extends TileList
    Second, add a function to CatalogList to dispatch the event. This function will be called by the itemRenderer instances:
              public function dispatchBuyEvent( item:Object ) : void
                   var event:BuyBookEvent = new BuyBookEvent();
                   event.bookData = item;
                   dispatchEvent( event );
    Third, change the Buy button code in the itemRenderer to invoke the function:
                   <mx:Button label="Buy" fillColors="[0x99ff99,0x99ff99]">
                        <mx:click>
                        <![CDATA[
                             (listData.owner as CatalogList).dispatchBuyEvent(data);
                        ]]>
                        </mx:click>
                   </mx:Button>
    Now the Button in the itemRenderer can simply invoke a function in the list control with the data for the record (or anything else that is appropriate for the action) and pass the responsibility of interfacing with the rest fo the application onto the list control.
    ====================================

  • Problem dispatching event a second time

    When the page is first loaded I dispatch an event to get data
    as follows:
    public function init():void
    CairngormEventDispatcher.getInstance().dispatchEvent( new
    CairngormEvent( GetTransactionsEvent.EVENT_GET_TRANSACTIONS ) );
    In one of my functions to insert new data, I dispatch
    getTransactions event again but it doesnt fire:
    private function insertTransactions():void
    { CairngormEventDispatcher.getInstance().dispatchEvent( new
    CairngormEvent( GetTransactionsEvent.EVENT_GET_TRANSACTIONS ) );
    It's only when I remove the first getTransactions event that
    the second instance fires. I am guessing there is some problem
    dispatching a same event twice??
    Can somebody please advise?
    Thanks in advance.

    Yes I have created a brand new event (and also command) and
    everything is working now. However, I tried doing the following but
    it doesnt work (the refresh version doesnt work):
    Event:
    public class GetTransactionsEvent extends CairngormEvent
    public static var EVENT_GET_TRANSACTIONS : String =
    "getTransactions";
    public static var EVENT_GET_TRANSACTIONS_REFRESH : String =
    "getTransactionsRefresh";
    Controller:
    addCommand( GetTransactionsEvent.EVENT_GET_TRANSACTIONS,
    GetTransactionsCommand);
    addCommand(GetTransactionsEvent.EVENT_GET_TRANSACTIONS_REFRESH,
    GetTransactionsCommand );

  • Dispatching events...

    Hi,
    I am working on a project for a system that will not have a mouse. Ideally I would like the screen to function almost like a video game would -- even though it is not a game. By this I mean that all keystrokes are handled at the window level and dispatched to the correct component depending on the keystroke.
    Currently I have inhibited the ability of components on the form to gain focus. When I press a key, the listener associated with the JFrame responds... I then attmpt to use dispatchEvent inside of a case statement to route events to the proper components (In this case a JTextField) The problem is, is that allthough the dispatchEvent call is made, the JTextField doesn't do anything with it. I am just typing characters so I would expect all these keystrokes to show up in the JTextField, but it does not work.
    Does anybody know why this might not work?
    -Benjamin

    Here is a code snippet that actually seems to work. The problem was that I was dispatching a keyPressed event rather than a keyTyped.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class NoFocus extends JFrame implements KeyListener {
       private class JTextFieldNF extends JTextField {
          public JTextFieldNF(int size) {
             super(size);
          public boolean isFocusTraversable() {
             return false;
       JTextFieldNF tfnf;
         public NoFocus() {
          tfnf = new JTextFieldNF(20);
          getContentPane().setLayout(new FlowLayout());
          getContentPane().add(tfnf);
          addKeyListener(this);
         public void keyPressed(KeyEvent evt) {
       public void keyTyped(java.awt.event.KeyEvent evt) {
          switch (evt.getKeyCode()) {
             // Route up and down key somewhere else
             case KeyEvent.VK_UP:
             case KeyEvent.VK_DOWN:
                break;
             // All keystrokes not expicitly used are piped to tfnf
             default:
                      tfnf.dispatchEvent(evt);
       public void keyReleased(java.awt.event.KeyEvent A) {
         public static void main(String args[])
              JFrame frame = new NoFocus();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(200,200);
              frame.setVisible(true);

  • Dispatching Events - External SWF & Main Stage

    Hi Everyone
    I am dispatching two different events showbutton and removebutton from the code inside the LOADED SWF.
    on main file, (the one that is loading the swf file) i m listening for events and either showing or removing the
    buttons based on proper scenario. Here is he error i m getting. I appreciate if someone can help me understand
    the problem thanks.
    ERROR   1180  Call to a possibly undefined Method Event   - - - > dispatchEvent(new Event("showbutton"));
    -----------------EXTERNAL SWF -----------------
    dispatchEvent(new Event("removebutton"));
    dispatchEvent(new Event("showbutton"));
    -----------------MAIN STAGE-----------------------
    movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler)
    function loaderCompleteHandler(event:Event) {
        (event.currentTarget.content as MovieClip).addEventListener("removebutton", categoryClickHandler);
        (event.currentTarget.content as MovieClip).addEventListener("showbutton", categoryClickHandler2);
    function categoryClickHandler(event:Event):void {
        alaarm.visible=false
    function categoryClickHandler2(event:Event):void {
        alaarm.visible=true
        trace("yohoo");

    MathAdor,
    Have you considered solutions that don't involve event handlers available to AS3.
    If I understand correctly you are trying to:
    1.  Control buttons that exist in your main .swf file
    2.  Control the visibility of those buttons from a child .swf called into existence from the main .swf file
    You could control this completely from the child .swf by setting a variable for your parent .swf
    In your child .swf creat a variable that contains the parent movieclip:
    var myParentClip:MovieClip = MovieClip(parent.parent);
    Now control your buttons with the appropriate command from your child
    myParentClip.buttonName.visible = true;
    myParentClip.buttonName.visible = false;
    Total control from your child .swf
    Hope this helps

  • Dispatch Event for loaded Netconnection datas

    Hi All!
    I made a manager component to retrieve data from database
    through amfphp.
    When the datas are loaded at the end of the "onResult"
    function, I dispatch an event "contactLoader"
    Another parent mxml component has an instance of my manager
    component with a call to a function contactLoader="getData()",
    and then this function calls in turn the getContacts()
    function of the instantiated manager component to retrieve the
    datas. Thus I am sure that the datas are correctly loaded by my
    manager before to retrieve the Array.
    But I would like to refresh this array in case any change has
    been made in the database. The problem is that the listener is
    created automaticly by the instance of my manager component and the
    "contactLoader" already exists once the data are loaded once. I
    need a way to reload the data in the manager , create a new event
    once the data are downloaded and then my parent component can call
    one more time the getContacts function.
    Is it the right way to do that? I'm not skilled enouth to
    solve that problem. Thanks for your help.

    "badoumba" <[email protected]> wrote in
    message
    news:gk57nf$oak$[email protected]..
    > Hi All!
    > I made a manager component to retrieve data from
    database through amfphp.
    > When the datas are loaded at the end of the "onResult"
    function, I
    > dispatch an
    > event "contactLoader"
    > Another parent mxml component has an instance of my
    manager component with
    > a
    > call to a function contactLoader="getData()",
    > and then this function calls in turn the getContacts()
    function of the
    > instantiated manager component to retrieve the datas.
    Thus I am sure that
    > the
    > datas are correctly loaded by my manager before to
    retrieve the Array.
    >
    > But I would like to refresh this array in case any
    change has been made in
    > the
    > database. The problem is that the listener is created
    automaticly by the
    > instance of my manager component and the "contactLoader"
    already exists
    > once
    > the data are loaded once. I need a way to reload the
    data in the manager ,
    > create a new event once the data are downloaded and then
    my parent
    > component
    > can call one more time the getContacts function.
    I'm not sure what the issue is...you can fire a new
    contactLoader event
    whenever you need to.

  • Class is not dispatching Event without timer of 1 second. Why?

    Hi All,
    I have created a class Called ClassA and ClassA creates a instance of ClassB and adds the listener to ClassB. Then after some processing ClassB dispatches the event.
    Issue:- ClassB is only able to dispatch the event if I call the dispatchEvent(new Event(Event.COMPLETE)) function in ClassB by giving the 1 second interval otherwise it is not sending any event.
    Question-Could someone explain this behaviour?

    Then you should probably post the question in the ActionScript 3 forum.
    This forum is for OpenType Font Development Kit questions.

  • Dispatching Events on overlapping Components

    Hello,
    i use a layered pane that contains some custom components. How can I make that two overlapping components that reside in the same layer both receive a mouseEvent?
    At the moment, only the Componet above receives the event - I know I can pass an Event with dispatchEvent - but i don't know the instance of the component to which to pass it of course... Is there any method to dispatch the event without having to know to which component to pass it?
    Any help appreciated.
    Best regards & Thanks.
    alex

    You can use use EventQueue.postEvent to post the event, but it requires source and if it is mouse event it will be later retargeted to correct components according to coordinates. So the only way for you to do this is to find the components by yourself and call processMouseEvent on it.

Maybe you are looking for

  • Ideapad Y450 - Vista to Windows 7 upgrade comedy routine

    I've looked for information on how to upgrade my y450 (Vista) to Windows 7 but have been unable to find what i am looking for. The lenovo page for Ideapad windows 7 information is a dead link.  What are the steps to install windows 7 on the laptop? T

  • How to maintain Authorized buyer for a customer in Sales Order.

    Dear all, We have a corporate customer, which has 10 authorized buyers. We have created a Customer number for this company. But at time of sales order creation, we need enter the authorized buyer name in sales order for the record purpose. we are not

  • No Blackberry ID shown on Playbook in General section of the ABOUT Tab...

    I have a collection of Playbooks with no Blackberry ID established...   Current version is 1.0.0.0 or 1.0.1...  in either case the playbook will not update wi fi fashion because without the ID the playbook will not connect with the Update Server.. So

  • ADF Security against database?

    I am working with JDeveloper 10.1.3.4 on a project which uses adf/bc and adf faces/jsf 1.1; the application is deploying to iAS 10.1.3.4 and is hooked as a mid-tier instance via SSO to an infra iAS instance on another machine. How do you change ADF S

  • Lock_lint for LINUX RHEL5

    As a Software QA, I am interested in the field of Static Analysis for multithreaded software. In particular early detection of dead locks or data inconsistency. I have been made aweare of the "Lock_Lint - Static Data Race and Deadlock Detection Tool