How to import MXML Component in ActionScript

Hello,
I'm having a structure similar to this:
root
   - components
       - subcomponents (MyCustomMXMLComponent)
   - views
In views package I have a piece of AS where I want to instantiate an MXML Component from subcomponents.
In Views:
var data:DisplayObjectContainer=new components.subcomponents['MyCustomMXMLComponent'];
But that throws an error.
I need a syntax similar to the one above because I'm running a for loop and changing data variable to be a new MXML component on each iteration.
Any idea how I can solve this?
Thank you.

OK, so:
var length:int=arrSubcomponents.length;
for(var i:uint=0;i<length;i++)
          //Decide parent
          var parent:IVisualElementContainer;
          if(arrSubcomponents[i].group && arrsUbcomponents[i].group==1){parent=firstGroup;}
    else{parent=secondGroup;}
          //Add to parent
          var childClassName:String='components.subcomponents.'+arrsUbcomponents[i].className;
          trace(childClassName);//So far so good the path is correct, I checked.
          var childClass:Class=Class(getDefinitionByName(childClassName));
          trace(childClass);//It breaks here with the error below
          var child:IVisualElement=new childClass() as IVisualElement;
          trace(child);
          parent.addElement(child);
The error:
ReferenceError: Error #1065: Variable FirstCustomMXMLComponent is not defined.
          at global/flash.utils::getDefinitionByName()

Similar Messages

  • How to Access MXML components  from ActionScript class

    Hi ,
    I am having a Application Conataner , in which i am having a Form Container with some Label in it .
    This is some thing similar to this as shown :
    <Mx:Application>
    <Mx:Form>
    <Mx:Label text="Hello world"/>
    </Mx:Form>
    </Mx:Application>
    Can any body please let me know how can i access this Form's Label , from an ActionScript class .
    catch(error:*)
    // Here i want to access these Objects and set data to that Label .
    Basically My requirement is that iinside the catch block of my ActionScript class , i want to set some text to the Label , Please
    let me know if this is possible or not also ??
    Waiting for your Replies .

    Hi these both are not same these refer to different one...
    Well let me explain...
    Application.application.myCustomComp.myLabel.text = "sometext"; sets the label "myLabel" which is present inside your customcomponent(which is in main application).
    Application.application.myLabel.text = "sometext"; sets the label "myLabel" which is present directly inside your main application.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Label id="myLabel"  text=""/> // So inorder to set the label(myLabel) present here you will use directly the 2nd line of code.
    <mx:CustomComp id="myCustomComp" /> // So inorder to set the label(myLabel) present inside this component you use 1st line of code.
    </mx:Application>
    Hope now its clear.
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Instantiate MXML component in actionscript - percent sizing issues

    Hey guys,
    I'm busting my head trying to sort out this issue.
    I have a MXML custom component which is being instantiated in
    actionscript, e.g.:
    component:CustomComponent = new CustomComponent();
    The custom component extends Canvas (i.e. the root XML tag is
    a Canvas). Inside the component is another Canvas that wraps the
    children so they can be laid out using constraint-based
    measurements (e.g. top, left, right, bottom).
    The component is then added to a VBox through
    addChild(component).
    Here's the problem - the component doesn't appear on the
    screen. It's because it's not getting a width and height set
    correctly. If I bind the Canvas inside it to
    height="{parent.height}" and width="{parent.width}", then it
    appears correctly. The problem with this is that the compiler warns
    me that the binding won't be able to detect changes to the parent
    sizes. This sux when I launch full screen mode because it doesn't
    expand to fill the VBox (which sizes correctly).
    Is there something I'm missing here? How does the percentage
    based widths and heights get applied? Perhaps there's a breakdown
    in the flow or something.
    Thanks!!

    Thanks Peter, but I've given that a go already.
    I'm looking into trying to get the component instantiated
    through MXML, and then returning it using it's ID. If another
    container addChilds it, then the component will be removed from the
    (temporary) display list it was previously added to (simply for
    instantiating), correct?
    I think these layout issues are only when I instantiate it in
    actionscript, but further poking should reveal the truth....

  • How to call mxml component in another mxml component

    I have added submenu in menu bar in adobe Flex.
    For Example : Menu A has submenu A1 A2 A3 like that, right now Submenu is not performing any action.
    I want  to open a new mxml  page on click of  submenu A1 in the same frame .Please suggest me how to achieve it
    Simply, I want to to have a MENU BAR just like in any website, with submenus  and on click of each submenu  items, it should navigate to other page .
    Regards,
    Gaurav

    If the functionality you need is self-contained within the component, you can dispatch generic event to the main application, and over there define the handler function.
    If you need more specific interaction triggered by the component, you have to create custom event Class and then dispatch custom event.
    I believe there are some clear tutorials in Flex in a week: http://www.adobe.com/devnet/flex/videotraining/?devcon=f2
    HTH,
    FTQuest

  • How To Import Orcad Component Libraries into Multisim

    Ive been using LabView for a long time now, and I have just started using Multisim and Ultiboard.   A lot of companies all ready have orcad libraries for their components, such as Maxim and Microchip.  Is there anyway to import these into Multisim or do I have to recreate everything? 
    Specifically, I am trying to import these libraries.  It would also be nice to import others too.
    http://www.maxim-ic.com/tools/spice/operational_amplifiers/orcad/
    Thanks In Advance

    Multisim does not use library files the way other packages do.You should still be able to use these files to create a new component with the component wizard tool. I am not sure how other packaqges work when it comes to importing spice models, but with Multisim it is a manual process of creating an individual part with a symbol and footprint. This is no guarantee that these models will work inside Multisim. You just have to try them and see.
    There are tutorials available in the user's manual on component creation. Also, follow the link in my signature and there you will find a link to other tutorials in the Knowledge Base.
    I hope this helps some.
    Message Edited by lacy on 07-23-2008 06:05 PM
    Kittmaster's Component Database
    http://ni.kittmaster.com
    Have a Nice Day

  • Importing JSF Component in webdynpro

    Hi,
    Please let me know how to import JSF component in webdynpro in  CE 7.2 SP 01.
    Thanks,
    Raghu

    Hi Raghavendra,
    Please go through this [JSF (JavaServer Faces) Tutorial|http://www.vogella.de/articles/JavaServerFaces/article.html]
    Hope this helps!!
    Regards
    Vijay K

  • How to add interface to customlize MXML Component when use Flex Builder 3?

    How to add interface to customlize MXML Component when use
    Flex Builder 3?

    David,
    I don't believe you can add the interface via the creation
    dialog in FlexBuilder 3. You can always manually add the
    "implements" property to your MXML Component root tag. Something
    like this: <mx:VBox implements="com.mycorp.IMyInterface">
    If you want autogeneration of the interface, then create an
    ActionScript class with that interface and then copy the generated
    functions and setter/getters into the script block of your MXML
    component.

  • How to create package access MXML component?

    Hi
    In ActionScript we can create an internal class which can be referenced by the classes in the same package.
    How can we create the MXML component which can be referenced by the others in the same package?

    Packager Links https://forums.adobe.com/thread/1586021

  • Event in ActionScript Class not accessible by MXML Component

    I am implementing an ActionScript Class in my MXML Component,
    but it can't see the Event I'm specifying. I'm getting the
    following Error when I compile my application:
    Cannot resolve attribute 'myEvent' for component type
    myClass.
    How do I make the Event available to the MXML component?
    Thanks.

    Guess the compiler has a problem with semi-colons after the
    Event declarations. I removed the semi-colons, and was able to
    compile.

  • How to create custom MXML component accepting other MXML componenents as children

    How can I create an MXML component that when I use it in the "main" MXML, accepts other MXML components...
    For example:
    <s:WindowedApplication>
         <myComponent>
              <otherMXMLcomponent></otherMXMLcomponent>
              <otherMXMLcomponent></otherMXMLcomponent>
              <otherMXMLcomponent></otherMXMLcomponent>
              <otherMXMLcomponent></otherMXMLcomponent>
         </myComponent>
    <s:WindowedApplication>
    How do you declare such a component?
    Thanks in advance

    Bhè non so se ho capito .. ti spiego la prova che ho fatto io.. Dunque, io ho provato a creare un mio componente Custom e a metterci dentro degli oggetti miei di esempio.. Il componente di esempio si chiama mioComponenteCustom e all'interno è strutturato in questo modo:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx">
    </s:Group>
    Al posto dei puntini ci metto quello che voglio.. nel tuo caso i tuoi 2 famosi pulsanti..
    All'esterno chiamerò :
    <mioComponenteCustom>
         <s:DataGrid>
         </s:DataGrid
    </mioComponenteCustom>
    Dove DataGrid è un componente a caso qualsiasi.. Ora, con questa struttura non ricevo errori e sembra andare bene..
    Dimmi se ho capito bene o volevi fare altro..
    Max

  • How to import engine.security.facade software component in CE 7.1 SP3

    Hi experts,
    When I used com.sap.security.api.sda, there is a warning that it has deprecated. However, know that engine.security.facade (public part default) in software component ENGFACADE is the new component, I cannot find it in the CE environment.
    Where to locate engine.security.facade and how to import engine.security.facade into the infrastructure component?
    Thank you.

    Hi experts,
    When I used com.sap.security.api.sda, there is a warning that it has deprecated. However, know that engine.security.facade (public part default) in software component ENGFACADE is the new component, I cannot find it in the CE environment.
    Where to locate engine.security.facade and how to import engine.security.facade into the infrastructure component?
    Thank you.

  • How to extend an AS3 class in an MXML Component

    Hello,
    I have a few MXML Components based on the Spark Group.
    They all use MXML for layouta and AS3 for logic.
    They all have the same logic and I would like all to extend an AS3 class to have the same methods and properties isteand of declaring the same exact ones for each MXML Component.
    How can this be done please?

    Hm, no, I'm not explaing this properly.
    I have an MXML component based on the Spark Group.
    It has a few form elements.
    There are many such components.
    I want all to have two public methods: getData() and setData() which get and set data from and to the input elements.
    I don't want to write the exact same method for all of them.
    I would like to at least interface the MXML components with an AS3 class forcing them to have those 2 methods.

  • How to import the software component version in PI7.1

    Hi Experts,
    I am new to PI7.1 . How can we import the software component vesrion in PI 7.1.
    Regards
    Santosh

    Hi,
    go to Tools ---> Transfer form System Landscape Dir  ---> Import Software component vesrion
    Sorry, above method is for XI3.0
    Regards,
    Sarvesh
    Edited by: Sarvesh Singh on Dec 30, 2009 7:03 PM

  • How to call method in another mxml component

    HI to all friends out there. I am stuck at some point . I need to call public method which is in other mxml component file in another mxml component.
    So please tell me how i achieve this . I need to call inside event method which activate when user click on mu advancedatagrid item.
    So please tell me how to acheive this.
    Thank you in advance.

    If the functionality you need is self-contained within the component, you can dispatch generic event to the main application, and over there define the handler function.
    If you need more specific interaction triggered by the component, you have to create custom event Class and then dispatch custom event.
    I believe there are some clear tutorials in Flex in a week: http://www.adobe.com/devnet/flex/videotraining/?devcon=f2
    HTH,
    FTQuest

  • Interface not found in implements-attribute for MXML component

    Hi,
    I am trying to use the "implements" attribute for an
    MXML-component in order to implement an interface from a library
    like below (Flex 3). I get the error "Interface IClonable not
    found". The compiler does not complain about " import
    com.yworks.support.IClonable;", so the library is installed
    correctly. I use the library in many places in my project, it just
    does not find it in the "implements" tag. How can I fix this
    without reimplementing the component in ActionScript?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    implements="com.yworks.support.IClonable">
    <mx:Script>
    <![CDATA[
    import com.yworks.support.IClonable;
    ]]>
    </mx:Script>
    </mx:VBox>

    "mavdzee" <[email protected]> wrote in
    message
    news:gldjg8$js8$[email protected]..
    > Hi,
    >
    > I am trying to use the "implements" attribute for an
    MXML-component in
    > order
    > to implement an interface from a library like below
    (Flex 3). I get the
    > error
    > "Interface IClonable not found". The compiler does not
    complain about "
    > import
    > com.yworks.support.IClonable;", so the library is
    installed correctly. I
    > use
    > the library in many places in my project, it just does
    not find it in the
    > "implements" tag. How can I fix this without
    reimplementing the component
    > in
    > ActionScript?
    >
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > implements="com.yworks.support.IClonable">
    >
    > <mx:Script>
    > <![CDATA[
    >
    > import com.yworks.support.IClonable;
    >
    > ]]>
    > </mx:Script>
    >
    > </mx:VBox>
    I don't see anything where you're actually _implementing_ the
    interface, but
    I'd expect to see a different error if that's the problem.
    Still, I'd go
    ahead and implement the properties and methods in the
    interface, just to
    make sure.
    HTH;
    Amy

Maybe you are looking for

  • Apple Mail account suddenly offline, smtp offline

    iMac 27" (late 2009) updated to Mac OS X Yosemite 10.10 and Apple Mail 8.0 (1990.1) 17th October 2014. Mail accounts in Apple Mail where working as years before until Yesterday, 3th November 2014. Suddenly 2 out of 3 accounts where offline showing th

  • How do I set up my timer/clock for a 17 bit synchronous encoder?

    I am trying to get an output from a 17 bit Gray Code encoder. I need the position output for other projects. Here is a list of equipment being used: PCIe 6361 CP-850-17S-GC-CW encoder from Allied Motion SCB-68 I am trying a 3 wire connection. Clock +

  • Cannot see imported iphoto library

    I just installed the app store version of aperture. I imported my iphoto library as instructed in the demo video and with the instruction to keep the images stored in theor current location. When I go to projects the the images do not show up. Event

  • BPA_DEMO - Problem With SQL Scripts

    Hi, In order to understand BPA functionality i have downloaded 1.oracle_BPA_SUite_10.1.3.4_download.zip 2.oracle BPA Suite 10.1.3.4 Sample I am trying to setup the BPA Suite and execute the Case Study in the sample -oracle BPA Suite 10.1.3.4 Sample.

  • Issue a report by SCCM2012, but distribution was applied by WSUS

    Guys, need some help regarding doubts below:  I have a server environment, where a team manage the application of microsoft patches through WSUS own. However I need to know if it is possible or if there is any way to issue a report of installed using