How to create objects dynamically (with dynamic # of parameters)

I need to create a set of objects based on a definition from an XML file (obtained from the server) and add them to my scene.
I understand how to create the object using getDefinitionByName (and the limitations regarding classes needing to be referenced to be loaded into the SWF).
But some objects require parameters for the constructor, and some don't. The XML can easily pass in the required parameter information, but I can't figure out how to create a new object with a dynamic set of arguments (something akin to using the Function.call(obj, argsArray) method.
For example, I need something like this to work:
var mc=new (getDefinitionByName(str) as Class).call(thisNewThing, argsArray)
Currently this is as far as I can get:
var mc=new (getDefinitionByName(str) as Class)(static, list, of, arguments)
Thoughts?

I think what Dave is asking is a bit different.
He's wanting to know how to invoke the constructor of an object dynamically (when he only knows the # of constructor arguments at runtime).
This class I know will do it but seems to be a hack:
http://code.google.com/p/jsinterface/source/browse/trunk/source/core/aw/utils/ClassUtils.a s?spec=svn12&r=12
See the 'call' method, which first counts the # of arguments then invokes one of 'n' construction methods based on the number of constructor args.
I've yet to find a clean AS3 way of doing things ala 'call' though.
-Corey

Similar Messages

  • How to create a report with dynamic columns

    Hi all,
    I am using Apex 4.0 with Oracle 10g
    I am creating a report and I need to display columns dynamically based on the item values.
    example:
    I have a table employee with columns name, designation, sal
    In the report page i have a select list with designations and when I select a designation from the select list,
    I need to display the names of the employees horizontally,
    like each name as a new column in the report with that particular designation. and same has to continue when I select different designations.
    Can some one help me how we can do that.
    I appreciate your answer
    Thanks,
    Rik

    Essentially you want to write a pl/sql function which returns a varchar2 string. The contents of the string must be a valid sql statement.
    Once you have done this, you need to add a report region as type sql report and you will have the option of writing it as a query or as a function returning query. Choose function returning query and enter in the function call.
    Note your function must be valid, and must be executable by your apex parsing schema.
    example:
    create or replace
    function test_report(   p1_tablename       in varchar2)
    return varchar2
    is
    v_query varchar2(4000);
    begin
    v_query  :=
    'SELECT * from '||p_tablename;
    return v_query;
    end test_report;Edited by: Keith Jamieson on Aug 15, 2011 4:50 PM

  • How to create fillable PDF with dynamic content dropdowns?

    I'm creating a March Madness bracket for people that don't really understand how they work.  What I'd like to do is have dropdowns for each of bracket lines (they would list the teams playing against each other for that game and they would select who they think would win).  I would then like the dropdown for the next game to auto-populate with only the two options for the next round. 
    For example, team A and team B play against each other and teams C and D play against each other.  There are two separate dropdowns, one with A and B as choices and the other with C and D as choices.  The user thinks A and C will win their games, so the next dropdown would only have the options of selecting A and C.  To illustrate:
    AA and B are listed in the dropdown, and the user selects A to win.
    BA or C are listed in the dropdown because the user has selected A and C to win their previous games.
    CC and D are listed in the dropdown, and the user selects C to win.
    D
    I can make the first round dropdowns just fine, but I'm not sure how to conditionally/dynamically populate the second round dropdowns based off of user selections.

    I don't understand your request but my english is not the best.
    But here you can see a script. You can copy this in the first dropdown in the exit-event.
    In this example you will give the first dropdwon the entries
    "123"
    "345"
    "678"
    The first case describes what happens when the user clicks "123" the second drowdown will get the entries "456" and "789".
    When the user clicks "456" the second drowdown will get the entries "123" and "789".
    I think you can adapt this script as you need.
    Hope I could help a little bit,
    Mandy
    switch (xfa.event.newText)
        case "123":
            DropdownListe2.clearItems();
            DropdownListe2.addItem("Please select a value");
            DropdownListe2.addItem("456");
            DropdownListe2.addItem("789");
            DropdownListe2.selectedIndex = 0;
            break;
        case "456":
            DropdownListe2.clearItems();
            DropdownListe2.addItem("Please select a value");
            DropdownListe2.addItem("123");
            DropdownListe2.addItem("789");
            DropdownListe2.selectedIndex = 0;
            break;
        case "789":
            DropdownListe2.clearItems();
            DropdownListe2.addItem("Please select a value");
            DropdownListe2.addItem("123");
            DropdownListe2.addItem("456");
            DropdownListe2.selectedIndex = 0;
            break;
        default:
            break;

  • How to create a function with dynamic sql or any better way to achieve this?

            Hello,
            I have created below SQL query which works fine however when scalar function created ,it
            throws an error "Only functions and extended stored procedures can be executed from within a
            function.". In below code First cursor reads all client database names and second cursor
            reads client locations.
                      DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
                      DECLARE @ItemID int;
                      SET @locationClientPath = char(0);
                      SET @ItemID = 67480;
       --building dynamic sql to replace database name at runtime
             DECLARE @strSQL nvarchar(Max);
             DECLARE @DatabaseName nvarchar(100);
             DECLARE @localClientPath nvarchar(MAX) ;
                      Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
                      [tblOrganization] 
                      OPEN databaselist_cursor
                      FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                      WHILE @@FETCH_STATUS = 0
                      BEGIN       
       PRINT 'Processing DATABASE: ' + @DatabaseName;
        SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
        FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
                                   ([LocationRID]) 
        FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
                                   ItemId = '+ cast(@ItemID as nvarchar(20))  ;
         EXEC sp_executesql @strSQL;
        -- Open the cursor
        OPEN organizationlist_cursor
        SET @localClientPath = '';
        -- go through each Location path and return the 
         FETCH NEXT FROM organizationlist_cursor into @clientLocation
         WHILE @@FETCH_STATUS = 0
          BEGIN
           SELECT @localClientPath =  @clientLocation; 
           SELECT @locationClientPath =
    @locationClientPath + @clientLocation + ','
           FETCH NEXT FROM organizationlist_cursor INTO
    @clientLocation
          END
           PRINT 'current databse client location'+  @localClientPath;
         -- Close the Cursor
         CLOSE organizationlist_cursor;
         DEALLOCATE organizationlist_cursor;
         FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                    END
                    CLOSE databaselist_cursor;
                    DEALLOCATE databaselist_cursor;
                    -- Trim the last comma from the string
                   SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)-  1);
                     PRINT @locationClientPath;
            I would like to create above query in function so that return value would be used in 
            another query select statement and I am using SQL 2005.
            I would like to know if there is a way to make this work as a function or any better way
            to  achieve this?
            Thanks,

    This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
    do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
    In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
    though: data access from scalar UDFs can often give performance problems and its not recommended too..
    Raju Rasagounder Sr MSSQL DBA
          Hi Raju,
           Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
           Thanks in advance!
           Satya
              

  • How to create a report with dynamic no of columns

    Hi All,
    we have a report with 6 columns.
    and its been access by 10-20 people.
    the user dont want to have a fix report with 6 columns rather they want to have a flexibility to select the columns from the report they want to see.
    i.e. user one one time wasnt to see only one columns
    another time he want to see only column 2 and 4 of the report.
    its like there can be a multiple select option from where he can select the columns in the existing report and then see the same report with only that much column.
    Please tell me how to implement it.

    Abhip i thin you didnt get the problem.
    there is s exeiting report with 6 column
    Currently when i logging to OBIEE and see that report
    i will be getting report with 6 column
    but now i want a flexibility of selecting only 2 or 3 or 1 or 4 or 5 as i wish columns from this report and see the result only for that
    so is there by any chance i can have a check box for each column which i can check in dashborad to select that column
    and show the result were as by default it will show the report with 6 column.
    Thanks

  • Has anyone been able to create a HtmlDataTable with dynamic col and rows?

    Has anyone been able to create a HtmlDataTable with dynamic col and rows?
    If so please explain. I am successfully able to dynamically add columns using the getChildren method of the htmldatatable object
    BUT for each new column created no data is displayed.
    I am only able to display data for columns originally created when i clicked and dragged the dataTable icon from the pallette in netbeans visual web kit.
    Any help on this is greatly appreciated. I have been searching the web and these forums for around 8 hours and no one seems to have a working example of this. Lots of similar posts asking how to do it though :(
    Thanks in advance.

    This might be useful: http://balusc.xs4all.nl/srv/dev-jep-dat.html

  • How to Create a Table Component Dynamically based on the Need

    Hello all,
    I have a problem i need to create dynamically tables based on the no of records in the database. How can i create the table object using java code.
    Please help.

    Winston's blog will probably be helpful:
    How to create a table component dynamically:
    http://blogs.sun.com/roller/page/winston?entry=creating_dynamic_table
    Adding components to a dynamically created table
    http://blogs.sun.com/roller/page/winston?entry=dynamic_button_table
    Lark
    Creator Team

  • How to create an UI element dynamically on action in drop down?

    Hi,
    How to create an UI element dynamically on action of selecting a value from the  drop down?
    help out with the steps i need to follow..

    Hi,
    <u><i><b>Dynamic UI Element creation</b></i></u>
    We can create it only in the WD Modify View.
    Get the instance for the Root UI Element Container.
    Create the UI element Ex: Input Field, Text View etc.
    Bind the UI Element to the Attribute Value.
    Now bind the UI Element to the Root UI Element Container.
              IWDTransparentContainer root =(IWDTransparentContainer)view.getRootElement();
              IWDDropdownByIndex DdbName = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbName");
              IWDDropdownByIndex DdbAge = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbAge");
              IWDDropdownByIndex DdbGender = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbGender");
              IWDNode Mad =wdContext.getChildNode("Person",0);
              IWDAttributeInfo NameAtt = Mad.getNodeInfo().getAttribute("Name");
              IWDAttributeInfo AgeAtt = Mad.getNodeInfo().getAttribute("Age");
              IWDAttributeInfo GenderAtt = Mad.getNodeInfo().getAttribute("Gender");
              DdbName.bindValue(NameAtt);
              DdbAge.bindValue(AgeAtt);
              DdbGender.bindValue(GenderAtt);
              root.addChild(DdbName);     
              root.addChild(DdbAge);
              root.addChild(DdbGender);
    <u><i><b>Dynamic Action Creation</b></i></u>
    Create the Action in the Action tab.
    Create a Button.
    Get the reference for the created action (Through the Event Handler).
    Bind the Action to the Button.
    Bind the Button to the Root UI element Container.
    IWDButton ButGo = (IWDButton)view.createElement(IWDButton.class,"ButGo");
    IWDAction ActGo = wdThis.wdCreateAction(IPrivateStartView.WDActionEventHandler.GO,"Click");
    ButGo.setOnAction(ActGo);
    root.addChild(ButGo);
    Now write the required code for the Event Handler that is associated with the Action.
    //@@begin onActionGo(ServerEvent)
        IWDNode Mad = wdContext.getChildNode("Person",0);
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Name"));
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Age"));
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Gender"));
    //@@end
    Regards
    SURYA

  • Creating context node with dynamic type

    When we are creating context node thru wizard,  Dictionary type must be filled. I'm trying to create Context node manually.Did any one tried created Context node class with Dynamic type.

    Hi Prasad,
    I have a similar requirement.
    Can you please share with me how did you create context node with dynamic table data?
    Thanks
    Vicky

  • How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?

    How to create a table component dynamically in netbeans 6.0 (JSF 1.2)?
    This example http://developers.sun.com/jscreator/reference/techart/2/createTableDynamically.html works only with JSF 1.1.

    Please help my write correct code.
    How to replace this strings for run example?
    rowGroup.setValueBinding("sourceData", getApplication().createValueBinding("#{Page1.tripDataProvider}"));
    staticText1.setValueBinding("text", getApplication().createValueBinding("#{currentRow.value['TRIP.TRIPID']}"));

  • Create SCOM Group with dynamic members about 10minutes !

    in our SCOM 2012 SP1 (CU3) environment with about 800 Windows Agents.
    OperationsDB on a Windows Cluster (2 physical server with 2 processors (six cores). Datawarehouse on separate cluster.
    When i create a group with dynamic members, it took about 10min. During this period all the consoles are busy and freezing. 
    Is that normal ?
    Regards
    Lehugo

    on the management server i got follow eventlog error durung this time: 
    OpsMgr Management Configuration Service failed to execute 'ConfigStoreStatsUpdate' engine work item due to the following exception
    Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessException: Data access operation failed
       at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessOperation.ExecuteSynchronously(Int32 timeoutSeconds, WaitHandle stopWaitHandle)
       at Microsoft.EnterpriseManagement.ManagementConfiguration.SqlConfigurationStore.ConfigurationStore.ExecuteOperationSynchronously(IDataAccessConnectedOperation operation, String operationName)
       at Microsoft.EnterpriseManagement.ManagementConfiguration.SqlConfigurationStore.ConfigurationStore.WorkItemCompleted(IConfigServiceEngineWorkItemHandle workItemHandle, IConfigServiceEngineWorkItemResult workItemResult)
       at Microsoft.EnterpriseManagement.ManagementConfiguration.Interop.SharedWorkItem.ExecuteWorkItem()
       at Microsoft.EnterpriseManagement.ManagementConfiguration.Interop.ConfigServiceEngineWorkItem.Execute()
    System.Data.SqlClient.SqlException (0x80131904): Sql execution failed. Error 50000, Level 16, State 1, Procedure WorkItemMarkCompleted, Line 61, Message: Failed to report work item completion. Work item with id 1888748 is not assigned to service instance 'XXXXXX\Default'
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
       at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
       at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.NonQuerySqlCommandOperation.SqlCommandCompleted(IAsyncResult asyncResult)

  • Motion how to create 3d effect with a background and one primary object

    motion how to create 3d effect with a background and one primary object

    … like that?
    http://youtu.be/yOht1GJpEm4

  • How to create a node with attributes at runtime in webdynpro for ABAP?

    Hi Experts,
             How to create a node with attributes at runtime in webdynpro for ABAP? What classes or interfaces I should use? Please provide some sample code.
    I have checked IF_WD_CONTEXT_NODE_INFO and there is ADD_NEW_CHILD_NODE method. But this is not creating any node. I this this creates only a "node info" object.
    I even check IF_WD_CONTEXT_NODE but i could not find any method that creates a node with attribute.
    Please help!
    Thanks
    Gopal

    Hi
       I am getting the following error while creating a dynamic context node with 2 attributes. Please help me resolve this problem.
    Note
    The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
    The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
    Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
    Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
    Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
    My code is like the following:
    TYPES: BEGIN OF t_type,
                CARRID TYPE sflight-carrid,
                CONNID TYPE sflight-connid,
             END OF t_type.
      Data:  i_struc type table of t_type,
      dyn_node   type ref to if_wd_context_node,
      rootnode_info   type ref to if_wd_context_node_info,
      i_node_att type wdr_context_attr_info_map,
      wa_node_att type line of wdr_context_attr_info_map.
          wa_node_att-name = 'CARRID'.
          wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
          insert wa_node_att into table i_node_att.
          wa_node_att-name = 'CONNID'.
          wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
          insert wa_node_att into table i_node_att.
    clear i_struc. refresh i_struc.
      select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    rootnode_info = wd_context->get_node_info( ).
    rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
                                       attributes = i_node_att
                                       is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
    dyn_node->bind_table( i_struc ).
    l_ref_interfacecontroller->set_data( dyn_node ).
    I am trying to create a new node. That is
    CONTEXT
    - DYNFLIGHT
    CARRID
    CONNID
    As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
    Also I cannot define the structure in the ABAP dictionary because it changes based on condition
    Message was edited by: gopalkrishna baliga

  • How to create a table with events in smartforms?

    How to create a table with events view in smartforms?
    It doesn't like general table with header, main area and footer.
    for example:
    in smartforms: LE_SHP_DELNOTE
    table name is TABLEITEM(Delivery items table)

    Vel wrote:
    I am creating XML file using DBMS_XMLGEN package. This XML file will contain data from two different database tables. So I am creating temporary table in the PL/SQL procedure to have the data from these different tables in a single temporary table.
    Please find the below Dynamic SQL statements that i'm using for create the temp table and inserting the data into it.
    Before insert the V_NAME filed, i will be appending a VARCHAR field to the original data.
    EXECUTE IMMEDIATE 'CREATE TABLE TEMP_TABLE (UNIQUE_KEY NUMBER , FILE_NAME VARCHAR2(1000), LAST_DATE DATE)';
    EXECUTE IMMEDIATE 'INSERT INTO TEMP_TABLE values (SEQUENCE.nextval,:1,:2)' USING V_NAME,vLastDate;What exactly i need is to eliminate the INSERT portion of it,Since i have to insert more 90,000 rows into it. Is there way to have the temp table created with data in it along with the sequence value as well.
    I'm using Oracle 10.2.0.4 version.
    Edited by: 903948 on Dec 22, 2011 10:58 PMWhat you need to do to eliminate the INSERT statement is to -- as already suggested by others - eliminate the temporary table. You don't need it. It is just necessary overhead. Please explain why you (apparently) believe that the suggestion of a view will not meet your requirements.

  • How to create pdf files with text field data

    how to create pdf files with text field data

    That looks like it should work, but it doesn't.
    I opened the PDF I had created from Word in Acrobat (X Pro). Went to File > Properties. Selected "Change Settings". I then enabled "Restrict editing...", set a password, set "Printing Allowed" to "none", "Changes Allowed" to "none", and ensured that "Enable copying of text..." was disabled.
    I saved the PDF file, closed Acrobat, opened the PDF in Reader, and I was still able to select text and graphical objects.
    I reopened the PDF in Acrobat, and the document summart still shows everything as allowed. When I click on "show details" (from File > Properties) it shows the correct settings.
    Any ideas?

  • How to create excise invoice with reference thorugh credit memo

    Hi All,
    Please provide any solution for the following qurey:
    How to create excise invoice with reference thorugh credit memo

    Hi murali,
    i am unable to understand your requirement i think there is no like this scenario requirement for any client
    if any requirement is there kindly explain detail
    cheers

Maybe you are looking for

  • Printer Driver issue with iMac & HP 1200 Printer?

    A friend has this combination, asked me to help him with a printer problem. The HP 1200 Laserjet shows in the "Printer Setup" window, is the default printer. The printer shows up in the hardware connected to the USB bus. BUT, when you try to print, t

  • I cannot update Photoshop cc, Photoshop cc(2014), Bridge cc. (U43M1D204)

    I cannot update Photoshop cc, Photoshop cc(2014), Bridge cc. (U43M1D204) But I could do in Lightroom 5, Lightroom cc(2015). I've tried many times it comes out the same.

  • Workflow deadline expression problem

    Hi; I have a problem and I must solve . I created workflow and defined latest end (deadline) for activity . I selected refer data/time tabs and expression. I filled data and time as dynmically  in other words deadline change according to program.But

  • Adobe is installed but won't display pdf files

    Problem with opening PDF files. I have Acrobat Reader/Adobe Reader installed and updated. However, when trying to open PDF files online, say bankstatements, the browser will always open to a black, or dark gray page. What am I doing wrong?

  • Installed new memory and Macbook Pro wont start.

    I bought a total of 8GB from PNY for my mid 2009 MacBook Pro (2.8GHz Intel Core 2 Duo).  I installed it and my macbook wont turn on.  When I press the power button it just beeps.  The LCD doesnt turn on.   I reinstalled it a few times to make sure th