DispatchEvent

I'm modeling an application after the ReviewTube sample
application. That application the following class defined. I wrote
a class almost identical to this and I get an error "1180: Call to
a possibly undefined method dispatchEvent." on the line with the
call to dispatchEvent. I have no idea why I'm gettting the error
but the ReviewTube sample doesn't. In looking at the below class I
do not see where the definition for dispatchEvent is coming from.
Can anyone explain?
quote:
package com.joeberkovitz.reviewtube.model
import flash.events.Event;
[Event(name="selectedVideoChange",type="flash.events.Event")]
public class Session
[Bindable]
public var currentUser:User;
private var _selectedVideo:VideoInfo;
[Bindable("selectedVideoChange")]
public function get selectedVideo():VideoInfo
return _selectedVideo;
public function set selectedVideo(v:VideoInfo):void
if (v != null && v != _selectedVideo)
_selectedVideo = v;
dispatchEvent(new Event("selectedVideoChange"));

Hi, Alynn,
Thanks for the e-mail. I am a newbie and really want to figure out what is going on with the
Here is what I do
1) In the constructor of the frame subclass, I add the three buttons something like
formatButton=new JButton("Format");
formatButton.addActionListener(this);
formatButton.setEnabled(true);
formatButton.setLabel("Run");
2)In action handler I have
public void actionPerformed(ActionEvent e) {
     String cmd = e.getActionCommand();
     if (cmd.equals("Run")) {
// do something
else if(cmd.equal("Stop"){
// do something
else if (cmd.equals("Close Port"))
portClosed();
formatButton.dispatchEvent(new MouseEvent(formatButton,
MouseEvent.MOUSE_CLICKED, 1 , MouseEvent.BUTTON1_MASK, 1, formatButton.getLocation().x+2, formatButton.getLocation().y+2, false, MouseEvent.BUTTON1));
I didn't have any special eventlistener, is the above code ok?
Thanks,
Larry

Similar Messages

  • How do I use the event.target.name String with an external dispatchEvent?

    ...I hope the title question makes sense...
    On my stage I have an externally loaded SWF with a button. When clicked the button dispatches an event to the main stage.
    On the main stage a listener then loads an SWF into a loader called gallery.
    The gallery loader is also being shared by buttons on the main stage which use the event.target.name String to call in SWFs with corresponding names.
    I am using Tweens to fade-out and -in content to the gallery when a button is pressed.
    Loading the SWFs was working until I tried to create a universal button function for the dispatchEvent buttons...
    The problem I have is that I don't know how to define the String to tell the newSWFRequest where to find the SWF when triggered by the external buttons.
    (I may be doing this all wrong... but figured the best way to load an SWF on to the main stage from an external SWF was by using dispatchEvent??)
    My code triggers the Event and the gallery loader fades out, but then it cannot find the new SWF:
    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
    Please can someone help me understand the way to make the String point in the right direction? (I think the only errors are in bold below)
    Code:
    var myTweenIn2:Tween;
    var myTweenOut2:Tween;
    var nextLoadS2:String;
    // Listen for external event dispatched from external btns
    addEventListener("contactStage", btnClickExtrnl);
    function btnClickExtrnl(e:Event):void {
    nextLoadS2 = ?????
    myTweenOut2=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOut2.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    // Btns Universal function
    function tweenOutCompleteF2(e:TweenEvent){
    myTweenOut2.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
    myTweenOut2=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + nextLoadS2 + ".swf");
    myTweenIn2 = new Tween(gallery, "alpha", None.easeOut, gallery.alpha, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    Thank you.

    That works – thank you!
    I'm now using this code to fade in each of the SWFs:
    function contactStage(e:MouseEvent):void {
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
        myTweenIn = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But I cannot add the fade out function. I have amended the above code to create:
    var myTweenOutX:Tween;
    var myTweenInX:Tween;
    function contactStage(e:MouseEvent):void {
    myTweenOutX=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
    myTweenOutX.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    function tweenOutCompleteFX(e:TweenEvent){
    myTweenOutX.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteFX);
    myTweenOutX=null;
        var newSWFRequest:URLRequest = new URLRequest("swfs/"+e.currentTarget.name+".swf");
    myTweenInX = new Tween(gallery,  "alpha", None.easeOut, 0, 1, 0.2, true);
        gallery.load(newSWFRequest);
        gallery.x = Xpos;
        gallery.y = Ypos;
    But get this error:
    ReferenceError: Error #1069: Property name not found on fl.transitions.Tween and there is no default value.
    at ACOUSTIC_fla::MainTimeline/tweenOutCompleteFX()[ACOUSTIC_fla.MainTimeline::frame1:110]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.transitions::Tween/set time()
    at fl.transitions::Tween/nextFrame()
    at fl.transitions::Tween/onEnterFrame()
    Where am I going wrong?

  • PlugPlug DispatchEvent() takes too long

    Hi all,
    I'm using the PlugPlug interface to send events between my native Photoshop plug-in and my CEP extension.
    I've a slightly modified version of the code provided in the Adobe Illustrator SDK (SDKPlugPlug.[h|cpp]) and I'm able to communicate successfully between my two components.
    However, here comes the good fun : The interface specifies the Event structure, which contains a data field, but there's no data size. I have assumed this data buffer SHOULD be a null-terminated string when passed to the DispatchEvent function, which means I need to text-encode a good bunch of binary data I need to send via the event.
    I'm experiencing that the communication takes reaaaaaaaly long (within PlugPlug.dll), to the point that Photoshop get's blocked for about half a minute for sending 1MB of data.
    Not sure what's going on, but this does not work for what I need to do, to the point that I have ended up implementing my communication, until finding a better solution, using an internal socket.
    Is there an alternative or a way of doing this that you are aware of?
    Thank you.
    Arturo.

    I don't have this problem - but a bunch of other people have youtube problems since upgrading to Yosemite.Yosemite 10.10.1 causing Safari not to play YouTube videos...

  • DispatchEvent not working in debug mode

    Hello,
    I have a localconnection, and when I receive a message from
    the local connection I dispatch an event. However, the dispatch
    event does not work. I step into the code and go into some
    Macromedia code for the "mx.events.EventDispatcher.dispatchEvent"
    and "mx.events.EventDispatcher.dispatchQueue", and when I inspect
    my variables the eventObj has both a target and a type set, but
    when the code tries to access them through eventObj.target and
    eventObj.type it returns null.
    Also, this only happens in debug mode (Debug -> Debug
    Movie) and not in test mode (Control -> Test Movie). In test
    movie the exact same code works flawlessly.

    Im not very sure just try to help but look this one
    mx.utils.Delegate
    i look for some issue with your problem and i think this can help
    you.

  • What is DispatchEvent used for ?

    Hi Everyone,
    What is the DispatchEvent used for? If possible, please give
    me an example with code. Thanks a lot in advance.
    May

    Hi Greg,
    What does "dispatch" mean? Sorry my English is not good at
    all.
    thanks,
    may
    quote:
    Originally posted by:
    Greg Lafrance
    DispatchEvent can be used to, well, dispatch events in your
    code. This is often done with custom components but can be useful
    at other times as well. See these FB help topics:
    Dispatching an event
    Defining a custom effect trigger
    Manually dispatching events
    Dispatching custom events
    Creating custom events

  • Connect dispatchevent between two swf's??

    One single swf, imgdesc.swf is being loaded into the emptymcholder, by the moviecliploader instance.
    My order is
    folioholdermc ---holds--> emptymcholder --holds--> imgdesc.swf
    Within folioholdermc, I disabled buttons and lowered opacity, once imgdesc.swf was loaded, using onloadInit()
    Now  in the button inside imgdesc.swf. I called, this.unloadMovie(), which  successfully unloads the file, but I am still inside emptymcholder,  though I actually want to go back into folioholdermc.
    I  am trying out the use of Eventlistener to check for unloadMovie. But my  problem is can I place this within folioholdermc, within the  onloadInit() or maybe within the on(press) function which actually calls  the loader in the first place?? I need to enable the buttons within  folioholdermc, and increase opacity, once the imgdesc.swf is unloaded.
    Within the onLoadInit() in folioholdermc I added
    _mc.addEventListener("end",endClip);
             function endClip() {
                trace("end");    //plan to insert code to enable buttons and increase opacity here
    and in the imgdesc.swf within the back button
    on(press){
        this.dispatchEvent({target:this, type:"end"});
        trace("event dispatched");
        this.unloadMovie();
    how do I connect the two?? This is not working, as the endClip function is not being called. What am I doing wrong???

    Ok I figured it out. First mistake was that the code for dispatchevent was incomplete and placed in the wrong place, the first frame of the imgdesc.swf. The first frame of imgdesc.swf is apparently loaded before the onloadInit(), sending out an event which no one is listening to.
    So this is what I did within imgdesc.swf
    First Frame:
    import mx.events.EventDispatcher;
    EventDispatcher.initialize( this );
    stop();
    Then within the on(press) of the back button I inserted a gotoAndStop(2);
    Second Frame:
    this.unloadMovie();
    this.dispatchEvent({type:"end", target: this});
    trace("Child dispatching: end");
    Now in the onloadInit within the parent swf I wrote
    _mc.addEventListener("end", endClip);
            function endClip() {
                trace("end");
                i = 1;
                while (i<=30) {
                _root.folioholdermc["img"+i]._alpha = 100;
                _root.folioholdermc["img"+i].enabled = true;
                i++;
    Worked perfectly!! Hope this helps someone else who is stuck.

  • DispatchEvent and sending parameters

    Hi,
    I have a game with two joysticks and I use the dispatchEvent
    command to
    send the fire button event. What would be a good way to send
    the number
    of the joystick to check who pressed the fire button. A bit
    dirty way
    would be to save just the number in root or in my main class.
    Any better
    ideas?
    TIA

    the event dispatcher can be determined using the
    currentTarget property of the event.

  • Problem about dispatchEvent:

    I want to use dispatchEvent to trigger a action. But I found: it works if I use AWT component, otherwise, if I use Swing component, it doesn't work.
    I paste my code here. I want trigger the click event of button2 when button1 is clicked. If the two buttons are Buttons, it works. If they are JButtons, it doesn't work. Please tell me why and how to resolve it.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    import java.sql.*;
    public class Test extends JFrame implements ActionListener {
    private Container container = null;
    private Button button1 = null;
    private Button button2 = null;
    public static void main(String args[]) {
    Test test = new Test();
    test.show();
    public Test() {
    super();
    container = this.getContentPane();
    button1 = new Button("1");
    button1.addActionListener(this);
    button2 = new Button("2");
    button2.addActionListener(this);
    container.add(button1, BorderLayout.NORTH);
    container.add(button2, BorderLayout.SOUTH);
    this.setBounds(0, 0, 400, 300);
         public void actionPerformed(ActionEvent ae) {
    Object source = ae.getSource();
    if (source == button1) {
    System.out.println("button 1 clicked");
    button1.dispatchEvent(new ActionEvent(button2, ae.getID(), ae.getActionCommand()));
    // button1.dispatchEvent(ae);
    if (source == button2) {
    System.out.println("button 2 clicked");

    If you want to trigger the event on button2 then don't you need to call button2.dispatchEvent instead of button1.dispatchEvent?
    button2.dispatchEvent(ae);One "nice" way to get a JButton to perform its action programmatically is to call JButton.doClick.
    But I don't think your program logic is quite right here anyway since button2 isn't really interested in action events - it sends them rather than receiving them. It seems that you simply want button1 to perform at least the same action as button2.
    if(ae.gtSource() == button1)
      // button1 specific stuff
      System.out.println("button 1 pressed");
    else if(ae.getSource() == button2)
      // button2 specific stuff
      System.out.println("button 2 pressed");
    // stuff common to both button1 and button2
    System.out.println("button pressed");Hope this helps.

  • Problems with the dispatchEvent-Methode

    Hallo,
    I have a strange problem with above mentioned methode
    I have a JTextField, and I want that only numeric inputs are
    accepted, so I used a KeyListener -Interface in the following way
    public void keyTyped(KeyEvent e)
    JTextField field =(JTextField)e.getSource();
    char c =e.getKeyChar();
    if(c>57 | c<46 |c==47 &&c >31)
    field.dispatchEvent(e);
    the other methodes keyPressed and keyReleased are implemented in the same way.
    So if I type in now in my JTextField an 'a' or whatsoever
    then the following Exception occurs:
    java.lang.StackOverflowError
    at java.awt.Toolkit.getEventQueue(Toolkit.java:1483)
    at java.awt.EventQueue.setCurrentEventAndMostRecentTime(EventQueue.java:731)
    at java.awt.Component.dispatchEventImpl(Component.java:3448)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at ueberstd.ComputeHours.keyTyped(ComputeHours.java:128)
    at java.awt.Component.processKeyEvent(Component.java:5048)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
    at java.awt.Component.processEvent(Component.java:4902)
    Mmh, and this is not the whole Exception message.
    There are missing a couple of lines.
    But may be one of you knows what my mistake is.
    Thanks advance.

    This is not the best way to validate for numerics. Check out the "Creating a Validated Text Field" section from the Swing tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation

  • Lost selection in the DataGrid after dispatchEvent

    Hi I have two data list(DataGrid ) in the one page, left one list information, and right one list selected information's properies.
    When I select one of information in the left, which retrieve its properties from server(Java Jetty), code like this:
    <mx:DataGrid id="dgStores" dataProvider="{storesList}"
    change="dispatchEvent(new TideUIEvent('displayProp',dgStores.selectedItem));"
    width="100%" rowCount="8">
    <mx:columns>
    </mx:columns>
    </mx:DataGrid>
    <mx:DataGrid  dataProvider="{storesPropList}"  visible="{Boolean(dgStores.selectedItem)}" >
            <mx:columns>
            </mx:columns>
    </mx:DataGrid>
    dispatchEvent is to try to get storesPropList data
    Can someone figure out what cause left DataGrid lost focus (unselected)?
    Thanks

    See what CollectionEvents are being dispatched from the left list's dataprovider.  If you see an event with CollectionEventKind.RESET you should investigate as to why.
    You should be getting a VALUE_COMMIT or CHANGE event when selection changes as well and you can trap that and see why it got sent.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Dispatchevent problem

    I am trying to run a basic eventlistener but unable to run, in debugger shows both the init and creationcomplete methods are executed but the showText is  not able to run what might be the reason?
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                   creationComplete="onComplete()"
                   initialize="init()">
        <fx:Script>
            <![CDATA[
                public static const callMe="Call_Event";
                 public    function onComplete():void{
                    dispatchEvent(new Event(callMe,true,false));
               public    function init():void{
                    group.addEventListener(callMe,showText);
        public function showText(e:Event):void{
                      rt.visible=true;   
            ]]>
        </fx:Script>
        <s:VGroup id="group">
        <s:RichText 
            id="rt"
            text="Hai"
            visible="false">
        </s:RichText>
        </s:VGroup>
    </s:Application>
    thanks for reading.

    Hi, Your dispatched event is not reaching to 'group' so it is not listening it.
    You are dispatching it at the top application level.
    So you can listen it at application level by adding listener at application itself rather than on group as this.addEventListener(CALL_ME_EVENT,showText);
    or
    dispatching event from group container i.e. group.dispatchEvent(new Event(CALL_ME_EVENT,true,false));
    I have done it by dispatching event at group level and it works.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   initialize="{init();}"
                   creationComplete="{onComplete();}"
                   minWidth="955" minHeight="600">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.controls.Alert;
                public static const CALL_ME_EVENT:String="Call_Event";
                public function init():void
                    group.addEventListener(CALL_ME_EVENT,showText);
                public function onComplete():void
                    group.dispatchEvent(new Event(CALL_ME_EVENT,true,false));
                public function showText(e:Event):void
                    rt.visible=true; 
                    trace("Done.. :)");
            ]]>
        </fx:Script>
        <s:VGroup id="group">
            <s:RichText id="rt"    text="Hai" visible="false"/>
        </s:VGroup>
    </s:Application>
    Hope it helps you.
    Abhinav Sharma

  • DispatchEvent help

    I'm just starting to learn AS3 and I'm trying to create a play button on a menu screen to start a game.
    I keep getting MMenu.as,Line20 1137:Incorrect number of arguments. Expected no more than 0.
    Every where I look the proper way to handle a dispatchEvent is as shown. Help is greatly appreciated.
    package  {
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.events.MouseEvent;
    public class MMenu extends MovieClip {
    public var PLAY:Play;
    public function MMenu()
    PLAY=new Play;
    PLAY.x=200;
    PLAY.y=300;
    addChild(PLAY);
    PLAY.addEventListener(MouseEvent.CLICK, go)
    public function go(evt:MouseEvent):void
    dispatchEvent(new dispatcher(dispatcher.GO))                                   <---Line 20

    use:
    package  {
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.events.MouseEvent;
    public class MMenu extends MovieClip {
    public var PLAY:Play;
    public function MMenu()
    PLAY=new Play;
    PLAY.x=200;
    PLAY.y=300;
    addChild(PLAY);
    PLAY.addEventListener(MouseEvent.CLICK, go)
    public function go(evt:MouseEvent):void{
    dispatchEvent(new Event(dispatcher.GO)); // assuming dispatcher.GO is defined which is unlikely so use:
    dispatchEvent(new Event("goEvent"));      

  • JButton dispatchEvent problem

    Hi,
    I've got JButtons in a JTable which means I have to capture the mouse events and forward them to the button.
    I do this with a mouse listener on the table, and the lines:
    buttonEvent = (MouseEvent)SwingUtilities.convertMouseEvent(table, e, button);
    button.dispatchEvent(buttonEvent);
    System.out.println(buttonEvent);
    table.repaint();where 'e' is the original mouse event. This produces, for example:
    java.awt.event.MouseEvent[MOUSE_CLICKED,(145,167),button=1,modifiers=Button1,clickCount=1]
    on
    javax.swing.JButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.5 <snip> text=Delete,defaultCapable=true]but yet nothing happens to the button. Is this a coordinate problem, or am I missing something else, as I don't really know what I'm doing?
    Cheers,
    Rob

    MOUSE_CLICKED,(145,167),Well I'm guessing that you can't just convert the table coordinates and use them as the button coordinates because the button isn't that big.
    An alternative approach might be to use the doClick() method of the button.
    In case that doesn't work, here's something I've been playing with that may help:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableButton3 extends JFrame
         public TableButton3()
              String[] columnNames = {"Date", "String", "Integer", "Decimal", ""};
              Object[][] data =
                   {new Date(), "A", new Integer(1), new Double(5.1), "Delete1"},
                   {new Date(), "B", new Integer(2), new Double(6.2), "Delete2"},
                   {new Date(), "C", new Integer(3), new Double(7.3), "Delete3"},
                   {new Date(), "D", new Integer(4), new Double(8.4), "Delete4"}
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              //  Create button column
              ButtonColumn buttonColumn = new ButtonColumn(table, 4);
         public static void main(String[] args)
              TableButton3 frame = new TableButton3();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         class ButtonColumn extends AbstractCellEditor
              implements TableCellRenderer, TableCellEditor, ActionListener
              JTable table;
              JButton renderButton;
              JButton editButton;
              String text;
              public ButtonColumn(JTable table, int column)
                   super();
                   this.table = table;
                   renderButton = new JButton();
                   editButton = new JButton();
                   editButton.setFocusPainted( false );
                   editButton.addActionListener( this );
                   TableColumnModel columnModel = table.getColumnModel();
                   columnModel.getColumn(column).setCellRenderer( this );
                   columnModel.getColumn(column).setCellEditor( this );
              public Component getTableCellRendererComponent(
                   JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
                   if (hasFocus)
                        renderButton.setForeground(table.getForeground());
                         renderButton.setBackground(Color.WHITE);
                   else if (isSelected)
                        renderButton.setForeground(table.getSelectionForeground());
                         renderButton.setBackground(table.getSelectionBackground());
                   else
                        renderButton.setForeground(table.getForeground());
                        renderButton.setBackground(UIManager.getColor("Button.background"));
                   renderButton.setText( (value == null) ? "" : value.toString() );
                   return renderButton;
              public Component getTableCellEditorComponent(
                   JTable table, Object value, boolean isSelected, int row, int column)
                   text = (value == null) ? "" : value.toString();
                   editButton.setText( text );
                   return editButton;
              public Object getCellEditorValue()
                   return text;
              public void actionPerformed(ActionEvent e)
                   fireEditingStopped();
                   System.out.println( "Action: " + e.getActionCommand() );
    }

  • DispatchEvent - bug in my code

    I cant find bug in my code.
    In main document class I have created new instance of a AI class and and an listener for a custom event as fallows:
    _ai = new AI(_param1, _param2);
    _ai.addEventListener("decisionMade", bestOptionFound, false, 0, false);
    private function bestOptionFound(evt:Event):void{
         trace("hello");
    Then in AI class I do all my logic and after its finished I run a function that dispach event for a main class:
    Inside AI class:
    private function bestOptionSet():void{
         var boole:Boolean = hasEventListener("decisionMade");
         var boole2:Boolean = willTrigger("decisionMade");
         dispatchEvent(new Event("decisionMade", false, false));
         trace(boole);
         trace(boole2);
         trace("function works");     
    So my trace statements give me information that my function working fine, but  there is no listener attached to my AI class (boole and boole2 =  false). thats why my handler cant be triggered.
    So Instance of my class AI is working fine and all function inside it working fine as well. But there is no listeners attached to that class as my trace statements tell me. But I add "_ai.addEventListener("decisionMade", bestOptionFound, false, 0, false);".
    Any ideas?

    you're dispatching your event BEFORE you're adding your listener.

  • DispatchEvent from MovieClip

    I have a movieclip on my stage that I am using as a button to
    increment an index number. I have declared a custom event class and
    I am passing the index to the custom event as a property.
    I have initialized the clips on the stage to listen for the
    custom event and I am dispatching the event from the instance of
    the button being pressed
    Everything seems to be ok except my clips listening for the
    event don't seem to be getting it. Can you not dispatch an event
    directly from a movieclip instance on the stage? Do you have to do
    it from a .AS file class?
    I can post code if people need it, but I need to clean it up.
    Just let me know.

    I whipped up a simple example of what I am doing to make it a
    little clearer. Basically I want to dispatch and event from one
    movie clip and I want another movie clip to listen for it and react
    when it happens.
    Here is the simple code for the Custom Event Class
    package
    import flash.events.Event;
    public class AnimateEvent extends Event
    private var _index:uint;
    public static const ANIMATE_EVENT = "animate";
    public function AnimateEvent(type:String, index:uint,
    bubbles:Boolean=true, cancelable:Boolean=true)
    super(type, true, false);
    _index = index;
    override public function clone():Event
    return new AnimateEvent(type, index, bubbles, cancelable);
    public function get index():uint
    return _index;
    And here is the simple fla code with 2 instances of my
    genericButton already on the screen. One is named myButton and
    myButton2.
    import AnimateEvent;
    stop();
    myButton.addEventListener(MouseEvent.CLICK, throwEvent);
    myButton2.addEventListener(AnimateEvent.ANIMATE_EVENT,
    caughtEvent);
    function throwEvent(evt:Event)
    trace("firing");
    myButton.dispatchEvent(new
    AnimateEvent(AnimateEvent.ANIMATE_EVENT, 1, true, true))
    function caughtEvent(evt:AnimateEvent)
    trace("caught it");
    trace(evt.index);
    Basically if I click on myButton I want it to dispatch and
    event and I want myButton2 to pick it up. I know the dispatchEvent
    is working because if I subscribe myButton to the AnimateEvent it
    comes in and the event properties are all there.
    I thought that if you set bubbles to true in your custom
    event class you could decouple the event from the object and then
    anything could catch the event. You could do something like this in
    AS2 with eventdispatcher. It seems like this should work.

Maybe you are looking for

  • GeForce2 MX - MS Starforce 818 S Video - TV Out not working ?

    Hi, I'm using MSI GeForce2 MX Nvidia MS Starforce 818 which have an S-Video video out port in it. A few while back, I try to use this TV Out port for the first time with the S Video cable given upon purchase. Since I have no idea how to use this TV O

  • Bugs with 10.4 (80), 6 and counting...

    I've downloaded the last iTunes version (I´m running Leopard 10.5.8), and since I've found 6 annoying bugs: 1. Already discussed in here, "Drag & Drop" feature is not working anymore, at least for me to create new playlists. With previous versions I

  • Cannot install IPA on my ios 5 devices."A signed resource has been added, modified, or deleted."

    Hi guys.. I've spent the last 3 hours wrestling with this. I'm using flexbuilder 4.6 on pc, with air 3.1. I'm using my mac to do the installation on the device. I used to be able to deploy the ipa files output by flashbuilder 4.6 to my ipad, and ipho

  • I want to burn a DVD and keep the pictures in the files

    I am using iPhoto 8.  I have 46 albums that I created for one vacation.  I have organized all of the pictures from 5 cameras and want to burn a DVD keeping the pictures in those albums so others can create a slideshow from them.  When I burned a DVD

  • Thumbnails in Sequence... Can they be changed?

    I understand that the thumbnail display for each clip used in the timeline is chosen depending on the "in" mark, in the original clip. Is there a way to change that thumbnail pic based on another mark of some sort? I want the clip to start in the sam