Run function in component from Main Application

Hello all.
I have my main.mxml application, that has a component inside of it.  The component is called <ns1:record/> with an id of "rec".
This component has a function inside of it named doConnect(event:MouseEvent).
Now i want to be able to add an event listener to a button on the Main.mxml that will run a function inside the component when clicked.
I have managed to add an event listener to the Main.mxml that triggers a function held within the Main.mxml when a button clicked inside the component is clicked.
I did this by using this code.
            <ns1:record id="rec" x="9" y="6" camera="{camera}" microphone="{microphone}" creationComplete="makeEvent()">
            </ns1:record>             //Event listener
            public function makeEvent():void {
                rec.backbtn.addEventListener(MouseEvent.CLICK,swapstate);
            protected function swapstate(event:MouseEvent):void {
                viewstack1.selectedChild=config;
No matter what i try thou i cant get this to work the other way around.
What i need help with is - clicking a button within the Main.mxml to run a function inside the component Record.
If anyone can help that would be great !
Thanks in advance.

Hi djh88ukwb,
From your post if I understand you correctly you want to listen for a event in record component when a button in main mxml is clicked...based on this
assumption I am suggesting you a solution...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()">
<mx:Script>
  <![CDATA[
   private function onButtonClicked(event:MouseEvent):void
   rec.swapstate(event);
  ]]>
</mx:Script>
<ns1:record id="rec" x="9" y="6" camera="{camera}" microphone="{microphone}" creationComplete="makeEvent()"></ns1:record>
<mx:Button id="myBtn" label="Call Function in Record Comp" click="onButtonClicked()" />
</mx:Application>
<!-- In your record component Add a public function  swapstate as shown below-->
public function swapstate(event:MouseEvent):void {
                viewstack1.selectedChild=config;
Please try this and let me know....
Thanks,
Bhasker

Similar Messages

  • Calling a method in a component from main application

    Hi,
    I have a mxml component( menu1.mxml) . In the menu1.mxml
    there is a include for the actionscript file(menu1.as). In the main
    application page(SampleLogin.mxml) I want to call the method in the
    btnSubmit_Click() on the saveIndex() method for case 0. I am
    attaching all the code below

    case 0:
    menuOne.btnSubmit_Click( );
    break;
    Also it would probably be following best practices to used a
    custom event to pass the information in your "LoginButton_Click()"
    function to the application.

  • Show component from main application mxml.

    Hi all,
         I have a main application mxml and inside has a button named show_form. After that, I design an form named Form_A. And now, I want when click on show_form button fire the Form_A and made it appear.
         Hown can I do this ?
         Thanks !

    There are many ways of doings this, it depends how your forms are shown.
    Are they in a ViewStack or similar container? If so just change the view from the click handler function for the button.
    If they are in a Canvas/HBox/VBox, in the click handler function of the button you can do a check like if Form_A.visible==true then submit it and hide it, else submit the other form. You can also have a variable that tracks if Form_A was submitted.
    If you have code, post it here and we can find the best solution with a clear example in front.

  • Load/Unload Component from Main Application

    I want to load in my main application 2 components. At this moment I load them with this:
    <components:loadProject id="loadPrj" visible="false" click="loadPrj_clickHandler(event)" verticalCenter="7" horizontalCenter="0"/>
    and I only set visible to true. Inside this component there is a canvas.
    But, is there any other way to do this using an AS class file? I would like to load/unload it on click, not only set true/false to visible.

    For dynamic creation and destruction of objects, you want to use ActionScript.
    So in your main app file, you might have a button that triggers a click handler that does this:
    private function myClickHandler()void {
                    var b1:CustomComponent = new CustomComponent();
                    var b2:CustomComponent = new CustomComponent();
                    /// Be sure to add them to the display list if they are visual components
                    myPanel.addElement(b1);
                    myPanel.addElement(b1);

  • I need to call the Run continously button programmatically from MFC application .

    I have create Labview application from sample VI and with help of VirtualInstrument class I am to access the methods like Run ,SetControlValue and getControlvalue .But for VI we have Run continously button also .how do I programmatically call the Run continously button opteration from my applciation using VI methods.

    "Run Continuously" is not something that should be used in an application. (There are very few legitimate uses for continuous run, e.g. to quickly play with a few input parameters while debugging a subVI independent of the main application. The equivalent in your case would be to just place the run invocation in a loop and call it repeatedly. This is definitely not the way to do it!)
    Why don't you simply place a big while loop around all the code inside the VI that needs to run continuously?
    See also THIS recent discussion.
    LabVIEW Champion . Do more with less code and in less time .

  • Run Child Concurrent Program from Main Concurrent Program

    Hi,
    I'm trying to run Child Concurrent Program from the Main Concurrent Program as below, could you suggest me on below.
    Database:10g
    Main_Concurrent_Program
    =================
    1) Will update staging table XXID_PO_ITM with Batch_id = 1,2,3,4,5
    This staging table has 1000 rows, so every 200 rows will be updated with one of the above batch_id
    This logic is working.
    Child_Concurrent_Program
    ================
    2) Above Main Concurrent Program should call below Child_Concurrent_Program.
    This Child_Concurrent_Program will have parameter batch_id (based on above batch_id)
    So, this Child_Concurrent_Program should kick off with batch_id = 1
    Simillarly, Child_Concurrent_Program should kick off with batch_id = 2
    Child_Concurrent_Program should kick off with batch_id = 3
    Child_Concurrent_Program should kick off with batch_id = 4
    Child_Concurrent_Program should kick off with batch_id = 5
    Could you give me some suggestions on this?
    Thanks.

    Check with FND_SUBMIT for submitting a concurrent job using child dependecies. Keep in mind, that once you call the API ... it spawns it's own thread and and becomes an autonomous process. Control is no longer maintained within the calling package.
    procedure submit_interface_data(p_schedule_date in date,p_mm_header_id in number,p_req_id out number)
    is
      v_user_id            number;
      v_application_id     number;
      v_responsibility_id  number;
    begin
                select user_id
                into   v_user_id
                from   fnd_user
                where  user_name = 'USER123';
                select application_id,
                       responsibility_id
                into   v_application_id,
                       v_responsibility_id
                from   fnd_responsibility_tl
                where  responsibility_name = 'General Warehouse';
      fnd_global.apps_initialize(v_user_id,v_responsibility_id,v_application_id);
      p_req_id := fnd_request.submit_request ( application => 'XYZ',
                           program     => 'MOVE_CONC_SHORT_NAME',
                           description => null,
                           start_time  => p_schedule_date,
                           sub_request => false,
                     argument1   => p_mm_header_id);
      commit;
    exception
    when others
       then
         spl_log_pub.write_exception(transaction_id   => null,
                                     transaction_type => null,
                                     error_message    => '<some error message>' ||
                                     'sqlcode: ' || sqlcode ||
                                     'sqlerrm: ' || sqlerrm);
    end submit_interface_data;Edited by: sreese on May 18, 2012 3:16 PM

  • Run function on component load / focus

    hi
    I want to run a function every time a component is opened /
    focused upon.
    at the moment I am running the function with the
    "creationComplete" property which works fine, although it only runs
    when the component is first created, whereas I want to run the
    function every time the component is opened and re-opened etc......
    is there some sort of event call or something that can make
    this possible.......
    any suggestions?
    Jon.

    Something like this might work.
    Create the function you want to call:
    <![CDATA[
    import mx.controls.Alert;
    private function doFocusStuff() : void
    Alert.show('hi');
    ]]>
    On the component for which you want to run the function on
    focus set the property focusIn like:
    <mx:TextInput focusIn="doFocusStuff()" .../>

  • Events from main application to components

    Could someone please tell me if it's possible to broadcast an
    event from the main application to components that have been
    declared inside the main application?

    For the number of rows in the DataGrid just look at the length of the dataProvider.
    For passing data between popups and app, the gold standard is to use custom events, and add the event listener to systemManager.
    Here are some tutorials on custom events I created:
    http://chikaradev.com/learning/flex3/customevents/StudentsTutoringCustomEvents1.pdf
    http://chikaradev.com/learning/flex3/customevents/CustomEventSimple/CustomEventSimple.html
    http://chikaradev.com/learning/flex3/customevents/CustomEvents1/index.html
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • Running an ouside exe from java application

    Hi
    My application should display an help button that will open a pdf file in a browser or in acrobat reader.
    I would like to know how to start an outside applicatioon from my application.
    thanks,
    Liat

    My os is win 2000 professional
    the code:
    public static void main(String[] args) throws Exception {
    Process p = Runtime.getRuntime().exec("c:\\temp\\1.pdf");
    p.waitFor();
    System.out.println("Done.");
    and this is the exception:
    com.bitband.maestro.gui.temp.Demo1
    java.io.IOException: CreateProcess: c:\temp\1.pdf error=193
         at java.lang.Win32Process.create(Native Method)
         at java.lang.Win32Process.<init>(Win32Process.java:66)
         at java.lang.Runtime.execInternal(Native Method)
         at java.lang.Runtime.exec(Runtime.java:566)
         at java.lang.Runtime.exec(Runtime.java:428)
         at java.lang.Runtime.exec(Runtime.java:364)
         at java.lang.Runtime.exec(Runtime.java:326)
         at com.bitband.maestro.gui.temp.Demo1.main(Demo1.java:100)
    Exception in thread "main" Process terminated with exit code 1

  • Run BI Publisher report from an application directly to  a printer.

    Dear All,
    I have an HTML page (with JavaScripts),
    I want to Run BI Publisher report from this page directly to a printer. (and send parameters).
    Can anyone help me, and send me Demo URL or Demo code to do this?
    Regards,
    Tovit

    Tovit
    you are going to have build out a servlet that the page can call. The servlet will need to implement the supported web services to schedule a report. The schedule can include the delivery options ie to a printer. So you would create a schedule that runs the report immediately via the scheduler and then to the printer.
    I dont currently have any servlet demos but the services are pretty well covered in the user docs.
    check them out and give it a try, if you get stuck let me know
    Tim

  • On clicking a button run external class which refrances main application

    I have a reader ReadXML and a Jframe Cpass, on clicking a button on Cpass, an new filechooser opens, this then fills the input jtextfiled12 . When clicking "load" button on cpass I need to send jtextfiled12.getText() to ReadXML (this runs, and updates mank text fields on cPass)... but I cant reference from a static context Cpass>>ReadXML>>Cpass.... so having a problem
    relevant cPass in cPass.java:
    public class Cpass extends javax.swing.JFrame {
    public static void main(String args[]) {
    Cpass C = new Cpass();
         C.show();
    public String getIn() {        return this.jTextField12.getText();         }
    relevant ReadXML in ReadXML.java:
    public class ReadXML {
    private void ReadInXML() throws IOException {
         String XmlInText = Cpass.getIn();
              BufferedReader allData8 = new BufferedReader(new InputStreamReader
    (new FileInputStream(new File( XmlInText)),"UTF8")); }
    Edited by: Mr_Tuition on Dec 5, 2007 3:44 AM

    but since cpass is already running from cpass, i cant reinitialise it, I need to used the insatance that is already shown, since it contains the infomation needed to pass to readXML
    public static void main(String args[]) {
       Cpass C = new Cpass();
       C.show();
       }When selectinfg a button on C (which selects the file location), that then opens readXML, I cant open a new version of Cpass (since this wont contain the infomation, eg the file the user has just chosen)
    I need to run Cpass
    Click a button that selects a file
    then file location is set in a text feild on Cpass
    on selecting "load" on Cpass, this runs readXML.java
    *readXML some how gets the file location from Cpass (which is still C.show();)
    the XML is read, and sent back to Cpass via:
              public String[] getStrAllData() {
                      return this.arrayXML;
             }One way arround thios is to copy the readXML function into Cpass but thats just messy
    Another would be to write out a "cookie" type file that saves the location, then readXML can use this .. less messy, but not what I wanted.
    Edited by: Mr_Tuition on Dec 5, 2007 4:42 AM

  • Change States in component from main view

    The scenario like this:
    The main view includes many component views. On my main view
    there have a radio button to choice different role type, for
    example: admin and user. For different role have different views.
    But they don’t have big difference.
    My question is how could I implement my component view change
    states when I click button on the main view? I don’t want do
    change states in main view since I need create two component views
    for different roles.
    Thanks.

    Consider adding a second state to your application, even if
    you don't put anything into it.
    In each of the components that should change state when the
    role is changed, add a listener on the application for the state
    change event ("currentStateChange"). When this event is fired,
    query the application for its current state:
    var appState:String = (Application.application as
    Application).currentState;
    Use that to change the state of the component. Remember
    you'll also need to do this when your component is first
    created.

  • Run remote batch file from Web Application Server

    Hello,
    I've developyed a Java program and deployed it on WAS v7.1.
    My java program tries to run a remote batch file which is located on remote Windows file system (and not on the WAS file system itself).
    The batch file was launched on the remote server (I saw it on the Task Manager of the remote server), but the remote batch file actually wasn't run (it was stuck).
    In order to run the remote batch file from my java program that is deployed on the WAS I've created a batch file on the WAS file system which its contnet is:
    cd c:\jobs
    psexec.exe 
    iltlvt40 -u SAPServiceCE1 -p a2i2000! c:\automation\DiskSpace\runDiskSpace.bat
    The jobs folder contains the psexec.exe file (you can find more details about the psexec on this link: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx).
    iltlvt40 is the remote server.
    SAPServiceCE1/a2i2000! is a user/password on the remote server which has a full permissions.
    My java program calls this batch file using the Runtime.exec() java method in order to run the remote batch file.
    Please guide me how to solve this problem?
    Best regards,
    Ahmad

    Hi,
    To which batch file you have meant to add some commands: for the local one or remote?
    I've added to the local one some different commands and it's works.
    I think there is a permission problem when we are trying to go out of the WAS file system.
    Best regards,
    Ahmad

  • Constructing a class extending JDialog when invoked from main application

    In an application that extends JFrame a method, showJDialogGUI, is called to instantiate an object of another class (called enterGUI) that extends JDialog. This object, enterGUIDialog, is modal; user must click on its Submit button in order to dismiss it and be able to continue in MainProgram. I have troubles getting error messages resolved when the constructor of the enterGUIDialog JDialog object is called. Perhaps there are other things wrong with below code. Any help appreciated - snippet of code from both classes is below.
    public class MainProgram extends JFrame {
    enterGUI enterGUIDialog; // declaration for object of class extending JDialog
    public MainProgram() {     // constructor
    myContainer = getContentPane();
    showJDialogGUI(); // calls method to initialize
    public void showJDialogGUI() {
    enterGUIDialog = new enterGUI (this, true);
    enterGUIDialog.setDefaultCloseOperation (DISPOSE_ON_CLOSE );
    enterGUIDialog.setSize(200,200);
    enterGUIDialog.setVisible( true );
    enterGUIDialog.show();
    } // end of class MainProgram
    public class enterGUI extends JDialog{
    Container myContainer;
    JPanel myPanel;
    //// How to call the constructor to create this JDialog????
    public loginGUI( JRootPane theRoot, boolean theModal ) // passed in 'this', and 'true'
    // or maybe??? public About(Frame parent, boolean modal) {
    this.setRootPane( theRoot ); //???????
    // or maybe ??? super(theRoot, flag);
    //super(theRoot, flag); // calls Dialog class constructor
    this.setModal( theModal ); // ?????
    myContainer = getContentPane();
    myContainer.setLayout( new FlowLayout() );
    thePanel = new JPanel();
    // next add components to JPanel, then add to the JDialog container
    fieldsPanel.add( pageLabel ); etc.
    myContainer.add( fieldsPanel );
    // etc.
    myContainer.setDefaultCloseOperation( DISPOSE_ON_CLOSE );
    myContainer.setVisible(true);
    } // end of constructor
    // more methods etc
    }

    Error received is:
    E:\Ghost>
    MainProgram.java:670: cannot resolve symbol
    symbol : constructor enterGUI (MainProgram,boolean)
    location: class MyPackage.enterGUI
    enterGUIDialog = new enterGUI(this, true);
    'new enterGUI(this, true); ' seems to be at start of
    error
    TIAThe error message could not be any more clear. To wit: the compiler is telling you it cannot find a constructor for class enterGUI that takes as parameters a reference to a javax.swing.JFrame, and a boolean value. Supply the constructor and the error will not be raised.

  • Running a db2 command from Java Application ??

    Hi All,
    I have to write an application in JDBC that can retrieve a list of databases on a db2 server, the only way I know is the db2 command "list database directory", but I can not use it in a JAVA program, is there a solution for this?
    Can anyone help me in this regard ?
    Thanks in Advance.

    If your driver implement it you can list databases with DatabaseMetaData
    Connection conn = ...
    DatabaseMetaData meta = conn.getMetaData();
    ResultSet rs = meta.getCatalogs();
    while (rs.next())
        System.out.println(rs.getString("TABLE_CAT"));
    }

Maybe you are looking for

  • Suggestion for a good project

    Hi.. I have to develop a web application in my last semester of Bachelor of Engineering using technologies like Servlets, JSP, AJAX, JavaScript, struts, portlets .. Please give me some ideas on which domain I can develop a good project. The project s

  • What is missing from Photoshop CS6 ???

         I tried the new PhotoShop CS6 (beta) but aside from some innovations of which my favorite is the interface (The interface is one of the best innovation that Adobe have made finally an interface that does not make you eyes hurt) and content aware

  • Dvd menu problem

    The dvd menus does not accept custom background images. I can place images in the dvd menu, but when the dvd is rendered all images are gone. What is wrong with this software? This problem has been written by others, but it seems to be no solution to

  • Data Adapter Configuration Wizard and custom datatype's

    I was wondering if there is planned support for GUI wizards similar to the Microsoft wizards that appear when you add a data adapter to a form at design time. These wizards appear when you use the Microsoft OracleClient, OLEDB or SQL Server client. T

  • Unexpected Error consistently in iMovie 11

    I have hundreds of events, as well as projects in iMovie. Most of them are located on an external WD drive. Everything works perfectly, as has for the past year. EXCEPT, whenever I try to manuever the contents of an event iMovie shuts down immediatel