Listen for events from an embedded Swf

Hi there,
I have spend so long searching for an answer on the web but can not find any that works, please help!
I'm not even sure if this is possible but if anyone can guide me in the right direction I would most appreciate it!
Basically what I would like to do is to load a swf in to my flex application - contrary to my post title it doesnt even have to be embedded - when the loaded swf finishes playing it's animation I want for it to dispatch an event and for flex to listen for that event and trigger a function when the event is captured.
The animation is made in Flash CS3. I have not used any classes, rather on the last frame I set up an action to dispatch an event like this:
dispatchEvent(new Event("finishedPlaying"));
In my Flex Application I load my swf using swfLoader and I add an event listener to it like so:
mySwfLoader.addEventListener("finishedPlaying", test);
and my function is like this:
private function test():void
     trace("it worked!");
This is not working at all and I'm sure I am missing something but I cant seem to find any straightforward answer on the internet!
Is it at all possible for a swf made in flash to communicate with flex??
Since they are both written in AS3, I figured it would be easy but alas!
If anyone can help me I would most appreciate it, thank you in advance!!
By the way I have also tried:
mySwfLoader.content.addEventListener("finishedPlaying", test);
but no luck....

You have to wait for the swf to complete loading before adding the event listener.
When are you adding the event listener?
mySwfLoader.addEventListener("finishedPlaying", test);
Have a look at the SWFLoader complete event:
http://livedocs.adobe.com/flex/3/langref/mx/controls/SWFLoader.html#event:complete

Similar Messages

  • Listening to Events from inside loaded swf

    In Flash Builder 4 I have a swfLoader with which I load swf files. The swf files that get loaded get created in Flash Pro, and I would like to be able to listen for events from the level that they get loaded from. What would I have to specify in the Flash file for the path? Can't seem to be able to specify the right path.
    Thanks a lot for any help!

    I wouldnt say this is elegant but we have been having issues gaining direct access to the SWF's loaded in via OSMF. However I have done setups where I dispatch an event from a SWF and have it bubble up and catch it on the MediaContainer level. Not elegant but works- otherwise may need to make a custom MediaElement and bypass the SWFElement to gain tighter control - seems like there should be a better way, but I havnt found it.

  • Listen for Events from anywhere

    Hello!
    I have an application with a rather complicated component hierarchy.
    How can I have it so that I can listen for events from any component in any component, regardless of who is who's child?
    Thank you!

    You need a broadcasting mechanism.
    Many architecture framework offers this facility, but as a quick hack you can try something like
    public class Broadcaster extends EventDispatcher  ( singleton anti pattern   )
    instance
    then just do Broadcaster.instance.addEventListener or removeEventListener. it's a crappy singleton, but at least it does not hold any global state.
    I've also seen people use Application.application to dispatch/listen globally but really don't like it.
    Note : Use weak references or your views will never be eligible for garbage collections.

  • Listening for UncaughtErrorEvents from SubApp loaded by SWFLoader

    I can't seem to get my uncaughtErrorEvents listener to fire when attached to the loader.uncaughtErrorEvents  or loaded content's loaderInfo.uncaughtErrorEvents when loading a swf via SWFLoader.
    I have a main Flex Application ('A.swf') loading a SubApplication  (defined in' B.swf') via a SWFLoader and I need to listen for  UncaughtErrorEvent from the SubApplication. I'm not able to get my event  listeners to be called when I throw an error from within the SubApp  ('B.swf').
    After reading the asDoc for UncaughtErrorEvent and  UncaughtErrorEvents It states that the UncaughtErrorEvent should go through the normal capture, target, and bubble phases through the loaderInfo hierarchy. This doesn't seem to be the case or I'm not understanding the documentation/usage.
    I have added an event listener to A.swf's loaderInfo  (The 'outter' main app) and also to B.swf's loaderInfo (though the Docs  say not to do it here it is part of the event sequence in the capture  and bubble phase...) as well as the SWFLoader internal  FlexLoader.uncaughtErrorEvent (per Docs) like so:
    SWFLoader's internal FlexLoader uncaughtErrorEvents
    swfLoader.content.loaderInfo.loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    and the loaded SWF's loaderInfo:
    swfLoader.content.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    When I throw an Error from the SubApplication (B.swf). Only the 'outter' main app's (A.swf) event listener gets called. Which you expect, at first, if it is in the capture phase, but it isn't in that eventPhase at all. When debugging the eventPhase is in the EventPhase.AT_TARGET phase while being handled by A.swf's LoaderInfo, howeever the ASDoc says the Target phase should be B.swf's LoaderInfo.
    Is this a bug between Flash player and Flex where the event isn't flowing correctly as stated in the ASDoc for UncaughtErrorEvent?

    Thanks for the reply Alex.
    The Outer main swf and the SubApp swf are in different ApplicationDomains (sibilings to each other) so they should not be sharing the class that is throwing the error. I should note that these two Applications are purely based on MX components, this is important later on.
    I was originally throwing the error from a Button click handler from B.swf:
    <mx:Button label="Throw Error" click="callLater( throwUncaughtError )" />
    I was wrapping the handler function in a callLater because without it the error is not caught at all and the default flash dialog console just appears with the error. The A.swf's loaderInfo.uncaughtErrorEvents handler was not even firing unless I wrapped it a callLater.
    I realized that Flash Builder's default to link the 4.1 SDK library via Runtime shared libraries was what was causing the A.swf's loaderInfo.uncaughtErrorEvent to fire in the AT_TARGET phase when using callLater. This is because the UIComponent's callLater method queue structure is shared between the two SWFs and therefore inside a function executing off the method queue A.swf's loaderInfo IS the TARGET... explainable, but at first thought that isn't how I'd expect this to work.
    I then decided to test this out by setting the SDK library to merge into the code for both A.swf and B.swf and removing the  callLater. IT WORKS!  B.swf's (the SubApp) loaderInfo.uncaughtErrorEvents handler fires and I prevent the default (flash error console from appearing) and can stopImmediatePropagation so A.swf's loaderInfo.uncaughtErrorEvents handler doesn't fire.
    Perfect besides having to merge the SDK libraries into each swf independently.... size killer.
    In summary, using the same exact code for A.swf and B.swf:
    1. When the SDK libraries are RSL - no UncaughtErrorEvents, neither A.swf's or B.swf's, is called. Instead the default flash error console appears with no chance to handle the uncaught error.
    2. When the SDK libraries are Merged into the code - both A.swf's and B.swf's uncaughtErrorEvents  will be called, according to the asDoc documented sequence; B.swf's uncaughtErrorEvents in the AT_TARGET phase and A.swf's uncaughtErrorEvents in the BUBBLE phase.
    Moreover, if I build a pure Spark implementation everything works even when referencing the SDK libraries as RSL.
    Does this indicate a bug in the globalplayer (flash player code)'s logic for handling UncaughtErrorEvents listeners within the loaderInfo hierarchy when the Flex SDK is Shared code between the SWFs?
    OR
    Since it works in Spark, is it an issue with how the flex2.compiler.mxml.Compiler turns MX based mxml components into generated AS classes (it hooks up the inline event listeners of child UIComponentDescriptor using a generic object and the click function is specified as a STRING and has to use untyped bracket notation to lookup on the UICompoent when adding it as a listener:
    new mx.core.UIComponentDescriptor({
                  type: mx.controls.Button
                  events: {
                    click: "___B_Button1_click"
                  propertiesFactory: function():Object { return {
                    label: "Throw Error"
    Where as Spark does this correctly and generates Factory functions for setting up child UIComponents when converting Spark component mxml to AS:
    private function _B_Button1_c() : spark.components.Button
        var temp : spark.components.Button = new spark.components.Button();
        temp.label = "Throw Error";
       temp.addEventListener("click", ___B_Button1_click);
        if (!temp.document) temp.document = this;
        mx.binding.BindingManager.executeBindings(this, "temp", temp);
        return temp;
    * @private
    public function ___B_Button1_click(event:flash.events.MouseEvent):void
        throwUncaughtError()
    Sadly, moving to pure Spark would be a big hit is my project's schedule and at this point and likely isn't feasible. I have examples (with view source) built in MX for both the RSL and MERGE cases, I just don't know how to attach them here.
    Sorry for the long comments and thanks again!

  • Sevice Contract - Listener for Events Queue Issue

    Hi,
    The Listener for Events Queue in our Production environment ran very long, It took about 3+ hrs to complete the program. Is there any thing specific that we can check as part of RCA.
    Further there were 'library cache lock' found ... how this can impact the performance and how library cache lock works.
    Regards
    Tauseef E Ahmad

    Hi Team,
    i used the following code for recognizing the key events.
    String javaScriptKeyListener =
    " function keyListener() "
    +" { "
    +" alert(window.event.keyCode) ; } ";
    OAWebBean body = pageContext.getRootWebBean();
    if (body instanceof OABodyBean)
    ((OABodyBean)body).setOnLoad("onKeyPress = javascript:keyListener()");
    but it is not working as expected..
    Any suggestions ??
    Regards
    Sridhar

  • I need to get sound events from sounds embedded in a MovieClip

    I'm working on a SoundManager class for a game development
    platform. Unfortunately, I can't leverage the Sound class because
    the requirements are that the sounds for an application would be
    embedded in individual MovieClip objects and set to stream as the
    clip plays.
    The idea is that this would allow third-party developers to
    make simple edits to the sounds by using the envelope controls for
    the embedded sounds. I can manually fire an event when the sound
    finishes by calling a custom method in the last frame of the movie
    clip, however, this is not completely accurate and it makes it
    impossible to seamlessly loop sounds.
    Now, the Flash player must be aware that the sound has
    finished playing. I presume that sounds embedded in the IDE are
    handled by the Sound class in some way. Is there any way at all
    that I can expose an event when the embedded sound finishes
    playing?
    I'd really prefer to use another approach, and just attach
    sound files from a Library or from external files, but I don't have
    a choice in this particular case. This is the way the application
    has to work.
    I will probably have to give up on the precision I want in
    order to complete this job on time, but I refuse to believe that
    what I'm trying to do is impossible. I would appreciate any help
    anyone can give me.

    You'll have to update your OS on your Macbook.
    Click on the black Apple logo at the top left of your Mac screen.  Then click on Software Update.
    support.apple.com/kb/ht1338

  • Listen for event in own class?

    Hi
    I dispatch events from models to classes listening. How do you set up an event and listener in the same class?
    Eg for the former - a model "MyModel" to class - it's:
    public static const MY_VAR:String = "myVar";
    triggered by...
    dispatchEvent(new Event(MY_VAR));
    picked up in another class by...
    modelVar.addEventListener(MyModel.MY_VAR, doSomething);
    but what if the class that's dispatching also has the listener?
    So if MyClass is dispatching the event, along the lines of...
    addEventListener(MyClass.MY_VAR, doSomething);
    Cheers for taking a look

    Very often I'm waiting for a few key items before I can finally do something else. Setting simple flags or checking nulls can help with this.
    Often I download multiple data structures (JSON/XML/etc) and I need all of them before I can parse them because the co-depend on each other. URLLoaders finish at different times so I just set a flag for what I need but check if all are complete before I continue each time one finishes.
    e.g.
    package
         public class IHateWaiting extends EventDispatcher
              public static const MY_VAR:String = "myVar";
              private var _xmlA:XML;
              private var _xmlB:XML;
              public function IHateWaiting()
                   // load A
                   var ulA:URLLoader = new URLLoader();
                   ulA.addEventListener(Event.COMPLETE, _handleFinishedF);
                   ulA.load(new URLRequest("http://www.example.com/a.xml"));
                   // load B
                   var ulB:URLLoader = new URLLoader();
                   ulB.addEventListener(Event.COMPLETE, _handleFinishedF);
                   ulB.load(new URLRequest("http://www.example.com/b.xml"));
                   // listen to self
                   addEventListener(IHateWaiting.MY_VAR, _handleAppEventF);
              private function _handleFinishedF(e:Event):void
                   if (e.type == Event.COMPLETE)
                        var data:XML = XML(e.target.data);
                        // A or B? any way you can tell
                        if (data.A.length() > 0) _xmlA = data;
                        else if (data.B.length() > 0) _xmlB = data;
                        // event method (requires extra handler or a fake event)
                        if (_xmlA && _xmlB) dispatchEvent(new Event(IHateWaiting.MY_VAR));
                        // preferred direct reference, no handler needed
                        // if (_xmlA && _xmlB) _parseXML();
              private function _handleAppEventF(e:Event):void
                   if (e.type == IHateWaiting.MY_VAR) _parseXML();
              private function _parseXML():void
                    // parse XML
    I recommend the reference version from post #2. It's cleaner because you don't need to double up on functions (handler->reference) like you see above with dispatching. The only purpose for _handleAppEventF() in this case is just to run _parseXML(), which is a useless duplicate function.
    I've always kept my handlers free of model-esque logic, so you see me calling a different function from that handler, _parseXML(). This is just because I want my handlers to only handle events and then hand off the work elsewhere.
    Instead of dispatching the event, I agree with moccamaximum, run the method directly. Even if it's 2 lines of code to do 1 thing, I think the clarity of it is much cleaner coding. So I would recommend nuking the self-listener in the constructor above. When I have all the data I'm looking for, I'd run the methods in the class directly and If the parent needs to know, I'd dispatch when they complete.
    e.g.
              private function _handleFinishedF(e:Event):void
                   if (e.type == Event.COMPLETE)
                        var data:XML = XML(e.target.data);
                        // A or B? any way you can tell
                        if (data.A.length() > 0) _xmlA = data;
                        else if (data.B.length() > 0) _xmlB = data;
                        if (_xmlA && _xmlB)
                             // parse first (synchronous)
                             _parseXML();
                             // xml ready, dispatch to parent
                             dispatchEvent(new Event(IHateWaiting.MY_VAR));

  • Listening to event from custom component

    I have a main.mxml file, and 2 custom components: component1.mxml and component2.mxml
    I want to dispatch an event from component1 and handle it in component 2.
    I'm able to do this by handling the event first in the main.mxml then passing it on.
    But is there a way not to involve main.mxml, and to directly listen to the event from component 1 and handle it in component 2?
    I need to listen the event in actionscript, not mxml.

    You can dig in to custom event handlers
    Best Regards,
    Yogesh

  • Passing events from externally-loaded SWFs

    Hi,
    We have an externally-loaded swf that acts as a kind-of-a slide show.  After a user selects a particular subject from a mxml-based "menu" application, they push "buttons" in the SWF to go through a presentation, then on the last frame of the swf, I'd like to unload the swf and replace it with another "mxml" application.  How can this be done?  I have not tried to pass/capture events "up" from an externally-loaded swf before.
    Thanks,
    Doug

    Do you own those SWFs?  If so, they should dispatch an event from a known
    place like a SlideShowManager or something like that.
    Other folks "cheat" and bubble events or dispatch off of the systemManager
    and/or top-level application.

  • Mxml file listening for event.

    Hi All,
       I'm having following code in my project, here Report.mxml file displays to enter user details like (firstname,lastname,city,state,zip etc). After entering user information there is submit button. When user selects this button it needs to submit this data into database and return REPORT_ID back to confirmation state.
       My problem is that submitting data into database and getting REPORT_ID is taking some time because of that it is not displaying REPORT_ID in Confirmation viewStack. Rather than getting REPORT_ID from RemoteObject, hardcoding(given in red color) this value in my controller then it is displaying REPORT_ID.
      How to wait for event result for displaying confirmation viewStack. Can anyone please suggest me what changes I need to make so that confirmation page will be displayed only after getting REPORT_ID.
    ------------------------------- Report.mxml (begin) ----------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
    <mx:Script>
        <![CDATA[
        import mx.controls.Alert;
        import com.westernstates.classes.controller.WesternStatesController;
        import com.westernstates.classes.model.WesternStatesModel;
        import com.westernstates.classes.events.*;
        private var _inquiryIdTxt:String;
        private var _inquiryIdTxtChanged:Boolean;
        public function set inquiryIdTxt(value:String):void
           _inquiryIdTxt = value;
           _inquiryIdTxtChanged = true;
           invalidateProperties();
           invalidateSize();
        override protected function commitProperties():void
          super.commitProperties();
          if (_inquiryIdTxtChanged)
              Alert.show("Inside commitProperties 1",_inquiryIdTxt);
             inquiryIdVal.text = _inquiryIdTxt;
             //inquiryIdVal.text = "1234"
             _inquiryIdTxtChanged = false;
        public function init():void{
            Alert.show("Inside newreport init mxml");
            myViewStack.selectedChild = newReport;
            Confirmation.visible=false;
            // Reset the value too.
            first_name.text = "";
            last_name.text = "";
            street_address.text = "";
            street_address2.text = "";
            city.text = "";
            state.text = "";
            zip.text = "";
            public function submitInquiry(evt:Event):void{
            var chk_speed_up:String = "";
            WesternStatesModel.inquiryConsumer.first_name = first_name.text;
              WesternStatesModel.inquiryConsumer.last_name = last_name.text;
              WesternStatesModel.inquiryConsumer.street_address = street_address.text;
              WesternStatesModel.inquiryConsumer.street_address2 = street_address2.text;
              WesternStatesModel.inquiryConsumer.city = city.text;
              WesternStatesModel.inquiryConsumer.state = state.text;
              WesternStatesModel.inquiryConsumer.zip = zip.text;
              myViewStack.selectedChild = Confirmation;
              newReport.visible=false;   
             this.dispatchEvent(new NewReportEvent());        
              //inquiryIdVal.text = _inquiryIdTxt;
              inquiryIdVal.text = WesternStatesModel.inquiryConsumer.inquiry_id;
        ]]>
    </mx:Script>
        <mx:ViewStack id="myViewStack" width="100%" height="100%" creationPolicy="all" >
        <mx:Canvas id="newReport" height="100%" width="100%" visible="true">
        <mx:Label x="10" y="10" text="NEW REPORT"  fontSize="18" fontWeight="bold" color="#F07012"/>
        <mx:TitleWindow width="100%" height="100%" layout="absolute" title="Create A New Report" fontWeight="normal" fontSize="13" y="38" x="0">
         <mx:Canvas height="100%" width="100%">
         <mx:VBox width="100%" height="100%">
             <mx:HBox>
                 <mx:Label text="Consumer Information: " fontSize="12" fontWeight="bold" color="#34B05D"/>
             </mx:HBox>
             <mx:HBox>
                 <mx:Label text="Report Type: " fontWeight="normal"/>
                 <mx:Label text="Phone" fontWeight="bold"/>
             </mx:HBox>
             <mx:HBox width="100%">
                 <mx:Label width="25%"  text="First Name:" fontWeight="normal"/>
                 <mx:TextInput width="25%" id="first_name"/>
                 <mx:Label  width="25%" text="Last Name:" fontWeight="normal"/>
                 <mx:TextInput width="25%" id="last_name"/>
             </mx:HBox>
             <mx:HBox width="100%">
                 <mx:Label  width="25%" text="Address1: " fontWeight="normal"/>
                 <mx:TextInput width="25%" id="street_address"/>
                 <mx:Label  width="25%" text="Address2:" fontWeight="normal"/>
                 <mx:TextInput width="25%" id="street_address2"/>
             </mx:HBox>
             <mx:HBox width="100%">
                 <mx:Label  width="25%" text="City: " fontWeight="normal"/>
                 <mx:TextInput width="25%" id="city"/>
                 <mx:Label  width="25%" text="State:" fontWeight="normal"/>
                 <mx:TextInput width="25%" id="state"/>
             </mx:HBox>
             <mx:HBox width="100%">
                 <mx:Label  width="25%" text="Zipcode: " fontWeight="normal"/>
                 <mx:TextInput width="25%" id="zip"/>
                 <mx:Label  width="25%" text="Phone"/>
                 <mx:TextInput width="25%" id="phone"/>
             </mx:HBox>
             <mx:HBox width="100%" horizontalAlign="center">
                 <mx:Button label="SUBMIT REPORT" id="submit_search" click="submitInquiry(event)" fillColors="#34B05D"/>
             </mx:HBox>        
            </mx:VBox>
        </mx:Canvas>
        </mx:TitleWindow>
        </mx:Canvas>
            <mx:Canvas id="Confirmation" width="100%" height="100%">
            <mx:Label x="10" y="10" text="NEW REPORT"  fontSize="18" fontWeight="bold" color="#F07012"/>
            <mx:TitleWindow width="100%" height="132" layout="absolute" title="Create A New Report" fontWeight="normal" fontSize="13" y="38" x="0">
            <mx:VBox width="100%" height="81">
                 <mx:HBox>
                     <mx:Label text="Submission Confirmation:" fontSize="12" fontWeight="bold" color="#34B05D"/>
                 </mx:HBox>
                 <mx:HBox>
                     <mx:Label text="Report has been created successfully with Report ID:"/>
                     <mx:Label id="inquiryIdVal" fontSize="12" fontWeight="bold" color="#34B05D"/>
                 </mx:HBox>
             </mx:VBox>
            </mx:TitleWindow>
            </mx:Canvas>
        </mx:ViewStack>
    </mx:Canvas>
    ------------------------------- Report.mxml (end)   -----------------
    ------------------------------- NewReportEvent.as( begin) ---------------
    package com.westernstates.classes.events
      import flash.events.Event;
      // This custom event should be dispatched if the user
      // successfully logs into the application.
      public class NewReportEvent extends Event{   
        public static const REPORT:String = "report"; 
        public function NewReportEvent(){
          super(NewReportEvent.REPORT);
    ------------------------------- NewReportEvent.as( end)   ----------------
    ------------------------------- WesternStatesController.as (begin) ------------
       public class WesternStatesController extends UIComponent{
        public function WesternStatesController(){
          addEventListener( FlexEvent.CREATION_COMPLETE, init);
        // Add event listeners to the system manager so it can handle events
        // of interest bubbling up from anywhere in the application.
        private function init( event:Event ):void{    
         systemManager.addEventListener(NewReportEvent.REPORT, newInquiry, true);
          login(new LoginEvent(LoginEvent.LOGIN));
            public function newInquiry(evt:NewReportEvent):void{
                 Alert.show("Inside newInquiry", evt.type);
                 addNewInquiry();
                 //getNewInquiryResult();
             }//End of newInquiry
             public function addNewInquiry():void
                 ro = new RemoteObject();
                 setUpAmfChannel();
                 ro.destination = "manageInquiryService";
                 ro.addEventListener("fault", faultHandler);      
                 ro.createInquiry.addEventListener("result", getNewInquiryResultHandler);
                 Alert.show("Before addNewInquiry");      
                 ro.createInquiry(WesternStatesModel.inquiry,WesternStatesModel.inquiryConsumer);
             }//End of addNewInquiry
             public function getNewInquiryResultHandler(event:ResultEvent):void
                     WesternStatesModel.inquiryConsumer.inquiry_id = event.result as String;
                    //WesternStatesModel.inquiryConsumer.inquiry_id = "09S-1234";  UNCOMMENT     
             }//End of getNewInquiryResultHandler
    ------------------------------- WesternStatesController.as (end) ---------------
    Thanks in advance.
    Regards,
    Sharath.

    Can someone please tell me how to add event handler to show REPORT_ID before displaying confirmation page. Confirmation page should be displayed once data saved successfully and getting REPORT_ID back from server.
    How to set variables for .mxml from action script(.as) file.
    Thanks,
    Sharath.

  • JTextfield  listening for changes from other class

    Hi,
    Assuming I have a Jtextfield in one of the class1 extend Jframe,
    how do I update the jtextfield so that it could up make accessible by other class and continuously updated to reflect the input for value rom another class2.
    In other words very much similar to the observable model view concept
    class 1 may be look like
    private void initComponents() {
    jTextField1 = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setEditable(false);
    class 2 may be look similar to the following
    public void out_1(){
    setStop1("N");
    for (int i=1;i<100;i++){
    class_1.getJTextField1().setText(String.valueOf(i)); // System.out.println(i);
    setOuti(i);
    setStop1("N");

    HI,
    I have attempted with the following coding , test 1 the source display generated using Netbeans GUI , t est2 the worker code ,and mybean the bean , so far nothing seems to work .
    I have not try the threaded swing concept as I am not familar with the concurrency but i am not sure whether propertylistener will do the job or not
    In summary , list of method employed are :
    binding the jtextfield1 to a bean,
    jtextfield add document listener ,
    Coding objective
    1. Test 1 defined jtexfield1 and jbutton
    2 Jbutton added actionlistener , where upon click,
    Execute Test 2 which will assign a series of integer to the bean , own setters & getters, Output is achieved via Test 1 jtextfield1 supposingly to display all the running number from 1 to 99 continuously until the test2 out_1 method finished the execution
    Anyone could provide the assistance .
    Thank
    * Test_1.java
    * Created on July 25, 2007, 9:23 PM
    package sapcopa;
    import java.beans.PropertyChangeListener;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.text.Document;
    import sapcopa.MyBean.*;
    public class Test_1 extends javax.swing.JFrame {
    /** Creates new form Test_1 */
    // private Test_2 t2=new Test_2();
    private String input_txt;
    public Test_1() {
    myBean1=new MyBean();
    myBean1.addPropertyChangeListener(new java.beans.PropertyChangeListener(){
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    bean_chg(evt);
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    myBean1 = new sapcopa.MyBean();
    jTextField1 = new javax.swing.JTextField();
    jTextField1.getDocument().addDocumentListener(new MyDocumentListener());
    jButton1 = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jTextField1.setEditable(false);
    jTextField1.setText(myBean1.getRecord_Process());
    jTextField1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    txt1_chg(evt);
    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    But1(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(19, 19, 19)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(layout.createSequentialGroup()
    .addGap(32, 32, 32)
    .addComponent(jButton1)))
    .addContainerGap(131, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(21, 21, 21)
    .addComponent(jButton1)
    .addContainerGap(216, Short.MAX_VALUE))
    pack();
    }// </editor-fold>//GEN-END:initComponents
    private void txt1_chg(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_txt1_chg
    // TODO add your handling code here:
    //myBean1=new MyBean();
    try {
    jTextField1.setText(myBean1.getRecord_Process());
    } catch (Exception e){
    e.printStackTrace();
    }//GEN-LAST:event_txt1_chg
    private void bean_chg(java.beans.PropertyChangeEvent evt){
    jTextField1.setText(myBean1.getRecord_Process());
    private void But1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_But1
    //getJTextField1().getDocument().addDocumentListener(new MyDocumentListener());
    Test_2 t2=new Test_2();
    t2.out_1();
    try{
    System.out.println("Button 1 mybean->"+myBean1.getRecord_Process());
    } catch (Exception e){
    e.printStackTrace();
    // TODO add your handling code here:
    }//GEN-LAST:event_But1
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Test_1().setVisible(true);
    public javax.swing.JTextField getJTextField1() {
    return jTextField1;
    public void setJTextField1(javax.swing.JTextField jTextField1) {
    this.jTextField1 = jTextField1;
    class MyDocumentListener implements DocumentListener {
    final String newline = "\n";
    public void insertUpdate(DocumentEvent e) {
    // updateLog(e, "inserted into");
    String vstr=myBean1.getRecord_Process().toString();
    jTextField1.setText(vstr);
    public void removeUpdate(DocumentEvent e) {
    //updateLog(e, "removed from");
    String vstr=myBean1.getRecord_Process().toString();
    jTextField1.setText(vstr);
    public void changedUpdate(DocumentEvent e) {
    //Plain text components don't fire these events.
    String vstr=myBean1.getRecord_Process().toString();
    jTextField1.setText(vstr);
    public void updateLog(DocumentEvent e, String action) {
    Document doc = (Document)e.getDocument();
    int changeLength = e.getLength();
    // jTextField1.setText(String.valueOf(changeLength));
    String vstr=myBean1.getRecord_Process().toString();
    jTextField1.setText(vstr);
    public String getInput_txt() {
    return input_txt;
    public void setInput_txt(String input_txt) {
    this.input_txt = input_txt;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JTextField jTextField1;
    private sapcopa.MyBean myBean1;
    // End of variables declaration//GEN-END:variables
    * Test_2.java
    * Created on July 25, 2007, 9:26 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package sapcopa;
    import sapcopa.MyBean.*;
    public class Test_2 {
    private Test_1 t1=new Test_1();
    private int outi;
    private String stop1;
    MyBean mybean;
    /** Creates a new instance of Test_2 */
    public Test_2() {
    public void out_1(){
    setStop1("N");
    mybean=new MyBean();
    for (int i=1;i<100;i++){
    mybean.setRecord_Process(String.valueOf(i));
    setOuti(i);
    setStop1("N");
    setStop1("Y");
    public int getOuti() {
    return outi;
    public void setOuti(int outi) {
    this.outi = outi;
    public String getStop1() {
    return stop1;
    public void setStop1(String stop1) {
    this.stop1 = stop1;
    * MyBean.java
    * Created on July 24, 2007, 12:00 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package sapcopa;
    import javax.swing.JTextField;
    public class MyBean {
    /** Creates a new instance of MyBean */
    public MyBean() {
    * Holds value of property record_Process.
    private JTextField txt_rec_process;
    private String record_Process;
    * Utility field used by bound properties.
    private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport(this);
    * Adds a PropertyChangeListener to the listener list.
    * @param l The listener to add.
    public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
    propertyChangeSupport.addPropertyChangeListener(l);
    * Removes a PropertyChangeListener from the listener list.
    * @param l The listener to remove.
    public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
    propertyChangeSupport.removePropertyChangeListener(l);
    * Getter for property record_Process.
    * @return Value of property record_Process.
    public String getRecord_Process() {
    return this.record_Process;
    * Setter for property record_Process.
    * @param record_Process New value of property record_Process.
    public void setRecord_Process(String record_Process) {
    String oldRecord_Process = this.record_Process;
    this.record_Process = record_Process;
    propertyChangeSupport.firePropertyChange("record_Process", oldRecord_Process, record_Process);
    * Holds value of property rec_Match.
    private String rec_Match;
    * Getter for property rec_Match.
    * @return Value of property rec_Match.
    public String getRec_Match() {
    return this.rec_Match;
    * Setter for property rec_Match.
    * @param rec_Match New value of property rec_Match.
    public void setRec_Match(String rec_Match) {
    String oldRec_Match = this.rec_Match;
    this.rec_Match = rec_Match;
    propertyChangeSupport.firePropertyChange("rec_Match", oldRec_Match, rec_Match);
    public JTextField getTxt_rec_process() {
    return txt_rec_process;
    public void setTxt_rec_process(JTextField txt_rec_process) {
    JTextField oldTxt_rec_process=this.txt_rec_process;
    this.txt_rec_process = txt_rec_process;
    propertyChangeSupport.firePropertyChange("txt_rec_process", oldTxt_rec_process, txt_rec_process);
    }

  • Listen for events in another Gui class

    Most of the GUIs I have written to date have consisted of either a single class or multiple self-contained classes - mainly extensions of JPanel with JButtons etc to perform certain tasks.
    Now I want to be able to click a JButton in one class which will invoke a method in another.
    The code is too lengthy to post here but this is the general layout:
    JFrame Simulation_GUI contains a JPanel (panelMain) which is set as the content pane
    panelMain contains two GUI classes which extend JPanel;
    buttonPane > contains a number of JButtons, including the one I want to click
    loadingPane > contains the method (which takes a Hastable as an argument) I want to run
    All three panels are declared in the main class which extends JFrame, so I know that from there I can simply call;
    loadingPanel.runLoads(htData); but how do I do this from the JButton on the buttonPane.
    Any assistance greatly appreciated as I have little enough hair at the moment and can't afford to tear much more out.
    Thanks in advance

    Class GUI1 {
    //Display all the buttons.
    public void init() {
    Button.addActionListener(new
    ener(new SomeClass(this));
    Class SomeClass implements ActionListener {
    GUI1 gui = null;
    SomeClass(GUI1 gui) {
    this.gui = gui;
    public void actionPerformed(ActionEvent e) {
    //Do all your process here
    gui.setTable(table);    //table would be ur
    ould be ur hashtable
    }Cheers
    -PThis didn't fully answer my question but did two things:
    1. Told me that it is at least possible and it is just me having a senior moment,
    2. Sent me on the right road to finding a solution
    With additional help from the following post I have sorted my problem. Basically I had to centrallise the event handling into a different class. This was instantiated by the main GUI class and passed to the other GUI components as an argument.
    http://forum.java.sun.com/thread.jspa?threadID=576012&messageID=2881969
    Simple when you know how...!
    prashanth_kuppur - have some Duke Dollars on me and thanks for the poke in the right direction.

  • Error #1009 in as3 code to install an Air application from an embedded swf.

    Hi, I am getting error #1009 in my code when i try to install the application. I am new to action script and below is the code for my installer.
    var airSWF:Object; // This is the reference to the main class of air.swf
    var airSWFLoader:Loader = new Loader(); // Used to load the SWF
    var loaderContext:LoaderContext = new LoaderContext(); 
                                    // Used to set the application domain 
    var paramObjAppid:Object = LoaderInfo(this.root.loaderInfo).parameters.appid;
    //var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    loaderContext.applicationDomain = ApplicationDomain.currentDomain;
    airSWFLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
    airSWFLoader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"), 
                        loaderContext);
    function onInit(e:Event):void 
        airSWF = e.target.content;
    var url = '';
    var qty = '';
    var appID = '';
    var pubID = "";
    var runtimeVersion = "3";
    var tf:TextField = new TextField();       // create a TextField names tf for debugging
    tf.autoSize = TextFieldAutoSize.LEFT;
    //tf.size = 4;
    tf.wordWrap = true;
    tf.border = true;
    addChild(tf);        
    try
        var keyStr:String;
        var valueStr:String;
        var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;   //set the paramObj variable to the parameters property of the LoaderInfo object
        for (keyStr in paramObj)
            valueStr = String(paramObj[keyStr]);
            if ( keyStr == 'qty' ) {
                qty = Number(valueStr);
            if ( keyStr == 'url' ) {
                url = escape(valueStr);
            if ( keyStr == 'appid') {
                appID = valueStr;
    catch (error:Error)
    var arguments:Array = [qty];
    launchBtn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
        airSWF.getApplicationVersion(appID, pubID, versionDetectCallback);    
    function versionDetectCallback(version:String):void
        if (version == null)
            trace("Not installed.");
            tf.appendText('Not Installed');
            try {
                   airSWF.installApplication(url, runtimeVersion, arguments);
                catch (error:Error){
                    tf.appendText(error.toString());
        else
            trace("Version", version, "installed.");
            tf.appendText("appID="+appID);
            try {
                airSWF.launchApplication(appID, pubID );
            catch(error:Error) {
                tf.appendText(error.toString());

    I managed to figure out what was causing the issue, I had a particular png image in my projects assets folder that seemed to be the culprit. Once I removed it the app installs just fine? Really weird?
    Adam

  • Registry for event from cid-implementating component failed

    hi,
    I have a problem with the following scenario:
    - I have a component Main, component interface definitions (cid´s) L and MENU
    - component M1 and L1 implement the cid
    now my problem:
    Main embedds the interface view of cid L (in my case the component L1 at runtime) and L1 embedds the interface view of cid Menu (M1 at runtime). both embedding of course in a view container.
    In M1 I got a tree ui-element and when a leaf in the tree is clicked a event in M1 is fired. This event is defined in the cid Menu and Main has registered for it with an eventhandler method.
    when I start my application the event is fired in M1 but Main-component didn´t execute its eventhandler method for this event. what could be the reason?
    has anyone an idea?

    no messias outhere? :-D

  • ICal no longer listening for event notifications in 10.5.4

    Up until 10.5.4, iCal would automatically add todo's and calendar events to its display when an event was created from an external app using the CalendarStore framework...
    Not anymore... The events are created, but you need to click on a different view to get iCal to realize something has been added to the calendar
    What's the normal way to submit a bug report to Apple on this?

    Hi,
    the normal way is to submit feedback over here: http://www.apple.com/feedback/ical.html
    Björn

Maybe you are looking for

  • 64-bit SUN java for Windows 64-bit x64?

    Hi Anyone who knows if SUN has released a 64-bit version of SUN JDK 1.4.x to be used on a Windows x64 installation? I haven't been able to find it, but SAP's PAM tells that SAP NW04s is supported for SUN JDK 1.4.2 x64 Windows! Best regards Tom

  • IPhone DEAD after 2.0.2 update!

    I updated and iTunes said the update failed due to an unknown error after backing up the iPhone. The phone, still connected, had the apple logo. I disconnected and still nothing but a logo. After several minutes I performed a reset by holding down po

  • Re-order tracks on arrange page

    Hi, maybe this sounds stupid but for some reason i cant re-order tracks on the arrange page. I think you can do it dragging and drop each track with the "hand" ... right? or no... i'm lost here and this really break my head cause then is a kaos when

  • My InDesign Library Crashes InDesign

    I have two screens and keep all of my palettes on the right screen. When I cross over to select the InDesign Library to grab something, it crashes my InDesign. It is the ONLY palette that causes an issue. If I remember to save the file I am working o

  • Implementing a new PKI Structure that supports SHA256

    My question has to do with moving away from our old PKI environment and onto a new PKI environment I am designing. A little background...So due to the fact that our existing PKI environment was not installed using most best practices and it only supp