Can't access object using "id" or "name" if created with actionscript

How can you register an instance of an object with actionscript so that it's id or name value is accessible?
I included a simple example where a Button is created using mxml and in the same way it is created using actionscript.  The actionscript object is inaccessible using it's "id" and "name" property.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            protected function application1_creationCompleteHandler(event:FlexEvent):void
                import spark.components.Button;
                var asBtn:Button = new Button();
                asBtn.label = "actionscript";
                asBtn.x = 200;
                asBtn.id = "asButton";
                asBtn.name = "asButtonName";
                addElement(asBtn);
                trace("mxmlButton="+this["mxmlButton"].label); // returns: mxml  label
                //trace("mxmlButton="+this["asButton"].label); // returns runtime error: ReferenceError: Error #1069: Property asButton not found on TestId and there is no default value.
                //trace("mxmlButton="+this["asButtonName"].label); // returns runtime error: ReferenceError: Error #1069: Property asButtonName not found on TestId and there is no default value.
        ]]>
    </fx:Script>
    <s:Button
        id="mxmlButton"
        label="mxml label"
        alpha="0.8"/>
</s:Application>

Hi Dan,
It is a very rare occurrence when I miss not being able to access an object (object property, really) using the ["name"] notation for objects created using actionscript.
In MXML the compiler is conveniently adding an attribute to the class with the same name as the id, so you can conveniently refer to it using the [] notation. While we explicitly specify an application container to use, the MXML compiler creates a custom container which is a derivative of the base container and to that it adds properties for the children declared in MXML. I guess it also effectively calls "addElement" for us when  the container is being constructed.
Your example assumes that using "addElement" to add the button to the application container is the same as declaring a variable (ie property ). It isn't, so there's no point in looking for an property of the name "as3Button" using the [] notation, because it doesn't exist. The container is managing a collection of children in it's display list and that's not the same as being accessible as properties of the container.
Generally speaking, accessing properties using the ["name"] syntax isn't necessary.
Paul
[edit: you may wonder why "addElement" doesn't conveniently also add the "id" attribute to be an property of the container class. Unfortunately, it can't because the container class would need to be dynamic and it's not. A further complication would be that adding properties at runtime would invite naming clashes at runtime with associated mayhem. MXML can do this because the compiler generates the class and can trap name duplication at compile time.
Great question, BTW.
-last edit changed my "attributes" to be "properties" in line with Adobe's terminology]

Similar Messages

  • Can I access BIOS using JNI?

    Hi,
    Can I access BIOS using JNI on Windows and Linux platforms?
    Mathew

    I guess that the old BIOS functions (INT 15 for instance) are "emulated" by Windows when you are running old 16-bit DOS programs. They're mapped into equivalent Windows calls. Even if the BIOS implement different features you can't run the exact BIOS code. (Please correct me if I'm wrong)
    I don't know about Linux handling of BIOS calls.
    If you simply want to read (not execute) the BIOS code in Linux you can use a special device (/dev/kmem? I can't remember the exact name) and seek to the BIOS address.

  • I have moved from a G5 Powermac to an Intel Mac Pro and am porting over Items from a Backup HDD. How can I access and use drawings and documents created on the PC computer on the Intel computer ?

    I have moved from a G5 Powermac to an Intel Mac Pro and selectively porting over items from a backup hard drive.
    How can I access and use documents and drawings created on the PC based computer ?

    Clarisworks, you need Appleworks, which will only work with Mac OS X10.6.8 or earlier.  See this tip if you must go newer.  Mac Pros with newer hardware configuration than July 20, 2011 can't use Mac OS X 10.6.8 or earlier without this tip and then it would be Mac OS X Server.  I'm not sure if the new black Mac Pro supports that configuration or not.
    iPhoto, there is an iPhoto for all versions of Mac OS X.
    iTunes, there is an iTunes for all versions of Mac OS X.  Note with iTunes versions 11 and later, which are needed for syncing with iOS 7 or or later, you will lose coverflow, if you liked that feature.  Sadly you can't run an older version of iTunes from within Mac OS X 10.9 or later.
    Sketchup: http://help.sketchup.com/en/article/60107 shows the versions that will work with intermediate Mac OS X versions, and this shows the latest version: http://help.sketchup.com/en/article/36208 be sure to click on the operating system you choose to use.
    GIF - Viewing GIFs Apple's Preview can do that.  Editing them, I like http://www.lemkesoft.com/ Graphicconverter.
    DMG is able to be opened by all versions of Mac OS X.  This are just "disk images" which store programs on a virtual disk that will open when double clicked.    Frequently you'll find the installer of the said program inside.  To find out if the program itself is compatible with 10.7 through 10.9, see http://www.roaringapps.com/
    Otherwise see the resources on:
    https://discussions.apple.com/docs/DOC-2455
    If you end up deciding to stick with Snow Leopard.

  • How can I access and use the alphabetical keyboard of the phone ?

    How can I access and use the alphabetical keyboard of the phone ? I cannot find the answer in the manual of use.  Thanks for your help !

    Recently I was abroad and tried to contact my voicemail to check my messages. I was asked to enter a password and did not know how to use the letters below the figures on the keyboard.  I had to give up and wait until I was back in my country (no password is then needed).

  • Does my macbook air have a built in virus scan?  how can I access and use it? also any recommendations of what software if this is not avail ?

    does my macbook air have a built in virus scan?  how can I access and use it? also any recommendations of what software if this is not avail ?

    Contrary to what Geeks on Hugs is telling you, Mac OS X does indeed have a basic malware scanner. It is not a feature that is directly accessible to the user, and works a bit differently than every other malware scanner out there. Gatekeeper, which has been mentioned here, is entirely separate, and provides a different method for helping to protect you against malware.
    The anti-malware scanner in Mac OS X is called XProtect. When you download an application (or any other kind of executable code), it is automatically "quarantined," so that when you open it you're asked if you really want to do that. I'm sure you're very familiar with this aspect of Mac OS X if you have ever downloaded any apps from outside the App Store. What you don't know, though, is that each time you try to open a new app, that app is checked by XProtect. If it is identified as malware, you will not be allowed to open it, and will be warned that it's malware.
    At this time, there is no known malware that can infect a properly up-to-date Mac. All current malware will be blocked by one or more methods.
    For more information, see my Mac Malware Guide.
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com.)

  • Need to get IRole object using Roles Display Name

    Hi,
    I need to get IRole object using Roles Display Name. I had the below code in EP 2004 SP12 and it works. But the same code dont work in EP 2004s SP13
    user = request.getUser();
    profile = request.getComponentContext().getProfile();     
    String strRoles = profile.getProperty("Roles");
    String strRole[] = strRoles.split(",");
    IRoleFactory roleFactory = UMFactory.getRoleFactory();
    String roleUniqueId = null;
    int i = 0;
    boolean flagRedirect = false;
    for(i = 0; i < strRole.length; i++){
         try
              com.sap.security.api.IRole role = roleFactory.getRoleByUniqueName(strRole<i>);
              roleUniqueId = role.getUniqueID();
              if(!user.isMemberOfRole(roleUniqueId, true))
                   continue;
              flagRedirect = true;                    
              break;
         catch(UMException ex)
         catch(IOException ex)
    if(!flagRedirect){
    Where property Roles will have comma separated roles display names like "com.ABC.ortho_reports,com.ABC.lawns_ortho_reports,com.ABC.executive_reports"
    Please advise.

    Thanks Mrudula for the response. Sorry for the delay in responding.
    I get UMEException with the message "Role with uniqueName com.ABC.general not found"
    But it works fine if i specify Role unique role (like pcd:portal_content/com.abc.Marketing_Workbench/com.abc.Roles/com.abc.general).
    We are in the process of upgrading Portal environment from EP6.0 SP12 to EP7.0 SP13. Above scenario works fine in the older environment.

  • Can't sign in using any 3rd party email client with my iCloud account on any Mac. Tried every settings, My iCloud only works with Mail.app

    Can't sign in using any 3rd party email client with my iCloud account on any Mac or any other Mac. My iCloud will only work with Mail.app. All the clients I tried work perfectly well as long as I sign in with somebody else's iCloud account. But mine won't work no matter the client (Postbox, Unibox, Airmail...) and no matter the computer.
    I can access my account on iCloud.com, but I can't use email clients without getting error messages prompting me to check my password or login.
    I was able to use those clients in the past but a couple of months ago I got logged out of Airmail and the issue started just like that!
    I tried every possible mail server settings including the following:
    IMAP information for the incoming mail server
    Server name: imap.mail.me.com
    SSL Required: Yes
    If you receive errors when using SSL, try using TLS instead.
    Port: 993
    Username: The name part of your iCloud email address (for example, emilyparker, not [email protected])
    Password: Your iCloud password
    SMTP information for the outgoing mail server
    Server name: smtp.mail.me.com
    SSL Required: Yes
    If you receive errors when using SSL, try using TLS instead.
    Port: 587
    SMTP Authentication Required: Yes
    Username: Your full iCloud email address (for example, [email protected], not emilyparker)
    Password: Your iCloud password

    Those are the correct settings, and they work with any email client that supports Imap.
    Try again.

  • Can this device be used as an external hard drive with a macbook pro laptop to use files on the airport?

    can this device be used as an external hard drive with a macbook pro laptop and use files on the airport time capsule?

    If you mean an AirPort base station other than the Time Capsule, it doesn't have internal storage.
    If you mean a Time Capsule, its internal drive can be used for regular file storage but shouldn't be; as with all drives, it'll eventually fail. You're better off using a standalone drive and setting Time Machine to back it up as well.
    (112309)

  • How can I access my parents iCloud account remotely to assist with photo management and printing?

    How can I access my parents iCloud account remotely to assist with photo management and printing?

    I tried that without any luck. I was hoping I could get Apple to reset it for me or delete the account so I could recreate it or at least tell me what is listed as my birth date, the security question answer.

  • Exporting Layers to PNG files using each layer name to create the file name??

    Hi All
    I'm trying to sort the following problem and was hoping somebody here could help with a scripting solution - my knowledge extends as far as actions unfortunately - which I don't think is appropriate for this.
    I've created a User interface in Illustrator with many layers and have exported this as a psd with layers.
    Basically what i'm wanting to do is export every layer as a png file while using the layer name to create the file name - each layer needs to be clipped.
    There is no transparency in the png.
    I've run the export to files script - but the names are too long and there is no anti aliasing.
    I've tried running a script from Illustrator - but it doesn't see sub layers - and doesn't name the layers.
    any help would be appreciated.
    thanking you in advance
    regards
    nate

    Hi,
    We just released this tool: FERRY (http://ferry.thedamarmada.com). It does exactly what you want and a little bit more.
    I think it's worth it a try.
    It comes with a free demo that will export 5 layers.
    Take a look and let us know if it's what you need.
    It could be easily tweaked.
    Jordi

  • I purchase Adobe Elements Photoshop 12 & Premiere 12 together from a camera shop in town.  When I tried to use the Premiere, it splashed "created with the trial verson" over all of the photos. How can this unsightly watermark be removed. It has severely h

    I purchased  Adobe Elements Photoshop 12 & Premiere 12 together from a camera shop in town.  When I tried to use the Premiere, it splashed "created with the trial version" over all of the photos. How can this unsightly watermark be removed. It has severely hampered my timeline to start and finish this project. Why would a purchase software product purport to be a "trial" version?

    This indicator will appear when you have not registered your product or typed in the serial number for the product.
    Once you've added the serial number, any future products will not display this indicator.
    To remove this this indicator from videos created before you added the serial number, you'll need to delete the rendered files.

  • How can I access a thumb drive plugged into an airport with my iPad?

    how can I access a thumb drive plugged into an airport with my iPad? I am trying to set up an information point to serve weekly info over a NOT connected to the internet airport.

    You can't. There are a couple of devices such as AirStash and the GoFlex drive that you can access over WiFi. They are limited, as I understand it, though.

  • HT1893 How can I still print using a 'hp designjet 120nr (C7791B)' with OS X 10.8.3?

    How can I still print using a 'hp designjet 120nr (C7791B)' with OS X 10.8.3? I cannot get the drivers to work?

    bdmorgan wrote:
    Thank you once again Matthew. I understand the importance of being thourough and followed your instruction exactly. I really thought that this would solve it and was ready to click 'This solved my question'. However I still have the same print options as before, no 'A1 on the roll'.
    Although, when I copied:
    'sudo pkgutil --forget org.linuxprinting.foomatic-rip'
    into Terminal it did say somehting along the lines of 'nothing found' (sorry I didnt copy the text). Could this be part of the issue?
    In this case the instructions were incorrect.  I forgot that the uninstaller would run that command.  The reason for that command was to let the system know that foomatic-rip 4.0.6 had been removed.  I am sure that you were able to then install foomatic-rip version 3.43.2.15.  There are two ways to confirm that the older version is now installed.  First, if you can print at all, it is present.  You could also copy and paste the following command in the Terminal.  It should respond with the version that is installed:
    pkgutil --pkg-info org.linuxprinting.foomatic-rip | grep version
    Do I need to change the PPD at all?
    There is no need to change the PPD.  PPDs are reflective of the software (drivers) that are called from the PPD.  You can put anything you want in the PPD.  If that capability is not in the driver, having it in the PPD won't make it work.
    Setting a job to print from A1 Roll Paper is a two step process.  First you select the Paper Size which is A1.
    Then look under the pop up menu below Paper Size for an item called Paper Feed.
    Select Paper Feed.  Then you will be able to select where/how the paper is being fed to the printer.  This is where you can choose Roll Paper (Cut) or Roll Paper (No Cut) among other choices.
    Other drivers may have A1 Roll Paper listed under Paper Size.  Perhaps that is how the HP driver was.  There would still have had to be a place, then to check whether or not you wanted the paper to be cut and/or whether you were feeding sheets of paper from one of the other paths.
    Let us know if you can find all the options now and that you are able to keep your normal workflow.

  • HT2486 i created a group in address book and when wanted to use it it does not allow me to use it in email how do use a group name i created?

    I created a group in address book and wanted to use it, it does not allow me to use it in email how do I use a group name i created?

    How many in the group? Some ISP's have a restriction on that. Check with your ISP.

  • I can't open iTunes message says" can't read itunes library.itl because it was created with a newer version"

    I can't open iTunes message says" can't read itunes library.itl because it was created with a newer version"  thank you for any help!

    My ipod did that all day yesterday then went into lockdown ! now the dam thing wont do anything !!!! its stuck in download mode!!!!!!!!!

Maybe you are looking for

  • Hdmi output not found under playback in the control panel

    I am trying to get sound to go through my tv with my HDMI cable.  I looked in the control panel under sound - playback.  I do not see the option of the hdmi output.  I have right clicked on the speaker and clicked disabled and it still does not come

  • View ALL content on TV?

    Hey, i have 1 syncing computer and 2 streaming computers connected to my TV. Currently, i can only view each separate computer's content, but is there a way to view a menu with ALL the content from ALL three of the computers? thanks

  • SAP HANA Spatial Processing

    Hi expert, Please anyone can help me regarding Spatial feature of SAP HANA. How can i use this feature: 1>Suppose i have already data with state & city and country. 2>how can i start practice from basic to high level implementation. Your help will ap

  • What is The sustitute of flash player for ipad2

    I Face difficulties when opening a website that needs flashplayer

  • Agent dropping every 11 minutes and reconnects

    Tidal master 5.3.1.396 windows Agent added windows 3.1.0.05 Just added new Agent and agent is dropping every 11 minutes Re-installed agent and rebooted no luck Checked agent log and I am seeing this: _20141217 13:36:53 <err.TIDAL_AGENT_1.ES_INVJOBSCH