Dynamic Referencing in AS3.0

I am writing an application that allows the user to choose a
subset of the data that will be displayed to them. I have eight
checkboxes on the stage ("check1" - "check8") and each checkbox
relates to a particular XMLList (xmlLogic, xmlSetTheory,
xmlPredCalc, etc.). I put together an array of the possible xmlList
variable names and was planning on using that to feed the data into
one big xmlList so that I could randomize from the sets selected by
the user; i.e., if a user chose only Logic then they'd get a
randomized set from the logic XMLList. If they chose Logic and Set
Theory, then they'd get a single random list from the list of both
xmlLogic and xmlSets, and so on.
I cannot, however, get Flash to dynamically reference the
xmlList data from the array of strings. Is there any way to do
this?
Note: I've not got this in classes right now, though if
that's the only solution, I'm willing to go that way.
Thanks!
Stevie

Duh. I just realized I should've omitted the quotes around
the var names in the card array. My bad. Totally.

Similar Messages

  • Using dynamic referencing in PDF Form with Checkboxes

    I have created a checklist that contains approx 60-70 steps. About 20 of them are to have a checkbox that fills an adjacent field with the date, and another with the user name. I have already got this functioning as a stand alone process.
    aaa = checkbox
    aaadate = field for date
    aaaname = field for name
    [code]
    function test() {
    var one = this.getField("aaa");
    var two = this.getField("aaadate");
    if (one.value == 'Yes') {
    if (two.value == "") {
         this.getField("aaadate").value = util.printd("dd-mmm-yy",new Date());
         this.getField("aaaname").value = identity.name;
    }} else if (one.value == 'Off') {
         this.getField("aaadate").value = "";
         this.getField("aaaname").value = "";
    [/code]
    I do not want to write a piece of code for each checkbox so I am trying to figure out how to use dynamic referencing so that when i check on a checkbox, the code takes the checked checkboxes' name (aaa) and is able to determine the two other fields name by appending/concatenating (name + "date"  = aaadate)
    I have tried various methods and done tremendous research; I'm not sure if I lack the knowledge to incorporate what I've found properly, if I just have been looking in the wrong places for the wrong things. It seems like this should be possible in a PDF form...
    Please help

    You need to inject the part of the field name that changes as a variable. So your code would be something like this:
    function test(base) {
        var one = this.getField(base);
        var two = this.getField(base+"date");
        if (one.value == 'Yes') {
            if (two.value == "") {
                this.getField(base+"date").value = util.printd("dd-mmm-yy",new Date());
                this.getField(base+"name").value = identity.name;
        } else if (one.value == 'Off') {
            this.getField(base+"date").value = "";
            this.getField(base+"name").value = "";
    And you would call it like so:
    test("aaa");
    test("bbb");
    etc.

  • Dynamic referencing the numChildren in a mc instance

    I am trying to dynamically read the number of children in
    movieclips that are created at runtime. These mc "windows" have
    several items in them, (scrollbars, text fields, image, etc...). I
    can run tweens and stuff by referencing these mc instance with:
    DocClass(root).popupPages.getChildByName(pageToBuild) //
    works as a reference to a specific item
    However, this same syntax fails when I add: numChildren
    DocClass(root).popupPages.getChildByName(pageToBuild).numChildren
    // generates an error.
    DocClass(root).popupPages[getChildByName(pageToBuild)].numChildren
    // generates an error.
    What I want to do is run a for() statement on the mc to have
    it read back all of its contents. However, it fails to do that
    because it can never give me the number of children it
    contains.

    It is possible that the instance name in the library or on
    stage is different then the instance name in your code.
    Meaning: var mc_scroll:ScrollBar is different from the
    instance on stage or in the library "scrollBar_mc"
    I found that fl.controls.ScrollBar; does not work unless you
    add it to your library or stage.

  • Dynamically creating a AS3.0 code based on animations made at runtime

    Hello everyone,
    I am new to AS3.0 and always getting tasks that is very very challenging. Here is the challenge.
    Need to create a flash application where the user can create animations using images(upload) and text dynamically and export to a swf file. This was my previous post and the answers from the forum members was "impossible - 95%" and "Possible - 5%" (my average calcu).
    http://forums.adobe.com/thread/678202?tstart=0
    Now i got an idea from the "Possible - 5%". That is
    as per the discussion in the above link there are compliers that can create swf files from the command prompt using haxe, swfmill, neko etc etc. these requires a AS3.0 class file to get the output.
    now my question is can we generate the AS3.0 code from the swf file where the animations using images, text are done on the runtime stage. after the user is done with his animations he can click publish btn were we need to create the AS3.0 code and send to the command promt for getting the swf file as output.
    i think this task is quite hard. but any help regarding this will let me in a right direction.
    thanks in adv for any helps

    Assuming that WYSIWYG concept is valid, you are better off with Flex. Flex offers xml structure that you can use as template and just write values. Then this XML can be used by compiler as it is used in Flex.
    In any case, this is a very tedious and advanced task you are embarking on. If you are talking about couple of objects and simple animations - it is not that bad. But if there is more - it is difficult mainly because of the multitude of use cases and exponential growth in objects relationships from both display list and user interaction standpoint.
    I was a part of such project about 2 years ago and I see that one has to be an excellent UX engineer, very good architect and an advanced AS developer in order to make this kind of application worth pursuing.

  • Dynamic menu in AS3

    I would like to create in AS3, something like, it's in AS2
    //_root
    var menuArray:Array=new Array("menu0","menu1","menu2","menu3","menu4","menu5");
    var gap:Number=10;
    var xmenu:Number=10;
    for (var i:Number=0;i<menuArray.length;i++){
        this.attachMovie("menu_bot", "menu"+i, this.getNextHighestDepth(), {_x:xmenu, _y:100});
        xmenu=xmenu+this["menu"+i]._width+gap;
        this["menu"+i].num=i;
    //menu_bot
    var num:Number;
    textM.text=_root.menuArray[num];
    this.onPress=function(){
        trace(num);
    www.4x4nz.sk/downloaded /dinamikmenuas2.fla

    well you understood me, I want an alternative to the script what I put in AS2,
    but I think. of the script as you sent me centenary assume that I have in the library button menu0 menu1 .....
    But I have only one menu button.
    because I tried it and it did not work.
    var ClassRef: Class = Class (getDefinitionByName ("menu" + i));
    I will be happy if later you look again

  • Dynamic HTTPService request AS3

    I'm doing a mashup in Flex right now using Yahoo Maps. One of
    the functions allows users to create their own routes.
    Here's the problem. I need a dynamic httpService request
    because I never know beforehand how many markers a route holds.
    Here's my code:
    [Bindable]
    private var rssFeed:String;
    private function opslaanRoute(event:Event):void
    if(this.tekstInputVenster.text!="")
    if(markerLijst.length>0)
    rssFeed = "<route>";
    rssFeed +=
    "<routebeschrijving>"+this.tekstInputVenster.text+"</routebeschrijving>";
    var lengte:Number = markerLijst.length;
    for(var d:Number=0;d<lengte;d++)
    rssFeed +="<marker>";
    rssFeed +=
    "<latlon"+d+">"+markerLijst[d][0]+"</latlon"+d+">";
    rssFeed +=
    "<indexMarker"+d+">"+markerLijst[d][1]+"</indexMarker"+d+">";
    rssFeed +=
    "<titel"+d+">"+markerLijst[d][2]+"</titel"+d+">";
    rssFeed +=
    "<beschrijving"+d+">"+markerLijst[d][3]+"</beschrijving"+d+">";
    rssFeed +="</marker>";
    rssFeed += "<aantal>"+indexMarkers+"</aantal>";
    rssFeed += "<userid>"+_loginid+"</userid>";
    rssFeed += "</route>";
    opslaanR.send();
    else
    Alert.show("U moet markers toevoegen om op te slaan!");
    else
    Alert.show("U moet een routebeschrijving toevoegen om op te
    slaan!");
    The httpservice looks like this:
    <mx:HTTPService
    id="opslaanR"
    url="url"
    useProxy="false"
    method="POST"
    resultFormat="e4x"
    result="opslaanSucces(event)"
    showBusyCursor="true"
    >
    <mx:request>
    {rssFeed}
    </mx:request>
    </mx:HTTPService>
    The "aantal" tag is the number of markers a route holds.
    Basically I want to loop the $_POST variables in php using "aantal"
    so I can add them to my database. The PHP works flawlessly but it
    never gets the httpservice values.
    Please help.

    well you understood me, I want an alternative to the script what I put in AS2,
    but I think. of the script as you sent me centenary assume that I have in the library button menu0 menu1 .....
    But I have only one menu button.
    because I tried it and it did not work.
    var ClassRef: Class = Class (getDefinitionByName ("menu" + i));
    I will be happy if later you look again

  • Adding Image to Simple Button Dynamically Using AS3

    Hi,
    I need some help trying to figure out how to dynamically add an image (PNG or JPEG) that I can place in the library to a simple button also dynamically created in AS3.
    Is there a way to (1) add the image instead of using a text label and have it centered in the button?
    Here's the AS3 for the simple button without the image (currently uses text label but would prefer if possible to substitute an image for the text:
            var mc2:MovieClip = new MovieClip();
            mc2.addChild( bgRed2 );
            mc2.addChild( txt2 );//currently uses text label; would prefer to use an image istead of text
            var mc2a:MovieClip = new MovieClip();
            mc2a.addChild( bgRed2a );
            mc2a.addChild( txt2a );currently uses text label; would prefer to use an image istead of text
            var clearBtn:SimpleButton = new SimpleButton();
            clearBtn.upState = mc2;
            clearBtn.overState = mc2a;
            clearBtn.downState = clearBtn.upState;
            clearBtn.hitTestState = clearBtn.upState;
            clearBtn.x = 0;
            clearBtn.y = 0;
            addChild( clearBtn );
            clearBtn.x = 55;
            clearBtn.y = stage.stageHeight-clearBtn.height;
    Any help appreciated.

    assign your image a class name (eg, Img1). you can then use:
    var img1D:BitmapData=new BitmapData();
    var img1:Bitmap=new Bitmap(img1D);
    cleanBtn.upState=img1; // for example, button's upstate is the image.
    // if you wanted some background and the image centered on the background, create your background (sprite or movieclip), use addChild to add img1 to your background and center it.  then assign your button's upState etc to be your background

  • Parenting and child control with AS3

    Hi,
    I'm new to AS3 and although I can see some good practice and functionality I'm constantly getting stucked and can't yet make things that I would do so easily with AS2 - I almost need to relearn it from scratch!. Still I would appreciate some help and guidance on this...
    I made a class that creates a "kind" of menu with data from a XML file and basically what it does when it is called is create a emptyMC (a container), add a childMC (a square) and add another child (a text label). When I create the container I'm trying to add a MouseEvent that can act on each the container instances but all I can get is a MouseEvent on object containing all the added MCs. The code follows.
    Can anyone enlight me with this issue or explain what am I doing wrong.
    I can't understand well the dynamic parenting with AS3 and the lack of using instance names and dot parenting doesn't help.
    Thanks in advance.
    Note to Adobe: Previous versions of Flash Help Files and AS reference were by far more helpful than in CS4!
    In the timeline:
    import assets.myDynMenu;
    var theMenu:myDynMenu = new myDynMenu("menu.xml");
    stage.addChild(theMenu)
    stop();
    In the class:
    package assets
         import flash.display.*;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.text.TextField;
         import flash.net.*;
         public class myDynMenu extends Sprite {
              // INIT EXTERNAL DATA LOAD
              public function myDynMenu(theData) {
                   // LOADS THE MENU DATA FROM PREFORMATTED XML
                   var loader:URLLoader = new URLLoader();
                   var url:URLRequest = new URLRequest(theData);
                   loader.addEventListener(Event.COMPLETE, buildTheMenu);
                   loader.load(url);
              // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
              public function buildTheMenu(event:Event):void {
                   var xml:XML = new XML(event.target.data);
                   for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                        // ADDS A CONTAINER
                        var itemContainer:MovieClip = new MovieClip();
                        itemContainer.name = "menu" + i;
                        // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                        // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                        itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                        itemContainer.x = 100 * i;
                        itemContainer.y = 0;
                        itemContainer.mouseEnabled = true;
                        itemContainer.mouseChildren = false;
                        addChild(itemContainer);
                        // ADDS A CHILD TO CONTAINER (a square)
                        var itemBase:MovieClip = new MovieClip();
                        itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                        itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mConfig.mainIt emH);
                        itemBase.graphics.endFill();
                        itemBase.name = "base" + i;
                        itemBase.mouseEnabled = false;
                        itemBase.mouseChildren = false;
                        itemContainer.addChild(itemBase);
                        // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                        var theLabel:TextField = new TextField();
                        theLabel.x = 5;
                        theLabel.y = 5;
                        theLabel.selectable = false;
                        theLabel.mouseEnabled = false;
                        theLabel.border = true;
                        theLabel.text = xml.menuData.menuItem[i].mName;
                        itemContainer.addChild(theLabel);
              // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
              private function onMouseOver(event:MouseEvent):void {
                   event.stopPropagation();
                   trace("You are over " + this.name );

    use:
    package assets
         import flash.display.*;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.text.TextField;
         import flash.net.*;
         public class myDynMenu extends Sprite {
              // INIT EXTERNAL DATA LOAD
              public function myDynMenu(theData) {
                   // LOADS THE MENU DATA FROM PREFORMATTED XML
                   var loader:URLLoader = new URLLoader();
                   var url:URLRequest = new URLRequest(theData);
                   loader.addEventListener(Event.COMPLETE, buildTheMenu);
                   loader.load(url);
              // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
              public function buildTheMenu(event:Event):void {
                   var xml:XML = new XML(event.target.data);
                   for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                        // ADDS A CONTAINER
                        var itemContainer:MovieClip = new MovieClip();
                        itemContainer.name = "menu" + i;
                        // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                        // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                        itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                        itemContainer.x = 100 * i;
                        itemContainer.y = 0;
                        itemContainer.mouseEnabled = true;
                        itemContainer.mouseChildren = false;
                        addChild(itemContainer);
                        // ADDS A CHILD TO CONTAINER (a square)
                        var itemBase:MovieClip = new MovieClip();
                        itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                        itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mCon fig.mainItemH);
                        itemBase.graphics.endFill();
                        itemBase.name = "base" + i;
                        itemBase.mouseEnabled = false;
                        itemBase.mouseChildren = false;
                        itemContainer.addChild(itemBase);
                        // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                        var theLabel:TextField = new TextField();
                        theLabel.x = 5;
                        theLabel.y = 5;
                        theLabel.selectable = false;
                        theLabel.mouseEnabled = false;
                        theLabel.border = true;
                        theLabel.text = xml.menuData.menuItem[i].mName;
                        itemContainer.addChild(theLabel);
              // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
              private function onMouseOver(event:MouseEvent):void {
                   event.stopPropagation();
                   trace("You are over " + event.currentTarget.name );

  • Dynamically reference :old.column_ name in trigger

    Hi all,
    I am writing an application for which i would like to include a limited audit trail.
    I have a form that is based on a table with approx 100 columns and wish to write the :old.column_name value on fields that have been updated, along with userid and date/time to an "audit" table.
    I think that I can do this by using the Before_update trigger and then the IF UPDATING ('column name') condition. However, for maintenance and readabiility, I wish to be able to dynamically reference the :old.column_name value, which I cannot get working.
    I know it can be done with a large IF statement, but due to the number of columns involved, this can lead to a maintenance nightmare. Also, if I can get this working, I want to include the procedure in a library for other applications, thus the need for dynamically referencing the table and column names.
    My proposed logic for the before_update trigger is:
    Declare Vcolumn_name Varchar2(50)
    Get column names for table (using select cursor)
    loop through cursor
    Vcolumn_name := column name
    IF UPDATING (Vcolumn_name) then
    insert userid, timestamp, :old.Vcolumn_name into audit table
    end IF
    next cursor row
    :old.Vcolumn_name is where I am having trouble.
    Is this possible?
    Thanks
    Peter

    The pre-update trigger won't store the value of the old.column . If you are querying the data and then updating then use the POST-QUERY trigger to store the current values in global variables. In the PRE-UPDATE trigger assign the global variables to the columns of the audit tables.
    For instance in the PRE-FORM trigger initialize the global variables :
    :GLOBAL.VAR1 := ' ';
    :GLOBAL.VAR2 := ' ';
    In the POST-QUERY trigger
    :GLOBAL.VAR1 := :BLOCK.COLUMN1;
    :GLOBAL.VAR2 := :BLOCK.COLUMN2;
    In the PRE-UPDATE trigger
    INSERT INTO AUDIT_TABLE (COL1, COL2)
    VALUES(:GLOBAL.VAR1, :GLOBAL.VAR2);
    Hope this helps.

  • Dynamic Reference to Registered XSD

    I generate docs from SELECT like this,
    <span style="color:red;">(I do not store this type of doc in DB/XDB)</span>:
    <div style="color:blue;">
    SELECT '&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;' || chr(10) ||
    xmlelement
    (&quot;ReinsuranceXfer&quot;,
    xmlattributes
        ('http://blah.com/blah2/types/common' AS &quot;xmlns&quot;,
         'http://www.w3.org/2001/XMLSchema-instance' AS &quot;xmlns:xsi&quot;,
         'http://blah.com/blah2/types/common http://blah3/xmlschemas/Sales_v1.xsd'
         AS &quot;xsi:schemaLocation&quot;),
     xmlelement
        (&quot;SalesTransactions&quot;,
         xmlattributes('DirectTransactions' AS &quot;xsi:type&quot;).......
    </div>
    the schema &quot;Sales_v1.xsd&quot; is XDB-registered.
    In stead of hard-coding <strong>&quot;Sales_v1.xsd&quot;</strong> in PL/SQL or View definition
    I want to DYNAMICALLY reference the value, so when I switch to
    version 2, registering the new schema (deleting the old one)
    the value <strong>&quot;Sales_v2.xsd&quot;</strong>
    can be dynamically referenced.
    Is there a better/&quot;smarter&quot; way to achieve the dynamic reference
    than this ?
    <div style="color:blue;">
    SELECT substr(any_path, instr(any_path, '/', -1) + 1) xsd
        FROM resource_view
       WHERE any_path LIKE '%Sales%.xsd';
    </div>
    thanks
    10gr2

    You can't invoke methods on bits of String as if they were references to objects. (Java isn't like PHP in this regard.)
    You can, however, use arrays as db suggested.
    Let's say I have a hundred toggle buttons. I might give them names like "okButton" "exitButton" etc. Or I might make them elements of an array of buttons, buttonArr.
    And I have a method toggle(int) that accepts an integer as input and verifies that the argument is within the range 1 to 100, throwing an exception if it is not. This method is intended to select the toggle button that corresponds to the integer it receives as input as selected. So the method would be implemented as
    buttonArr.setSelected(true);

  • How to add fast forward - rewind functionality using flvplayback in as3

    hello,
    i am using flvplayback (dynamically add from as3), now to add fastforward - rewind functionality in it.
    Thanks,
    Vishal Parekh

    The docs say the inBufferSeek is intended for "Flash Media Server 3.5.3 and Flash Player 10.1" or higher and does not work in AIR3.0 for iOS. Do you meet those requirements? They call that protocol RTFMP.
    The doc also explains that when inBufferSeek=true, and you seek() or step(), an event is dispatched if it was successful. You should see if these events fire.
    From the docs:
    When inBufferSeek=true and a call to NetStream.seek() is successful, the NetStatusEvent info.description property contains the string "client-inBufferSeek".
    When a call to NetStream.step() is successful, the NetStatusEvent info.code property contains the string "NetStream.Step.Notify".
    If you don't see those events, you know you have an issue.

  • Dynamic reference for movieclips

    I have read several examples both on the web and in the Adobe
    help files regarding dynamic referencing.
    I cannot get Actionscript to recognize a dynamically named
    clip such as in the attached for loop.
    Any suggestions as to why thumbCan[thumbMC+i] returns
    undefined and therfore doesn't allow anything to be loaded?

    trace("trace1= "+thumbCan["thumbMC"+i]);

  • Preloading AS3

    I have AS3 for a preloader on a first frame of a scene and
    also the actual movie clip loading bar on the same frame. After it
    loads it sends the user to another scene.
    1. Is it ok if the menu bar, dynamic text, and AS3 code for
    the preloader are on separate layers?
    2. Is there a need to have a second frame with a stop action
    after the first?
    Thanks.

    Yes, you can have various things on various layers in the
    preloader, and you do not have to include a stop(); in the second
    frame.

  • Global Variable in a User Exit

    Folks, I have a small problem. I have a Exit and there are several includes with in the exit. Due to modularization they have written Forms in One Include and actual call is happening at someother include. I need to code in a logic based on a value of variable. The variable is flag which is updated at Form Include.
    I couldnt add the field at the top include and it does not allow me to due a Implicit enhancement at Beginning or the end.
    Can you please suggest how to add this field which could be visible through out the function group.
    Thanks,
    Balakumar

    Hi,
    Access the variable using dynamic referencing.
    constant: field(50) type c value '(program name)flag'.
    here program name is main where variable is declared.
      field-symbols: <flag>.
    * Assign an individual variable
      assign (field) to <flag>.
    if <flag> is assigned.
    endif,

  • Facing problem with Itemrenderer in Datagrid...

    Hi,
    Any idea how the following code using Action script..
    <mx:DataGridColumn headerText="Online"
    dataField="online">
    <mx:itemRenderer>
    <mx:Component>
    <mx:CheckBox id="chkBox"/>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    As it is in actionscript....
    I dont want to create seperate component... everything i want
    to write in single file.
    something like...
    var dgc:DataGridColumn=new DataGridColumn();
    var chkBox:CheckBox=new CheckBox();
    Here how to add chkBox to dgc using Itemrenderer??? any
    idea??
    Is its possible???

    I am having the exact same issue! All my components are
    DYNAMICALLY generated with AS3 here is my post:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1344455&enterthread=y
    ALL examples I find or are given involve static components
    which I cannot have!
    I hope someone helps us out.

Maybe you are looking for