Calling Function across Classes

How do I call a function across classes?
I have a primary class ("ChordLib.as") that contains a function that manages options for TileList component, that includes prescribing a custom Cell Rendering class, "MyRenderer".  I want to be able to call a function in the primary "ChordLib.as" class from the "MyRenderer.as" class.  Here is the function in "ChordLib" that refers to the "MyRenderer" class. Perhaps there is a way here to pass reference of the primary class into "MyRenderer"?
// SET CHORD LIST  //////////////////////////////////////////
public function setChordList(song:int):void {
var dpChords:DataProvider = new DataProvider();
var i:uint;
// determine chord set
if (song == -1) {
     activeChords = allChords;
} else {
     activeChords = songChordSets[song];
// fill dataProvider
for(i=0; i<activeChords.length; i++) {
     var tt = activeChords[i];
     dpChords.addItem({ label:tt, source:ChordBar, data:i, scaleContent:true }); 
chordList.dataProvider = dpChords;
chordList.columnWidth     = 70;
chordList.rowHeight     = 30;
chordList.direction = ScrollBarDirection.VERTICAL;
chordList.setStyle("contentPadding", 5);
chordList.setRendererStyle("imagePadding", 0);
chordList.scrollPolicy  = ScrollPolicy.ON;
// set style for labels
chordList.setRendererStyle("textFormat", textFormat1);
// set the background skin
chordList.setStyle("skin", lightBackground);
//set the cell renderer
chordList.setStyle("cellRenderer", MyRenderer);
This last line ("chordList.setStyle("cellRenderer", MyRenderer);") refers to this custom class, that includes some event listeners:
package {
   import fl.controls.listClasses.ICellRenderer;
   import fl.controls.listClasses.ImageCell;
   import flash.events.*;
   public class MyRenderer extends ImageCell implements ICellRenderer {
      public function MyRenderer() {
            this.buttonMode    = true;
          // set state skins to same skin so background is static
          setStyle("upSkin", lightBackground);
          setStyle("downSkin", lightBackground);
          setStyle("overSkin", lightBackground);
          setStyle("selectedUpSkin", lightBackground);
          setStyle("selectedDownSkin", lightBackground);
          setStyle("selectedOverSkin", lightBackground);
          // turn off text background by setting to 0
          setStyle("textOverlayAlpha", 0);
          setStyle("textPadding", 7);
            // event listeners
            this.addEventListener(MouseEvent.CLICK, clickHandler);
            this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
            this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
       // EVENTS
       private function clickHandler(event:MouseEvent):void {
       private function mouseOverHandler(event:MouseEvent):void {
       private function mouseOutHandler(event:MouseEvent):void {
I want to insert calls to functions that are in the primary class (that contains the first function listed here), "ChordLib.as".
How do I do this?

In order for ClassA to call a function of another ClassB (or instance of it) it needs to be aware of two facts: 1) That ClassB does exist and 2) that ClassB has a particular function.
Another approach could be establishing communication between classes via events.
From you explanation it is not clear what you want to accomplish. Do you need to call a function on Class itself or an instance of this Class?
If former - you need to create a static function and just call it:
inside ClassB:
public static function classBFunction()
ClassA can call it:
ClassB.classBFunction()
If you need to call the function on an instance - you, naturally, need to instantiate the class and only then call the function.
Say you have function inside ClassB
public function classBAnotherFunction() - note that there is no word static
There is another fork here: either you instantiate the ClassB inside ClassA or you pass a reference of the instance of ClassB into ClassA

Similar Messages

  • What is the syntax for calling function from class file by jsp

    does anyone here knows what is the syntax of how to call a function from java class file by javascript code or any way to call it?
    and where should i put the calling function code? because the function is called depend on the user click.
    for example
    <%=pc.functionName(a,b)%>
    for the variable a and b, how can i get the value from html textbox and put it in a and b...
    urgent needed...
    thx

    Jsp's are executed before the Html forms are created and loaded. Dont try to use a java code function calling on a javascript click. You'll have to explicitly redirect it into a servlet where in you can call the function you want.
    Well! another way could be using AJAX. That seems to be powerfull enough and it might also serve your purpose.
    Hope this helps

  • Call function or class from a loaded MC

    Hi,
    Can anyone tell me if its possible to call a function or class from within a loaded MC?
    mainMovie loads MC > MC calls function in a class of mainMovie
    if so, what is the best method?
    I've tried this from loaded MC but (of course) an error pops:
    movieClip(parent.parent).DO_THIS();
    Thanks for any "light" on this.

    It works fine!
    I'll try now to "sniff" into some class in main movieClip...
    Thanks

  • How to call function module/ class method of another system.

    Suppose now i am working in System A. And i need to check the system Status of System B, System C, System D....
    my design is to provide an interface. and each system realize the interface individually.now my question is how cani call the interface, because they are in different systems.
    of course i know about the host name, port and logon information over these systems.
    who can give my some suggestions or other solutions.
    thanks in advance.
    Johnney.

    Hello,
    If u want to call a FM of the other system then that FM should be a RFC enable on one.
    <b>CALL FUNCTION func DESTINATION dest.</b>
    Effect
    Executes the function module from an external source (as a Remote Function Call or RFC); dest can be a literal or a variable.
    Depending on the specified destination, the function module is executed in another R/3 or R/2 System. Externally callable function modules must be flagged as such in the Function Builder (of the target system).
    Since each destination defines its own program context, further calls to the same or different function modules with the same destination can access the local memory (global data) of these function modules.
    To maintain existing destinations, choose Tools -> Administration, Administration -> Network -> RFC destinations
    Note
    Under certain circumstances, an RFC may trigger a database commit. For this reason, RFCs must not be used between pairs of SQL statements that open and close a database cursor (such as SELECT... ENDSELECT).
    Vasanth

  • Call functions between classes

    Hi all,
    I have two java classes compiled into the DB in different schemas. How could I call the static method in classA from classB?
    I suppose I need to get the schema name in there somehow, or is it just as simple as classA.method(arg1)
    havent dared trying yet ;)

    You need to change the resolver of the referencing class to include the schema of the referenced class.
    When a class is created, whether directly by create java ddl or by loadjava it has an attribute known as a resolver which is essentially a search path for schemas to look in when resolving names referenced in the class. The resolver is a list of pairs of the form ((<pattern> <schema name>)(<pattern> <schema name>)...). When the class is resolved any name X that it references is bound to a class object by iterating over the resolver from left to right identifying each term in which the name of X matches the pattern and looking to see whether a class with the name of X exists in the schema identified by the term. If such a class exists, the search stops and the name X is bound to that class. If after looking at all the terms there is no class found, then a resolution error occurs. The pattern can either be an explicit name, or an explicit prefix followed by '*' or simply '*'. The latter is the usual pattern used, and matches any name. The default resolver given when a class is created without explicitly specifying an alternate resolver is ((* <current schema>)(* PUBLIC)). A class with this resolver will be able to resolve names in its own schema or in PUBLIC. In your case you want the referencing class to have a resolver like
    ((* <current schema>)(* <the other schema>)(* PUBLIC))
    or some variation on this. An alternate resolver can be specified in loadjava using the -resolver argument, or in create or alter java ddl using the
    resolver ((...)...) syntax. This is all documented in the java developers guide.

  • Calling function of swf in flex mobile (iPhone)

    Hi all,
    I have created a project to run in iOs (iphone).
    I loaded external swf which contain a method firstLoad() . When I run the application in flash builder then every thing works but when I install application in device it do not call the method firstLoad().
    Please all help to resolve this here is the sample code.
    <fx:Script>
                        <![CDATA[
                                  private function loadSwfApplication():void
                                            // load the file with URLLoader into a bytearray
                                            var loader:URLLoader=new URLLoader();
                                            // binary format since it a SWF
                                            loader.dataFormat=URLLoaderDataFormat.BINARY;
                                            loader.addEventListener(Event.COMPLETE, onSWFLoaded);
                                            //load the file
                                            loader.load(new URLRequest("swf/funtionDemo.swf"));
                                  private function onSWFLoaded(e:Event):void {
                                            // remove the event
                                            var loader:URLLoader=URLLoader(e.target);
                                            loader.removeEventListener(Event.COMPLETE, onSWFLoaded);
                                            // add an Application context and allow bytecode execution
                                            var context:LoaderContext=new LoaderContext();
                                            context.allowLoadBytesCodeExecution=true;
                                            // set the new context on SWFLoader
                                            sfwLoader.loaderContext = context;
                                            sfwLoader.addEventListener(Event.COMPLETE, loadComplete);
                                            // load the data from the bytearray
                                            sfwLoader.load(loader.data);
                                  // your load complete function
                                  private function loadComplete(completeEvent:Event):void {
                                            var swfApplication:* = completeEvent.target.content;
                                            swfApplication.firstLoad();  // this is a Function that I made it in the Root
                                            // class of swfApplication
                        ]]>
              </fx:Script>
              <s:SWFLoader id="sfwLoader" width="100%" height="100%" />
    Many thanks in advance

    Hi Antoni,
    It sounds like you want to create one SWF using Flash
    Authoring, and then load that SWF into a Flex 2 app and call
    functions across that boundary.
    You can only call a function in a loaded SWF directly from a
    containing Flex 2 app if the SWF you're loading uses ActionScript
    3. Currently, the version of Flash Authoring that supports
    publishing ActionScript 3 SWFs is in beta:
    http://labs.adobe.com/technologies/flash9as3preview/
    Thanks,
    nj
    Flex Builder team

  • Variable Functions (and Classes)

    Hi, I was wondering if ActionScript had some way to call functions and classes from variables, like they do in PHP:
    function funcname() {
         print "Potatoes come from tree";
    $function = "funcname";
    print $function;   // Prints out "funcname"
    $$function();      // Prints out "Potatoes come from tree"
    In case you don't know the syntax for PHP, you should know that anything perpended with a $-symbol is a variable. Is something akin to this possible with ActionScript?

    flash uses array notation to convert strings to objects:
    function funcname() {
         trace("Potatoes come from tree");
    var fS:String = "funcname";
    this[fS]();

  • Calling functions of the inner class in .java code file

    Hello,
    I created a .java code file in Visual J#.Net and converted it into
    the application by adding the "public static void main(String args[])"
    function.
    I have created the two classes one extends from Applet, and the other
    extends from Frame. The class which I inherited from the Frame class becomes
    the inner class of the class extended from the Applet. Now How do I
    call the functions of the class extended from Frame class - MenuBarFrame
    class. the outline code is
    public class menu_show extends Applet
    ------init , paint action function---------
    public class MenuBarFrame extends Frame
    paint,action function for Menu
    public static void main(String args[])
    applet class instance is created
    instance of frame is created
    Menu , MenuBar, MenuItem instance is created
    and all these objects added
    I have Created MenuBarFrame class instance as
    Object x= new menu_show().new MenuBarFrame
    ????? How to call the functions such as action of MenuBarFrame class - what
    should be its parameters??????
    }

    Here's how I would do it:
    interface Operation {
        public int op(int y);
    class X {
        private int x;
        public X(int x) {
            this.x = x;
        private class Y implements Operation {
            public int op(int y) {
                return x+y;
        public Operation createOperation() {
            return new Y();
        public static void main(String[] args) {
            X app = new X(17);
            Operation f = app.createOperation();
            System.out.println(f.op(-11));
    }Your code, however, has some serious "issues". You typically don't
    instantiate an applet class -- that's the job of the applet viewer or Java plugin
    your browser is using. If you instantiate the applet directly, you're going
    to have to supply it an AppletStub. Do you really want to go that way?
    Again, use an applet viewer or browser, or better yet, why write applets at all?

  • Problem Calling a Java class from PLSQL function

    We are calling a Java class through oracle function as
    FUNCTION CalculateAMW (contributorid IN Number,
    fromdate IN Date,OHorAnncoverage in Number,
    OHAnncoverage in Number,
    AppStatus in Number,
    Status in Number)
    RETURN Number
    AS LANGUAGE JAVA
    NAME 'AMWCalculations.calculateAMW
    (long,java.sql.Timestamp,long,long,long,long) return double';
    on execution of this function the sql prompt for the 1st time it is giving the output
    but
    if reexecute it is throwing and error ORA - 932 : Inconsistent
    datatypes.
    Recompiling the java class then it works for the 1st time and the next
    time
    we execute it throws error as explained above.
    What could be the problem.
    Thanks
    Nanda Kishore

    any idea???Yes, you are in the wrong forum, this is a Java forum, you have an ASP question, so i suggest you visit an ASP forum/site

  • Call function inside running class

    Hey All,
    i have a two question in classes.
    1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
    is this doable ?
    2- What super() mean ?
    Thanks a lot.

    this is the default call, and when i call the method by this way its will run the default class function before call the method.
    here my example:
    i need to call checkboxes  function in ChannelsMain class without pass by the grey script.
    Note: the call_cb is working and the trace is working
    so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
    package com.link
         import fl.controls.CheckBox;
         import flash.events.*;
         public class ChannelsMain
              var cbLength:uint = Main.PV.channel_id.length;
              public function ChannelsMain()
                   // constructor code
                   for (var i:int = 0; i < cbLength; i++)
                        var cb:CheckBox = new CheckBox;
                        cb.name = Main.PV.channel_id[i];
                        cb.label = Main.PV.channel_name[i];
                        cb.x = 50;
                        cb.y = 50 + i * 30;
                        cb.addEventListener(Event.CHANGE,call_cb);
                        Main.MS.addChild(cb);
                        //call xml function
                        if(i == cbLength - 1)
                             new ChannelsXML();
              private function call_cb(evt:Event)
                   trace(evt.currentTarget.name,evt.currentTarget.selected);
              public function checkboxes(evt)
                   trace(evt);

  • "Calling functions that are in a class based DLL (MFC extention DLL)"

    "Calling functions that are in a class based DLL (MFC extention DLL)"
    "Calling functions that are in a class based DLL (MFC extention DLL)
    I have a DLL written in VC++ using MFC exteintion DLL.
    The functions are used to extract information from a hardware card.
    eg.:
    class AFX_EXT_CLASS WSDevice : public cAsyncSocket
    This is a class in a DLL. There are a number of functions in this DLL that we need to call from Labview 5.0
    How do we call these functions?
    Normally (in VC++ /C++) we ceate a instance of this class like WSDeviceObj and use the function call :
    WSDeviceObj.fucntion name
    Kindly Help.
    Satish Narayana"

    You can create a wrapper dll from which you can call your dlls functions.
    Guidelines on how to create a dll that can communicate with LabVIEW are provided in the document "Using External Code in LabVIEW", which should be included with LabVIEW. You can download the document also from www.ni.com at:
    http://digital.ni.com/manuals.nsf/web_productcurre​nt/4F1447F7CD83D6D88625690D00637CED?OpenDocument
    Regards;
    Vargas
    www.vartortech.com

  • Direct approach for - Message class used in Call Function - possible?

    Hi All
    This is I guess a very simple question, but I could not find the solution.
    If i use the function: POPUP_TO_CONFIRM, I can hand over to the export some text symbols directly from the text elements.
    Example:
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
            titlebar              = text-011
            text_question         = text-030
            text_button_1         = text-024
            icon_button_1         = 'icon_checked '
            text_button_2         = text-026
            icon_button_2         = 'icon_incomplete'
            default_button        = '2'
            display_cancel_button = ''
            start_column          = 25
            start_row             = 6
          IMPORTING
            answer                = answer.
    But I'm using a message class in this progamm.
    <b>So my question is, how can I use directly a message from the message class within the function?</b>
    I'm not asking for a 2-step approach (copy into text1 and set text1 to function). I would like to know how to use the text from the class directly into the function.
    Thanks
    Petra

    Hi
    May be this way.
       data : v_text1(72) type c,
              v_text2(72) type c,
           v_text3(72) type c,
              v_text4(72) type c.
        message i175(YVV) into v_text1.
        message i176(YVV) into v_text2.
        message i177(YVV) into v_text3.
        message i178(YVV) into v_text4.
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
            titlebar              = v_text1
            text_question         = v_text2
            text_button_1         = v_text3
            icon_button_1         = 'icon_checked '
            text_button_2         = v_text4
            icon_button_2         = 'icon_incomplete'
            default_button        = '2'
            display_cancel_button = ''
            start_column          = 25
            start_row             = 6
          IMPORTING
            answer                = answer.
    aRs

  • Which is the best way for a called function to identify caller class name.

    Which is the best way for a called function to identify the caller class name .
    1)Using sun.reflect.Reflection from called function
                    Class caller = Reflection.getCallerClass(2);
                    System.out.println("Caller Class Name ::"+caller.getName());2) Analyzing current threads stack trace from called function
                    StackTraceElement[] stElements=Thread.currentThread().getStackTrace();
                    System.out.println("Caller Class Name ::"+stElements[3].getClassName());Is there any alternate ways to achieve the same .Which is the best way ?
    Called function doesn’t have any arguments, I don’t want t pass any arguments from caller function to called function.
    Plz help.
    With kind regards
    Paul

    798185 wrote:
    Which is the best way for a called function to identify the caller class name .
    Is there any alternate ways to achieve the same.SecurityManager
        // 0 is the anonymous SecurityManager class
        // 1 is this class (also works in static context)
        // 2 is calling class
        static Class getClass(int i) {
            return new SecurityManager() {
                protected Class[] getClassContext() {
                    return super.getClassContext();
            }.getClassContext();

  • Calling function from deferint classes

    Dear all
    Am working in multiple classes application and i need to use from another class how i can
    Do that like :
    Function name sendBye in class SipMessage and i need to use that function in class callBox
    I try to use this code
    SipMessage sipM = new SipMessage();{
    sipM.callBox; but am receiving many Exceptions

    Javarcle wrote:
    but am receiving many ExceptionsThat sucks, dude. Maybe if you fix the problem, you'll stop getting the exceptions

  • ABAP Dump when calling Function Module Starting New Task

    Hi all. I have a tricky situation now, I am doing a POC on parallel processing.
    I am getting an ABAP dump on the following Call Function line which is in class lcl_steer_114numc (See below for full program):
    METHOD start.
        CALL FUNCTION 'Z_ZZCLS_STEER_114NUMC'
          STARTING NEW TASK me->id
          CALLING me->finish ON END OF TASK.
      ENDMETHOD.                    "start
    However I get the following ABAP dump:
    Short text
        Statement "CALL FUNCTION .. DESTINATION/STARTING NEW TASK/IN BACKGROUND TASK"
    The function module only contains a wait statement to simulate parallel processing. It is strange that it dumps here, because when I change the FM call to another call that has been triggered successfully from other classes, it still produces the same ABAP dump.
    The background of the Proof Of Concept is to see if I can get an event to trigger the next process that depends on the outcome of the previous process. Parallel processes are run in the start methods by calling RFC.
    <Garbled code removed>
    Moderator Message: Please post relevant portions of the code only.
    Edited by: Suhas Saha on Jul 17, 2011 1:17 PM

    Well, the thing is I did manage to run 3 other Function Modules asynchronously succeesfully prior to that function call, with the same exact function call syntax. Further more, I have tried editing it with your suggestion but I get the exact same dump.
    The complete function group can be downloaded here (slinkee file):
    https://docs.google.com/leaf?id=0B3sua1Bw4XK4ZmFhNzcwMTgtYzQ0Mi00NzQ4LTg5YTMtNDNlNWUxYTM2NTg3&hl=en_US
    The complete program can be downloaded here (slinkee file):
    https://docs.google.com/leaf?id=0B3sua1Bw4XK4YWJmNjU3ODYtODRmMy00Nzg2LThkNTUtZjNkNDRhZGQ3MTUw&hl=en_US
    The complete ST22 dump can be found here:
    https://docs.google.com/leaf?id=0B3sua1Bw4XK4ZDU1YmFkZDAtOTU5MS00ZTgwLWFlZTktNWZhMDUxMzJlZWNl&hl=en_US
    Basically I ST22 gives me the following:
    Runtime Errors         RPERF_ILLEGAL_STATEMENT
    Date and Time          17.07.2011 05:29:54
    |Short text                                                                                |
    |    Statement "CALL FUNCTION .. DESTINATION/STARTING NEW TASK/IN BACKGROUND TASK"                 |
    |What happened?                                                                                |
    |    Error in the ABAP Application Program                                                         |
    |                                                                                |
    |    The current ABAP program "Z_ZZB1_CLOSE_PERIOD_TEST2" had to be terminated                     |
    |     because it has                                                                               |
    |    come across a statement that unfortunately cannot be executed.                                |
    And it explains it here (but is not helpful / relevant at all) as I ran the program from SE38.
    |Error analysis                                                                                |
    |    There is probably an error in the program                                                     |
    |    "Z_ZZB1_CLOSE_PERIOD_TEST2".                                                                  |
    |    The program was probably called in a conversion exit                                          |
    |    or in a field exit. These are implemented by                                                  |
    |    function modules called CONVERSION_EXIT_xxxxx_INPUT/OUTPUT or                                 |
    |    USER_EXIT_xxxxx_INPUT.                                                                        |
    |    Conversion exits are triggered during screen field transports or                              |
    |    WRITE statements, field exits during field transports from the                                |
    |    screen to the ABAP/4 program.                                                                 |
    |    In this connection, the following ABAP/4 statements are not allowed:                          |
    |                                                                                |
    I hope you try to download the slinkee files and you will notice the call function I performed was no different than the other call function RFC calls that really are working.

Maybe you are looking for

  • Reg: Export and Import using Dbms_datapump

    Hi, I would like to export a table using dbms_datapump package. I have a procedure to do this (In Oracle 10g R10.2.0.1.0). This procedure have parameter for schema name and table name and this particular schema table should be exported as dump file.

  • Error in Webdynpro iView

    Hi,       I developed a webdynpro iView.But it displaying following error in preview.I established the JCO connection successfully. com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Failed to resolve JCO destination name 'WD_RFC_METADATA_A

  • Could connect two Nexus 5648 to a stack of Catalyst 3750?

    Good Morning, Can I connect a two Nexus 5600 (switchs distribution) with switch Catalyst 3750 (switch access)? I have tried to integrate the Nexus switch in the network as switch distribution, replacing a Catalyst 6500 switch and does not work. Every

  • TEM - Cost Transfer Posting to CO(Business Event Cost)

    Dear All, Kindly suggest solution for the following issue I have maintained all the cost items with cost elements I have booked an empolyee for a business event with resources I have maintained receivers cost center in  SEMIN SCOST (T77S0) I have cre

  • Raw Files Error

    Hi All i have just purchased a Canon EOS 70D and discovered that i can not open my RAW files with PSE11. Can anyone tell me if it is possible to open the new Raw files with PSE 13? Is there a way to may PSE 11 recognize this file?