Custom component calling function from main.mxml

I have a main.mxml that has the following function in it:
public function SubChooseField(evt:Event):void{
Alert.show( "Sub has been chosen" );
main.mxml also places the following custom component:
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="180" close="parent.SubChooseField(event)">
<mx:dataProvider>
<mx:Object data="1" label="choice 1 />
<mx:Object data="2" label="choice 2" />
<mx:Object data="3" label="choice 3" />
</mx:dataProvider>
</mx:ComboBox>
I want it so that when you chose one of the options in the
comboBox, it will call the function SubChooseField in the
main.mxml. But when I compile this, no matter what i try, i get the
error:
Error: Call to a possibly undefined method SubChooseField
through a reference with static type my_custom_opponent.
OR if i change the codeand remove the 'parent' to say:
close="SubChooseField(event)"> i get error:
Error: Call to a possibly undefined method SubChooseField.
any help much appreciated.

Rather than trying to use parent, using events might help
here. In your main mxml file, just listen for the change event that
is dispatched from your custom component. Since it is a ComboBox
component, it automatically dispatches this event. If your
component was more complex, you would need to dispatch a custom
event.
If your custom component was named CustomCombo, then the mxml
in your main file would look something like this:
<ns1:CustomCombo id="cb" x="70" y="39" width="160"
change="SubChooseField(event)"/>
Vygo

Similar Messages

  • How to access component's control from main .mxml file?

    I have a main .mxml while in which i imported custom
    "popUpWindow" component using "import components.popUpWindow"
    statement. In main .mxml file I display later on that component as
    popUp window using popUp manager class:
    var popUpWin:IFlexDisplayObject;
    popUpWin = PopUpManager.createPopUp(this, popUpWindow, true);
    Once component is displayed, how can i access using
    actionscript component's TextInput control (specifically its .text
    property) from my main .mxml file?
    thanks

    msabljic , sounds like you ran into the same problem as me,
    perhaps... I posted a question similar to yours around the same
    time. Take a look at the responses I got and maybe that will help
    answer your question.
    Here's a link to the post
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1285775&enterthread=y

  • Calling function from Main.as

    I have a buttons class I would like to access but not sure of
    proceedure. Here is the Main.as
    and here is the button class
    this is actions layer:
    Thanks
    Steve

    var buttons:Buttons = new Buttons(parameterGoesHere);

  • Call Function From MXML Component

    I am using MXML to create components that I use within my
    application. I have one MXML file that contains a list with a
    custom itemRenderer that is in another MXML file. I have an
    actionscript file with a function that I want to call from the
    itemRenderer.
    If I call the function from my main application, everything
    works fine. If I try to call it from one of the other MXML files, I
    get a 1180 Call to a possibly undefined function error.
    Is there a special way that I need to use to call the
    function?
    The main MXML file is in the root directory, the actionscript
    file is in a folder called functions, and the MXML files are in a
    folder called components.
    Thank you for any help.

    I was able to figure out my problem. It was just a simple
    typo of including the wrong file in a Script tag. However, this
    caused more issues and I ended up having to rewrite a large section
    of code to get everything working.
    Thank you for your help.

  • Running a method in a class from main.mxml

    So... this seems dumb, but I can't seem to run a method on an instance of a class. I should be able to
    arraycollectioninstance[0].methodinclass();    //this doesn't work
    I also tryed arraycollectioninstanace.getItemAt().methodinclass();
    All I want to do in run the function sortByUdn() that resides in the class definition from main.mxml on an instance of an arraycolleection. How do I do this and why doesn't the above attempts work? What am I missing?
    Below is my class:
    package status
    import mx.collections.ArrayCollection;
    import mx.collections.IViewCursor;
    import mx.collections.Sort;
    import mx.collections.SortField;
    import org.osmf.layout.AbsoluteLayoutFacet;
    [Bindable]
    public class Rack
      public var currentSort:String = 'udn';
      public var lowestUdn:int;
      public var highestUdn:int;
      public var circuits:int;
      public var rackModel:String;
      public var rackLevels:ArrayCollection = new ArrayCollection;
      public function Rack(response:XMLList):void
       circuits = response[0].info.length();
       for (var i:int=0; i < circuits; i++)
        rackLevels.addItem(new Level(
         response[0].info[i].@udn,
         response[0].info[i].@circuit,
         response[0].info[i][email protected](),
         response[0].info[i][email protected]()
       findMinMax();
    protected function sortByUdn():void
       var udnSort:Sort = new Sort()
       udnSort.fields = new Array();
       udnSort.fields.push(new SortField('udn',true,false,true));
       this.rackLevels.sort = udnSort;
       this.rackLevels.refresh();

    Thanks for the response!!!
    So my problem is that my class (Rack) has the functions, but I'm using an arraycollection of instances of this class. So in my main Application I have:
    public var current_rack:ArrayCollection = new ArrayCollection;
    then later on I'm using a current_rack.addItem(new Rack(.......)  several times to make the instances.
    I'm trying to call a function in one instance of current_rack[7] to perform a sort on that instance. I'm storing the sort function as part of the class, as it sorts the inards of the class instance.
    I really want to current_rack[0].sortByUdn();
    Though the above doesn't generate a compiler error, I get a runtime error of RangeError: 'Index '0' specified is out of bounds'

  • How to Call Function from SAPSCRIPT

    I want to Call a function from my SAPSCRIPT to get some data and print the same in the form , Can I get an example for this

    Hi Nandan,
    U cannot directly call function from SAPScript... For that u have to create one include in which u need to write the code. Using Perform... EndPerform u can call the same from SAPScript. See the below example
    u need to write this code in SAPScript
    PERFORM formname IN PROGRAM includename
    USING &field1&                                      
    USING &field2&                                      
    CHANGING &field3&                                     
    ENDPERFORM                                               
    Here includename is your include type program.
    u need to write this code in your include type program..
    FORM formname TABLES in_par STRUCTURE itcsy
                            out_par STRUCTURE itcsy.
    data : var1 like field1,
           var2 like field2,
           var3 like field3.
      READ TABLE in_par WITH KEY 'field1'.
      CHECK sy-subrc = 0.
      var1 = in_par-value.
      READ TABLE in_par WITH KEY 'field2'.
      CHECK sy-subrc = 0.
      var2 = in_par-value.
    now u can call corresponding function using local VAR1 and VAR2. Here u can pass N no of USING parameters.
    After processing on VAR3...
      READ TABLE out_par WITH KEY 'field3'.
      out_par-value = VAR3.
      MODIFY out_par INDEX sy-tabix.
    EndForm.
    Here in_par and out_par are the structures which will be used to communicate with SAPScript. And this is the only way as per my view.
    I m sure this code will work fine. Here i have used dummy variables that u need to change as per your requirement. If u have more queries write me back.
    And yes if this works than dont forget to give the points.
    Regards,
    Sagar

  • Call function from data base with clob input parameter.

    Hello,
    In this project I use Jdev 11g.
    I call function from database.
    create or replace function get_fa_list (
    p_fa_id_list in clob
    return sys_refcursor
    is
    vCursor sys_refcursor;
    begin
    put_msg ('begin');
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;
    put_msg ('Save');
    open vCursor for
    select rownum as id, s.*
    from (
    select f.latitude, f.longitude, count (distinct f.res_id) as res_count, count (*) as fa_count, 16711680 as color, res_concat_distinct (f.res_id) as station_list
    from mv_frequency_assignment f, table (SplitClob (p_fa_id_list, ',')) l
    where f.ext_system = 'BI' and
    f.ext_sys_id = l.column_value
    group by f.latitude, f.longitude
    ) s;
    put_msg ('Open and End');
    return vCursor;
    end get_fa_list;
    I use TopLink in ejb.
    i use follow code for call function and get result.
    public List<TmpResPoints> findAllPointsBI(String p_id){
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.beginEarlyTransaction();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("get_fa_list");
    call.useUnnamedCursorOutputAsResultSet();
    ClobDomain c = new ClobDomain(p_id);
    //System.out.println(c.toString());
    call.addNamedArgumentValue("p_fa_id_list", c);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(TmpResPoints.class);
    query.setCall(call);
    List<TmpResPoints> result = (List<TmpResPoints>)uow.executeQuery(query);
    uow.commit();
    uow.release();
    return result;
    But size parameter "p_fa_id_list" is 0. (geting from temp table in Data base). this code in function >>
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;)
    How I can call this function from dataBase and get result?
    thx,
    Demka.

    What is the SQL generated?
    The argument should just be the Clob value (a String) not the domain object.
    Also try addNamedArgument, and then pass the named argument to the query.
    James : http://www.eclipselink.org

  • Send data to ECC table through RFC Call function from SAP B1 via  b1if

    Hi,
    I have created scenario in B1if which triggers from SAP B1, now I have to send this data in to ECC table, so I have created scenario for that with inbound SAP B1, outbound void and in process RFC Call atom is there but I am not getting data in receiver and also how to write xml to send data in RFC function. Function for RFC has configured from ECC end and have access of that function.
    So please help me to send data to ECC table through RFC Call function from SAP B1 (9.0) via b1if
    Thanks

    Solved by my own.

  • Calling a function in main mxml  file from a component

    I have a main mxml file for an application.
    Within that file I have a viewStack with 3 components which
    are in separate mxml files.
    I have a function written in Action Script in the main
    application that I want to call from the 3 components.
    How is this done?
    Ta
    Mike

    Thanks for the help. I got it working using ntsiii's method
    (which is more straight forward but maybe not good practice?)
    though the line
    private var _appMain:Application = Application.application
    gave me the error message:
    1118: Implicit coercion of a value with static type Object to
    a possibly unrelated type mx.core:Application.
    So i changed it to:
    private var _appMain:* = Application.application
    Which made it work, I don't really understand why.
    Thanks
    Mike

  • How to access component's control property from main .mxml file

    I have a main .mxml while in which i imported custom
    "popUpWindow" component using "import component.popUpWindow"
    statement. In main .mxml file I display later on that component as
    popUp window using popUp manager class. Once component is
    displayed, how can i access using actionscript component's
    TextInput control (specifically its .text property) from my main
    .mxml file?
    thanks

    I posted this answer elsewhere, maybe it will help:
    First, save the new component wherever you keep your
    components, let's say you call it "MyPopWindow.mxml"
    Assign public variables for the string in both the main app
    and the popup.
    In your case, in the main app:
    Code:
    public var myText:String = "whatever the text field should
    say.";
    and then in the pop up mxml:
    Code:
    [Bindable]
    public var myText;
    Then, in the main mxml file:
    Code:
    // define the window type
    private var popWin:MyPopWindow;
    private function popMeUp(event:MouseEvent):void{
    popWin =MyPopWindow(PopUpManager.createPopUp(this,
    MyPopWindow, true));
    popWin.myText = myText;
    The important things here to notice is the name of the
    component (i.e. the file) is used. A variable is created for the
    window, and TYPED to your file name. Then you use the constructor
    you already had, but again use your type. The "true" is optional
    and gives you a modal popup window.
    Lastly, assign the variable in the window (I called mine
    popWin) to the variable in the main file you want to pass.

  • Call function in main timeline from class file

    Hi all, How can a function in main timeline be called from class file?

    Hi all, How can a function in main timeline be called from class file?
    You can, but you really shouldn't.
    Classes shouldn't "talk" to the outside directly.
    Use Event dispatching to get things done.
    "root" (i just threw up by just typing that word) should be avoided at all cost, especially in AS3.

  • Calling a function from Main()

    I have a written a function which I want to call in the Main method:
    private static GetExcel()
    DataTable dt = getData();
    System.Data.DataView view = new System.Data.DataView(dt);
    System.Data.DataTable selectedCol = view.ToTable("selectedCol", false, "OWS_PName");
    StreamWriter wr = new StreamWriter(@"C:\\Sunny\\Directory.csv");
    try
    //Write Column names to Excel
    for (int i = 0; i < selectedCol.Columns.Count; i++)
    if (selectedCol.Columns[i].ToString().ToUpper().Contains("OWS_"))
    wr.Write(dt.Columns[i].ToString().ToUpper().Replace("OWS_", "") + ",");
    wr.WriteLine();
    //write rows to excel file
    for (int i = 0; i < (selectedCol.Rows.Count); i++)
    for (int j = 0; j < selectedCol.Columns.Count; j++)
    if (selectedCol.Rows[i][j] != null)
    if (selectedCol.Rows[i][j].ToString().Contains(";#"))
    wr.Write(Convert.ToString(selectedCol.Rows[i][j]).Replace(";#", "") + ",");
    else
    wr.Write(Convert.ToString(selectedCol.Rows[i][j]) + ",");
    else
    wr.Write("\t");
    //go to next line
    wr.WriteLine();
    //close file
    wr.Close();
    catch (Exception ex)
    throw ex;
    What should I return here and how should I call it in Main()

    Hi,
    As this question is more relate to C#, I suggest you post it to Visual C# Forum, you will get more help and confirm answers from there.
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=csharpgeneral
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to access item renderer from main mxml?

    Hi,
    I have a datagrid which has item renderer. Code looks like this:
    <mx:DataGrid id="newsfeedgrid" width="100%" height="100%" visible="true" verticalScrollPolicy="auto"
                                  verticalGridLines="false" horizontalGridLines="true" horizontalGridLineColor="#E5F0F3" showHeaders="false"
                                  rowHeight="70" wordWrap="true" resizableColumns="false">
                                  <mx:columns>
                                            <mx:DataGridColumn headerText="Image Name" dataField="imgname" width="100">
                                            <mx:itemRenderer>
                                                      <mx:Component>
                                                                <mx:VBox height="100%" width="100%">
                                                                <!--          <mx:Image source="{data.imgname}" height="100%" width="100%"/>-->
                                                                <local:SmoothImage source="{'http://localhost/musicbook/attachdoc/'+data.imgname}" height="100%" width="100%"/>
                                                                          <mx:Text text="{data.fname+' '+data.lname}" fontSize="10" fontWeight="bold" fontFamily="Verdana" color="#3D3636"/>
                                                                </mx:VBox>
                                                      </mx:Component>
                                            </mx:itemRenderer>
                                            </mx:DataGridColumn>
                                            <mx:DataGridColumn headerText="Messages" dataField="mymsg" wordWrap="true" resizable="true"
                                                      >
                                                      <mx:itemRenderer>
                                                                <mx:Component>
                                                                          <mx:VBox verticalScrollPolicy="off" creationComplete="lbl_initialize()">
                                                                                    <!--<mx:HBox width="100%">
                                                                                              <mx:Text text="{data.uname}" width="100%" color="BLUE" fontSize="10" fontWeight="bold"
                                                                                              useHandCursor="true" buttonMode="true" mouseChildren="false"
                                                                                              click="this.outerDocument.userPage('msgFromC onnGrid')"/>
                                                                                              <mx:Text text="{data.actmsg}" width="100%" fontSize="10" fontWeight="bold"
                                                                                              />
                                                                                              <mx:Text text="{data.secuname}" width="100%" color="BLUE" fontSize="10" fontWeight="bold"
                                                                                              useHandCursor="true" buttonMode="true" mouseChildren="false"
                                                                                              click="this.outerDocument.userPage('msgFromC onnGrid')"/>
                                                                                    </mx:HBox>-->
                                                                                    <mx:Text id="lbl" width="100%"
                                                                            selectable="true"
                                                                            link="lbl_link(event);" />
                                                                                    <!--<mx:ControlBar id="cbar">-->
                                                                                    <mx:Spacer height="50%"/>
                                                                                    <mx:HBox width="100%">
                                                                                    <mx:Text text="{data.datetime}" fontSize="7" color="#8B9698"/>
                                                                          </mx:HBox>
                                                                           <mx:Script>
                                                                        <![CDATA[
                                                                            import mx.controls.Alert;
                                                                                    public var tempsecuname:String;
                                                                            private function lbl_initialize():void {
                                                                                      /* if(lbl.text=="Pratik is good")
                                                                                                lbl.htmlText="<a href='event:flex.org'>Good</a> is Pratik";
                                                                               //lbl.htmlText = "For more information on Flex, see <u><a href='event:flex.org'>http://www.flex.org/</a></u>.";
                                                                                if(data.secuname==null)
                                                                                          tempsecuname = "";
                                                                                else
                                                                                          tempsecuname=data.secuname;
                                                                               lbl.htmlText="<a href='event:flex.org'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+data.actmsg+"<a href='event:flex.org'><font color='#2112EF'><b>"+tempsecuname+"</b></font></a>";            
                                                                            private function lbl_link(evt:TextEvent):void {
                                                                                Alert.show(evt.toString(), evt.text);
                                                                                switch (evt.text) {
                                                                                    case "flex.org":
                                                                                        // You clicked the flex.org link.
                                                                                        break;
                                                                        ]]>
                                                                    </mx:Script>
                                                                          </mx:VBox>
                                                                </mx:Component>
                                                      </mx:itemRenderer>
                                            </mx:DataGridColumn>
                                  </mx:columns>
                                            </mx:DataGrid>
    Problem currently is since lbl_initialize() function is called on creationComplete of Vbox, output displayed is not expected and when ever i navigate to grid page output gets changed and it is not proper.
    I wanted to use text ,lbl, in my main.mxml so that i can assign the value when i am setting data provider.
    Please help!!!

    Thanks for your reply.. overriding set data in fact is a better approach and my half problem is solved but i am still facing some issues. Please find my code below:
    <mx:DataGridColumn headerText="Messages" dataField="mymsg" wordWrap="true" resizable="true"
                                                      >
                                                      <mx:itemRenderer>
                                                                <mx:Component>
                                                                          <mx:VBox verticalScrollPolicy="off" >
                                                                                    <mx:Text id="lbl" width="100%"
                                                                            selectable="true"
                                                                            link="lbl_link(event);" />
                                                                                    <!--<mx:ControlBar id="cbar">-->
                                                                                    <mx:Spacer height="50%"/>
                                                                                    <mx:HBox width="100%">
                                                                                    <mx:Text text="{data.datetime}" fontSize="7" color="#8B9698"/>
                                                                          </mx:HBox>
                                                                           <mx:Script>
                                                                        <![CDATA[
                                                                                  import mx.core.Application;
                                                                            import mx.controls.Alert;
                                                                                    public var tempsecuname:String;
                                                                                    public var tempmsg:String="";
                                                                                   override public function set data( value:Object ) : void {
                                                        super.data = value;
                                                                               lbl.htmlText="<a href='event:data.uname'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+tempmsg;
                                                                               if(data.datetime>Application.application.lastlogout)
                                                                                         Alert.show(Application.application.lastlogout);
                                                                                         lbl.setStyle("fontWeight","bold");
                                                                            private function lbl_link(evt:TextEvent):void {
                                                                        ]]>
                                                                    </mx:Script>
                                                                          </mx:VBox>
                                                                </mx:Component>
                                                      </mx:itemRenderer>
                                            </mx:DataGridColumn>
    Now my text is coming properly with link like how i wanted. I have added here another functionality where I am checking the last logouttime of user and the msg time and if msgtime is greater than last logout time then i am showing it in bold.
    override public function set data( value:Object ) : void {
                                    super.data = value;
                    lbl.htmlText="<a href='event:data.uname'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+tempmsg;
                    if(data.datetime>Application.application.lastlogout)
                    Alert.show(Application.application.lastlogout);
                    lbl.setStyle("fontWeight","bold");
    First time is shows properly but if i scroll then some random row is also appearing in bold, also when ever this set data function is getting called some random rows are coming in bold.
    Please let me know your input

  • Calling function from sql folder vs report

    Hi,
    A report based on a custom sql folder is taking a long time to run. One of the things that I noticed is that when I run the sql in plsql it takes a long time, but if I remove the row where I call a function, it runs pretty quickly.
    In general, is there a difference between running a function from the sql custom folder and calling it from the report itself?
    Thanks.
    Leah

    Hi Tamir,
    I might check out the execution plans, but truthfully, understanding the plans and the meaning of the differences is not my strong point.
    I thought that maybe there was some general rule that, for instance, it is better to keep functions out of the sql folder and use them in a condition in the report itself, or the opposite, or that maybe it makes no difference at all.
    I appreciate the response.
    Thanks.
    Leah

  • Put SQL query in a function/ call function from region

    How can I write a SQL query (like SELECT EMPNO, ENAME, JOB FROM EMP) as PL/SQL function, and then call this function from the PL/SQL Function Returning SQL Statement region?
    Thanks, Tom

    thanks jverd for your quick reply.
    I know passing in a reference to an object will do the job if I want to change the value several parameters in one function call.
    But I want to ask, is there any other ways?
    the following code works.....
    public class TestParameter {
         public static void main(String[] args) {
              Test2 t2 = new Test2();
              invokeChange(t2);
              System.out.println("x = " + t2.x + "\t y = " + t2.y);
         static void invokeChange(Test2 t2) {
              t2.x = 10;
              t2.y = 15;          
    class Test2 {     
         int x;
         int y;     
    }

Maybe you are looking for