Passing function name into another function?

Hi
I have a movieclip prototype thats scales and moves any
movieclips depending
on the parameters passed in. I want to be able to pass in a
function name
that is executed when the main function has finished. The
problem is the
line of code that calls the main function executes the
function name that I
m trying to pass in as a parameter. Is there something I m
missing?
see my code below:
"mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
-100,
mcMainAnimation._xscale, -30, 50,moveToX());"
MovieClip.prototype.moveFadeTransform = function(t, oldY,
diffY, oldScale,
newScale, tTime, funcToCall) {
this.onEnterFrame = function() {
t++;
if (t<=tTime) {
this._y = easeIn(t, oldY, diffY, tTime);
this._xscale = easeIn(t, oldScale, newScale, tTime);
this._yscale = easeIn(t, oldScale, newScale, tTime);
} else {
t = 0;
funcToCall;
this.onEnterFrame = null;
moveToX = function () {
trace("called");
Thank in advance
Shaun

Hi!
Try to modify code to:
mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
-100,
mcMainAnimation._xscale, -30, 50,moveToX);"
... so don't use () at end of function. That should do the
trick.
Also, you need to add the () to funcToCall, so that instead
of:
t = 0;
funcToCall;
this.onEnterFrame = null;
you should have
t = 0;
funcToCall();
this.onEnterFrame = null;
/Jensen/
"forums.macromedia.com" <[email protected]>
wrote in message
news:e6m428$qa0$[email protected]..
> Hi
>
> I have a movieclip prototype thats scales and moves any
movieclips
> depending on the parameters passed in. I want to be able
to pass in a
> function name that is executed when the main function
has finished. The
> problem is the line of code that calls the main function
executes the
> function name that I m trying to pass in as a parameter.
Is there
> something I m missing?
>
> see my code below:
>
> "mcMainAnimation.moveFadeTransform(0,
mcMainAnimation._y, -100,
> mcMainAnimation._xscale, -30, 50,moveToX());"
>
> MovieClip.prototype.moveFadeTransform = function(t,
oldY, diffY, oldScale,
> newScale, tTime, funcToCall) {
> this.onEnterFrame = function() {
> t++;
> if (t<=tTime) {
> this._y = easeIn(t, oldY, diffY, tTime);
> this._xscale = easeIn(t, oldScale, newScale, tTime);
> this._yscale = easeIn(t, oldScale, newScale, tTime);
> } else {
> t = 0;
> funcToCall;
> this.onEnterFrame = null;
> }
> };
> };
>
> moveToX = function () {
> trace("called");
> }
>
>
> Thank in advance
>
> Shaun
>

Similar Messages

  • Passing field name into Cursor

    I would like to pass the name of a field for the WHERE clause, into a cursor. In my application I need to change the field name for the where clause. I get an "Invalid Number" error when I try the following:
    cursor l_sel2Cur (c_group varchar2)
    is
    select email from test_grp_tbl6 where c_group = 1;
    select column_name
    into l_colName
    from listserv_grp_lk
    where lg_id = v_listserv_grp;
    open l_sel2Cur(l_colName);
    I hope this is enough explanation. I have seen examples where the value for the where clause is passed in, but not where the field name itself is passed in. Is this possible?
    Thanks in advance,
    John

    See the following example:
    SQL> create or replace procedure print_enames(in_col in varchar, in_val in varchar2) is
      2  c sys_refcursor;
      3  v_name emp.ename%type;
      4  begin
      5    open c for 'select ename from emp where '||in_col||'='''||in_val||'''';
      6    loop
      7     fetch c into v_name;
      8     exit when c%notfound;
      9     dbms_output.put_line('ename='||v_name);
    10    end loop;
    11  end;
    12  /
    Procedure created.
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> set serverout on
    SQL> exec print_enames('mgr','7839')
    ename=JONES
    ename=BLAKE
    ename=CLARK
    PL/SQL procedure successfully completed.
    SQL> exec print_enames('sal','1250')
    ename=WARD
    ename=MARTIN
    PL/SQL procedure successfully completed.
    SQL> exec print_enames('deptno','30')
    ename=ALLEN
    ename=WARD
    ename=MARTIN
    ename=BLAKE
    ename=TURNER
    ename=JAMES
    PL/SQL procedure successfully completed.

  • _SMSTSCurrentActionName place the TS step name into another variable when fails

    Hello,
    Testing a Task Sequence that detects step error and generates a VB script which echos failure or success.  Want to capture the _SMSTSCurrentActionName when it fails and places into a user defined variable that can be called an displayed in the
    vbscript. Any thoughts?
    Thanks

    To do this, you'd have to be able to capture the value of the variable on the task that failed but since your error catching code happens in another task, you'd actually have to be able grab the value for a different step which isn't possible. It sounds
    like it could be of value though just not possible with the task sequence engine today. You should file a design change request on connect.
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

  • Passing function value into another procedure

    Hi
    From this package the value returned by the function " FIRST " needs to pass into another procedure as parameter in the same package, how could i do that in a better way.Oracle Version 8.1.7.4.0.
    CREATE OR REPLACE package body PKG_CUST_CHECK is
    FUNCTION FIRST(P_PARMS in varchar2) return varchar2 is
    l_parms varchar2(62) := P_PARMS;
    BEGIN
    SECOND(l_parms);     
         return(l_parms);     
    END;
    PROCEDURE SECOND(P_PARMS in out varchar2) is
    L_CUST Varchar2(30);
    BEGIN
    SELECT P_CUST INTO L_CUST FROM TABLE_A WHERE ROWNUM=1 ;
    THIRD(P_CUST in VARCHAR2,
    P_PARMS_VALID out VARCHAR2,
    P_OK_FOR_CUST out VARCHAR2,
    --Here the output of the above procedure will be concatinate and Return ;     
    END CUST_CHECK;
    end PKG_CUST_CHECK ;
    Thanks

    sorry for the confusion, not sure whether it will be clear enough.
    the requirement is function "FOURTH" should get the value returned
    by the function "FIRST" as in parameter value.
    [ code ] CREATE OR REPLACE package body PKG_CUST_CHECK is
    FUNCTION FIRST(P_PARMS in varchar2) return varchar2 is
    l_parms varchar2(62) := P_PARMS;
    BEGIN
    SECOND(l_parms);     
    return(l_parms); --here the value which is returning is updated one by the THIRD procedure       
    END;
    PROCEDURE SECOND(P_PARMS in out varchar2) is
    l_parms varchar2(62) := P_PARMS;
    BEGIN
    --the procedure THIRD will get the parameter values after
    --extracting the values from l_PARMS by another function EXTRACT
    THIRD(P_CUST in VARCHAR2,
    P_PARMS_VALID out VARCHAR2,
    P_OK_FOR_CUST out VARCHAR2,
    return;                    
    --Here the output of the above procedure will be concatinate and Return ;     
    END CUST_CHECK;
    FUNCTION FOURTH(P_PARMS in varchar2) return varchar2 is
    l_parms varchar2(62) := P_PARMS;
    BEGIN
    --the procedure FIFTH will get the parameter values after
    --extracting the values from l_PARMS by another function EXTRACT
    FIFTH(P_CUST in VARCHAR2,
    P_PARMS_VALID out VARCHAR2,
    P_OK_FOR_CUST out VARCHAR2,
    return;                    
    --Here the output of the above procedure will be concatinate and Return ;     
    END CUST_CHECK;
    end PKG_CUST_CHECK; [ /code ]

  • Passing record type into function [error: identifier must be declared]

    Hi,
    I have a record type defined in my procedure
    type chk_tab is record(
    effect date,
    count number(9)
    type chk_typ is table of chk_tab index by binary integer;
    chk_typ_rec chk_typ;
    I have to pass the effect and count into another function, i tried doin as below:
    function name: func_chk_typ
    func_chk_typ(effect, count);
    this returns an saying "identifier effect needs to be declared"
    I am required to pass these values from the record type into the function, How can i over come this??
    Any help is very much appreciated.

    Hi Hemz,
    Find below code.
    Function Code:
    CREATE OR REPLACE FUNCTION fetch_band(eff in date,ineff in date)
    return number
    is
      lu_cb_sysid  NUMBER;
    BEGIN
    select fk_cb_sysid
    into lu_cb_sysid
    from ia_for_icon
    where cr_ans_date >= eff
    and cr_ans_date < ineff;
    RETURN lu_cb_sysid;
    END fetch_band;Procedure code. Here I have embedded the function.
    CREATE OR REPLACE procedure abc(a varchar, b number) is
      type cns_tab_record is record(
        eff   date,
        ineff date);
      type cns_tab_typ is table of cns_tab_record index by binary_integer;
      cns_tab cns_tab_typ;
      v_lu_cb_sysid NUMBER;
    BEGIN 
      -- Here you have to assign the values to your table type record.
      -- For example I am passing two values SYSDATE and SYSDATE - 10
      cns_tab(1).eff := SYSDATE;
      cns_tab(1).ineff := SYSDATE - 10;
      v_lu_cb_sysid:= fetch_band(cns_tab(1).eff, cns_tab(1).ineff);
    END abc;But I am just wondering why you are using table type datatype here.
    Hope above code will help you.
    Thanks,
    Suri

  • Pass table name as a parameter to function

    Is there a way to pass table name as a parameter to functions? Then update the table in the function.
    Thanks a lot.
    Jiaxin

    Hi, Harm,
    Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
    CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM student s' ||
    'WHERE' || 's.student_number' || '=' || stuno;
    LOOP
    DBMS_OUTPUT.PUT_LINE('record deleted');
    END LOOP;
    END;
    SELECT delstu_func('s11') FROM STUDENT;
    The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
    Could you tell me where is wrong?
    Jiaxin

  • Can I pass function name as a parameter to constructor?

    Hi!
    I want to create a class that extends JButton and executes some function, when released. The function for each button is different. I mean, can I write, for example:
    public class MyButton extends JButton
    public MyButton(...functionName...)
    addMouseListener(new MouseAdapter()
         public void mouseReleased(MouseEvent e)
         ...execute functionName...;
    MyButton testButton = new MyButton(printTest);
    void printTest()
    System.out.println("The button executes OK");
    (This code will not work, of cause).
    If you understood me, please answer if there is any way to pass function as a parameter ?
    Thank you in advance.

    Using reflection would work, but there is a more straightforward way. Here's what I do when I want to pass a method to be called by another object: First I declare an interface named Callback:public interface Callback
      public void run();
    }Then your class would look like this:public class MyButton extends JButton {
      private Callback doit;
      public MyButton(Callback whatToDo) {
        doit = whatToDo;
        addMouseListener(new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            whatToDo.run();
    }and the code that creates a MyButton might look like this:Callback callMe = new Callback() {
      public void run() {
        System.exit(0);
    MyButton closeButton = new MyButton(callMe);
    closeButton.setText("Close");If you like, you can adapt this pattern to use variations of Callback that have parameters or return values.

  • How to pass column name at run time in function.

    how to pass column name at run time in function as parameter.
    thank in advance
    pramod patel

    Hello,
    Using dynamic sql you can pass column name to function. well I am not getting what you really want to do ? Please write in more detail. By the way I am providing one example here. see it uses dynamic sql.
    Create or replace function fun_updtest (p_columnname_varchar2 in varchar2,
    p_value_number in number)
    return number is
    v_stmt varchar2(500);
    begin
    v_stmt := 'update emp
    set '||p_columnname_varchar2||' = '||to_char(p_value_number)||'
              where empno = 7369';
    execute immediate v_stmt;
    return 0;
    commit;
    end;
    call to this function can be like this..
    declare
    v_number               number;
    begin
    v_number := fun_updtest('SAL',5000);
    end;
    Adinath Kamode

  • Function Module to update the file path/name into Infopackage

    Hi Experts,
    I have some flat files which will be loaded to the directly daily. My requirement is to update the file name into the infopackage dynamically. Please suggest any function module or program for it.
    Thanks,
    Kittu

    In Higher versions, we can use the below code:
    call method CL_GUI_FRONTEND_SERVICES=>ENVIRONMENT_GET_VARIABLE
        exporting
          VARIABLE   = 'TEMP'
        importing
          VALUE      = LV_TMP
        exceptions
          CNTL_ERROR = 1
          others     = 2.
      if SY-SUBRC <> 0.
        message id SY-MSGID type SY-MSGTY number SY-MSGNO
        with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      call method CL_GUI_CFW=>FLUSH
        exceptions
          CNTL_SYSTEM_ERROR = 1
          CNTL_ERROR        = 2
          others            = 3.
      if SY-SUBRC <> 0.
    Error handling
      endif.
      concatenate lv_tmp '\' into folder_path.
    But need to know in the lower versions like 3.1h and 4.0,

  • Function module for transfering a file contents into another?

    Hi all,
       Is there a Function module for transfering a file contents into another?That is the whole content from a file to other??
    Regards,
    Shashank.

    Hi,
    I think there is no such FM. You need to read the data in internal table and then write it in another file.
    Regards,
    Atish

  • ABAP Function Module Example to move data from one Cube into Another

    Hi experts,
    Can any please help out in this ..?
    A Simple ABAP Function Module Example to move data from one Cube into Another Cube
    (How do i send the data from one client to another client using Function moduel).
    Thanks
    -Upen.
    Moderator message: too vague, help not possible, please describe problems in all technical detail when posting again, BI related? ("cube"), also search for information before asking.
    Edited by: Thomas Zloch on Oct 29, 2010 1:19 PM

    This is the start routine to duplicate records in two currencies.
    DATA: datew   TYPE /bi0/oidateto,
          datew2  TYPE rsgeneral-chavl,
          fweek   TYPE rsgeneral-chavl,
          prodhier TYPE /bi0/oiprod_hier,
          market  TYPE /bic/oima_seg,
          segment TYPE /bic/oizsegment.
    DATA: BEGIN OF S_DATA_PACK OCCURS 0.
            INCLUDE STRUCTURE /BIC/CS8ZSDREV.
    DATA: END OF S_DATA_PACK.
    S_DATA_PACK[] = DATA_PACKAGE[].
      REFRESH DATA_PACKAGE.
      LOOP AT S_DATA_PACK.
        move-corresponding s_data_pack to DATA_PACKAGE.
        if DATA_PACKAGE-loc_currcy = 'EUR'.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalgrc.
          DATA_PACKAGE-CURRENCY = 'USD'.
          APPEND DATA_PACKAGE.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalloc.
          DATA_PACKAGE-CURRENCY = 'EUR'.
          APPEND DATA_PACKAGE.
        else.
          DATA_PACKAGE-netval_inv = DATA_PACKAGE-/bic/zsdvalgrc.
          DATA_PACKAGE-CURRENCY = 'USD'.
          APPEND DATA_PACKAGE.
        endif.
      ENDLOOP.
    This is to load Quantity field
    RESULT = COMM_STRUCTURE-BILL_QTY.
    This is to load Value field
    RESULT = COMM_STRUCTURE-NETVAL_INV.
    UNIT = COMM_STRUCTURE-currency.

  • Adding multiple same-name nodes from one xml into another

    Hi,
    Following on from my question the other day (Adding multiple different nodes from one xmltype into another), I now have a slightly more complex requirement that I cannot work out where to start, assuming that it's something that can reuse some/all of yesterday's work (thanks again, odie_63!). ETA: I'm on 11.2.0.3
    So, here's the (slightly amended) xml along with yesterday's solution:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
    from sample_data sd;
    That gives me:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
      </xmlnode>
    </root>
    However, I now need to add in a set of new nodes based on information from the <multinode> nodes, something like:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
        <newnode>
          <name>fred</name>
          <type>book</type>
        </newnode>
        <newnode>
          <name>bob</name>
          <type>car</type>
        </newnode>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
        <type>book</type>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
        <type>car</type>
      </xmlnode>
    </root>
    If it's easier, I *think* we would be ok with something like:
    <newnode>
      <type name="fred">book</type>
      <type name="bob">car</type>
    </newnode>
    The closest I've come is:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    , element newnode {
                                       $new/a/multinode/name
                                       ,$new/a/multinode/type
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
             ) fred
    from sample_data sd;
    Which produces:
    <newnode>
      <name>fred</name>
      <name>bob</name>
      <type>book</type>
      <type>car</type>
    </newnode>
    - obviously not right!
    Can anyone provide any hints? I've tried searching for similar examples, but I mustn't be putting in the right search terms or something!

    odie_63 wrote:
    or, similarly, to get the alternate output :
    copy $d := $old
    modify (
      insert node element extrainfo {
        $new/a/b
      , $new/a/d
      , $new/a/f
      , $new/a/h
      , element newnode {
          for $i in $new/a/multinode
          return element type {
            attribute name {data($i/name)}
          , data($i/type)
      } as first into $d/root
    return $d
    So we're going with the second method, but I've discovered that the "$i/name" node is not always present. When that happens, I would like to use a default value (for example, "george"). I promise I've searched and searched, but I'm completely failing to turn up anything that sounds remotely like what I'm after (seriously, I can't believe my google-fu sucks this badly!).
    Is there a simple way of doing it? The only thing that I've found that looks vaguely relevant is "declare default namespace...." but I'm not sure that that's the correct thing to use, or if it is, how I'm supposed to reference it when populating the attribute value.

  • Passing function parameters in a non-sequential fashon

    Consider the function below:
    function personal(Name:String,age:int,city:String):void
       trace(Name+" is "+age+ " years old and lives in "+city+ ".")
    The parameters can only(???) be passed in the order they are declared in the function as shown below.
    personal("John",40,"London"0)
    If the order is changed as: personal("London",John", 40), there will obviously be a type related error (position 2 parameter is an integer).
    Is there a way of passing function parameters as: personal(city="London",Name=John",age= 40)?
    That way one does not have to worry about the 'order' in which the parameters are passed.

    Micheal, I love such ELEGENCE.
    One more question, before I 'attempt' to go to bed!
    Below is code extracted from my main class definition.
    Notice how I 'populate' the artist object  before I pass it on as a parameter to my saveRecord function.
    It is rather clamsy, I think. Is there a better way of doing it?
    import ARTISTS
    var artist:ARTISTS = new ARTISTS;
    artist.ARTISTID = 123678;
    artist.FIRSTNAME = "Gordon";
    artist.LASTNAME = "Brown";
    artist.ADDRESS= "13 Darwin Street";
    artist.CITY= "London"
    saveRecord(artist);
    saveRecord(params:ARTISTS){
         //Some code here

  • Passing functions( methods ) as arguements.

    I am new to java and I need to pass a method to another method within the same class. In C++ you could create a pointer to a function and pass that pointer. Can I do something like that in Java and if so How? Thanks in advance.
    Barkley

    I am new to java and I need to pass a method to
    another method within the same class. In C++ you
    could create a pointer to a function and pass that
    pointer. Can I do something like that in Java andif
    so How? Thanks in advance.
    BarkleyActually there is no reason for this. You dont have
    to pass the method to call it, especially since they
    are in the same class
    class X
    void Method1()
    void Method2()
    Method1();
    //or
    this.Method1();
    I think the original poster wants to be able to either: a) specify a method to call at run-time, not at compile-time OR b) specify a function that some other piece of code (that the coder has no control over) will execute upon a given event. These are the typical uses for function pointers are used for in my experience. This allows things like API call-back functions, etc in Windows programming.
    As many people have suggested, the same thing can be done in Java using interfaces (as were all the "listener" classes in the Java API). A general form of this "call-back" interface would be:
    public interface CallBack
      public Object func(Object o);
    The Object argument and return-type above are similar to how void pointers are used in C++ allowing user data to be passed in to and out of the function thereby letting the function implementation interpret the incoming user data and letting the caller interpret the data coming out.
    Now to "pass" a pointer to a function you would pass the implementer of the CallBack interface. The only difference is tacking on the ".func(...)" when
    you do the actual call-back.
    public class MyCallBack implements CallBack
      public Object func(Object o)
        // put implementation here...
        return null; // return something useful here maybe?
    }Now do this:
    MyCallBack cb = new MyCallBack();
    - pass cb anywhere...the callback function would be done like this:
    cb.func(...);

Maybe you are looking for