Anyway to make MXML components static?

This isn't too important because I know how to do it well enough in ActionScript.  But I like the readability and convenience of MXML components, so if anyone knows if there is a way to make them static, please let me know.

As best I understand it, there is no way to creation Static Classes in ActionScript 3 or MXML:
Class Modifier keywords are dynamic, final, internal, and public.
http://livedocs.adobe.com/flex/3/html/help.html?content=04_OO_Programming_06.html
The Static keyword is only for variables, constants, or methods:
http://livedocs.adobe.com/flex/3/langref/statements.html#static
If you want to create static variables, constants, or methods inside an MXML File do it in a script block, which is the same way you do it in an ActionScript 3 file.

Similar Messages

  • Flex mxml components should be private by default

    Flex mxml components should be private by default. Does adobe
    plan to fix this in future versions?

    Just noticed this and I think he may have a valid point here.
    But as well as reducing coupling the term I'd use to make this
    argument is
    encapsulation.
    There's no way AFAIK to make MXML sub components invisible to
    higher level components. This can sometimes reveal things
    internally that you don't want messed with, within a custom
    component. If you have a custom component that only requires
    one property be set to configure it properly, you don't want
    to be revealing all these extra sub-components just because they
    had to have ids assigned to them inside the custom component.
    This may be a headache for backwards compatibility, for
    anyone who has assumed these components would be public by default,
    but a simple "scope='public'" attribute should fix that. But even
    having them public by default, and allowing us to set their scope
    to private would be helpful at times.

  • Resource Module Help for localization in custom mxml components

    HI again,
    Ok I have my resource set up to load at run time, working
    great.
    But I have mxml components should they not use the same
    loaded bundle, or should I make smaller component bundles and load
    them as well.
    Best Practice etc...
    Thanks in advance.

    If you want the components to be decoupled and reusable with
    ease, I vote for separate bundles.

  • Converting MXML Components to ActionScript Classes

    I'm in the process of converting most (if not all) of my MXML
    components to Action Script classes. I've found this is easy, and
    doesn't require a lot of extra code when extending a simple
    container or control. However, several of my MXML components have
    several nested containers and controls - i.e. a component that
    contains several Labels, a ComboBox, a TextInput, a Button, and a
    DataGrid, plus several other containers needed for layout. To code
    the layout of all these containers and controls using MXML, it uses
    about 16 lines of code. To code the layout in ActionScript, it
    takes about 50+ lines of code (see attached).
    I'm just wondering if there are any best practices for
    creating ActionScript classes that include several (or even A LOT
    OF) containers and controls. It's very easy to layout in MXML, and
    is more visibly pleasing to look at and understand, but I feel it
    is best practice to code components as ActionScript classes. I know
    I should be using MVC, but it's a little late to rewrite the entire
    application now.
    Any thoughts?

    I can't specifically speak to how to write layout code in
    ActionScript, but you can look at the generated code that Flex
    creates to get an idea of how Flex does it. When you compile an
    app, the Flex compiler takes your MXML input and converts it to
    ActionScript classes before compiling the entire set of classes
    into a SWF. Because of this, you can look at the interim
    ActionScript code.
    You do this by setting the keep-generated-actionscript
    compiler option to true and looking in the /generated directory.
    hth,
    matt horn
    flex docs

  • Using salesforce connector in multiple mxml components

    I am using Flex 2.0.1 and Salesforce as Database. My question
    is i am creating login method in each component and application. I
    want to use/pass salesforce connection from main application to all
    sub component, how can i achieve this to avoid login for each
    application/ component.
    example: In my project i created main.mxml application and 3
    mxml components in each component i am logining into the salesforce
    database to retrieve data from the database. i want to avoid
    creating multiple logins for the components instead of writing
    login for each mxml component i want login for the first time in
    main.mxml application and want to use the same connection in mxml
    components. Can anyone tell me how can i achieve this
    If you feel this is not sufficient information to solve this
    problem then let me know i will post another message with sample
    code.
    Thanks in advance.

    The solution I ended up using was just to reference the CSS file at the root MXML application. Then I could just use .styleName on the Menu component and voila, it worked.

  • Mxml components not compiled into swc?

    Hi, I am using Flash Builder(Flex 4) and i am having issues compiling mxml components into swc.
    My scenario:
    I created Flex Library project, added some mxml components and actionsript classes.
    I created separate Flex project and added swc file to project's library path.
    I can only import actionscript classes from my library.
    ActionScript classes are compiled and bundled in the swc as expected, but all mxml components are not compiled into the swc.
    Do you have the same issues compiling mxml components?
    I am using Flash Builder Version 4.0 (build 253292).

    My team occasionally sees issues with missing classes in a similar setup, although I can't confirm that it has been limited to MXML (and no one has been able to reliably reproduce).
    I suspect our problem is the "includeAllClasses" property in .flexLibProperties (Project->Properties->Flex Library Build Path->Classes->Include all classes from all source paths)--it seems to not reliably compile in newly added classes.  Our workaround right now is to instead click "Select classes to include in the library" and toggle our source directory every time classes are added, at least until we script our own build tasks.  Looking through Jira I see this is a common issue: https://bugs.adobe.com/jira/browse/FB-23514 (and a few others).
    Hope this helps,

  • Dynamically add custom MXML components in Actionscript

    As there's no constructor for custom MXML components, how to
    dynamically add it as a child using ActionScript?
    I'm looking for some alternative to avoid the need to rewrite
    the entire existent component in ActionScript just to add it this
    feature (a constructor). PopManager is not an alternative...
    Is there any way?
    The case/situation:
    I have a custom MXML component that needs to be dinamically
    added to a NativeWindow created using ActionScript.
    Thanks a lot!
    Vicente Junior
    Independent Web Developer
    http://teclandoalto.blogspot.com

    mxml classes get generated into AS classes with a default
    constructor.
    In fact, there is essentially no difference between an AS
    component and an mxml component, they can be used exactly the same
    way.
    Tracy

  • Architecting an Application With MXML Components

    I have an application that has gotten lengthy and I want to
    simplify it by architecting the Main Application with custom MXML
    Components. The application as it is currently architected works
    perfectly.
    Currently, the application consists of "Canvas" containers
    along Top and Left Side holding Navigation Buttons. The main
    (changing) sections of the application will consist of a
    "ViewStack" container holding a number of "Canvas" containers
    stacked on top of one another. The navigation buttons along the top
    and left side, when clicked, display in turn the content of each of
    the several stacked "Canvas" containers. Because of the number of
    stacked "Canvas" containers within the "ViewStack" and the content
    of each, the main Application source code has become very long and
    unwieldy, thus the need to use custom components for each of the
    "Canvas" containers in the "Stack" and referencing them in the main
    Application page.
    I have tried several times to get this to work and I need to
    clarify a couple of things.
    1) After setting up custom components for the several
    "Canvas" containers that are now in the "ViewStack" container, do I
    first need to set up a custom component for the "ViewStack"
    container with its own name space?
    2) If the answer to 1) above is Yes then do I then reference
    each of the custom components for the "Canvas" container with their
    own name space designation within the "ViewStack" reference within
    the main Application?
    In the event I am completely off base then I would appreciate
    any suggestions. If you wish I would be happy to email you the
    current application page.
    Thanks,
    Joe
    joe k

    Here is some code for an app built with components. You can
    see how the pieces talk to each other a bit.
    ------------------------- ViewStack1.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:comp="components.*"
    layout="vertical" width="100%" height="100%" >
    <comp:TopBar />
    <mx:HBox width="100%" height="100%">
    <comp:LeftBar />
    <mx:VBox width="100%" height="100%">
    <mx:ViewStack id="myViewStack" borderStyle="none"
    width="100%" height="100%">
    <mx:VBox id="home" width="100%">
    <comp:MainIntroText />
    <mx:HRule width="50%" height="3"
    strokeColor="0xCC3333"/>
    <comp:MainSecondaryText />
    <mx:HRule width="50%" height="3"
    strokeColor="0xCC3333"/>
    <comp:MainFinalText />
    </mx:VBox>
    <mx:VBox id="about" width="100%">
    <comp:About />
    </mx:VBox>
    <mx:VBox id="contact" width="100%">
    <comp:Contact />
    </mx:VBox>
    </mx:ViewStack>
    </mx:VBox>
    </mx:HBox>
    </mx:Application>
    ------------------------------- About.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:VBox width="65%">
    <mx:Text fontSize="14" width="100%" text="This page tells
    you about us." />
    </mx:VBox>
    </mx:HBox>
    ----------------------------------- Contact.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:VBox width="65%">
    <mx:Text fontSize="14" width="100%" text="This page tells
    you how to contact us." />
    </mx:VBox>
    </mx:HBox>
    ------------------- LeftBar.mxml -------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="200" height="100%">
    <mx:LinkButton label="Adobe Labs - Flex"
    click="navigateToURL(new URLRequest('
    http://labs.adobe.com/technologies/flex'),
    '_blank');"/>
    <mx:Spacer height="20"/>
    <mx:Label fontSize="16" text="Flex Blogs"/>
    <mx:LinkBar direction="vertical" width="90%"
    itemClick="navigateToURL(new URLRequest(event.item.data),
    '_blank');">
    <mx:Object label="Adobe Flex Team Blog" data="
    http://weblogs.macromedia.com/flexteam/"/>
    <mx:Object label="Flex Blog Aggregator" data="
    http://www.allyourflexarebelongtous.com/"/>
    <mx:Object label="Adobe Flex Blog Aggregator" data="
    http://weblogs.macromedia.com/mxna/index.cfm?query=byCategory&#38;categoryId=5&#38;categor yName=Flex"/>
    </mx:LinkBar>
    <mx:Spacer height="20"/>
    <mx:Label fontSize="16" text="Example Flex Apps"/>
    <mx:LinkBar direction="vertical" id="addlRscList"
    width="90%" itemClick="navigateToURL(new
    URLRequest(event.item.data), '_blank');">
    <mx:Object label="Adobe Flex Store" data="
    http://www.adobe.com/devnet/flex/samples/flex_store_v2/"/>
    <mx:Object label="Adobe Dashboard Example" data="
    http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html"/>
    <mx:Object label="Buzzword Word Processor" data="
    http://preview.getbuzzword.com/?s=true"/>
    <mx:Object label="Adobe Style Explorer" data="
    http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"/>
    <mx:Object label="Adobe Component Explorer" data="
    http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html"/>
    </mx:LinkBar>
    </mx:VBox>
    ----------------------- MainFinalText.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:Text width="100%" fontSize="12"
    text="Here is the final text I want to show you." />
    </mx:VBox>
    --------------------------- MainIntroText.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:Text width="100%" fontSize="12"
    text="Here is the main text I want to show you." />
    </mx:VBox>
    ----------------------- MainSecondaryText.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:Text width="100%" fontSize="12"
    text="Here is the secondary text I want to show you." />
    </mx:VBox>
    --------------- TopBar.mxml --------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%">
    <mx:Script>
    <![CDATA[
    private function goToViews(view:String):void {
    if(view == "home"){
    this.parentApplication.myViewStack.selectedChild=this.parentApplication.home;
    if(view == "about"){
    this.parentApplication.myViewStack.selectedChild=this.parentApplication.about;
    if(view == "contact"){
    this.parentApplication.myViewStack.selectedChild=this.parentApplication.contact;
    ]]>
    </mx:Script>
    <mx:LinkButton label="MySnazzyLogo" fontSize="20"
    click="goToViews('home');" />
    <mx:VBox width="100%">
    <mx:HBox width="100%">
    <mx:Spacer width="100%" />
    <mx:LinkBar fontSize="14"
    itemClick="goToViews(String(event.item.data));">
    <mx:Array>
    <mx:Object label="About Us" data="about"/>
    <mx:Object label="Contact Us" data="contact"/>
    </mx:Array>
    </mx:LinkBar>
    </mx:HBox>
    <mx:HBox width="100%">
    <mx:Spacer width="150" />
    <mx:Label fontSize="25" text="Here is Some Additional
    Text" />
    </mx:HBox>
    </mx:VBox>
    </mx:HBox>

  • Data between mxml components

    I have a question about data between mxml components.
    Product.mxml is the overview screen for the products and ProductDetail.mxml (it is a TitleWindow) the detail screen.
    In the Product I define a value object ProductVo with all the data. When I click a record in the overview and click the button 'change' (changeProduct function) then a popup window appears with all the data in it.
    Code in Product.mxml:
    [Bindable]
    public var myWin:ProductDatail;
    private function changeProduct():void {
      myWin = PopUpManager.createPopUp(this, ProductDetail, true) as ProductDetail;
      myWin["btnSave"].addEventListener("click", save);
    private function save(event:Event):void {
      productVo.productId = myWin.ti_productnr.text;
      productVo.name = myWin.ti_name.text;
      productVo.ean = myWin.ti_ean.text;
      ...some code to save the data in the db...
    Code in ProductDetail.mxml:
    [Bindable]
    public var productDetailVo:ProductVo;
        <mx:Form>
            <mx:FormItem label="Productnr" required="true">
                <mx:TextInput id="ti_productnr" text="{productDetailVo.productId}" width="60"/>
            </mx:FormItem>
            <mx:FormItem label="Naam" required="true">
                <mx:TextInput id="ti_name" text="{productDetailVo.name}" width="200"/>
            </mx:FormItem>
            <mx:FormItem label="Ean">
                <mx:TextInput id="ti_ean" text="{productDetailVo.ean}" width="100"/>
            </mx:FormItem>
            <mx:FormItem direction="horizontal">
                <mx:Button id="btnSave" label="Save"/>
            </mx:FormItem>
        </mx:Form>
    So my question: the save function in Product.mxml, is it possible to do this in a easier way instead of linking all the data from the form into the value object? Something like productVo = myWin.productDetailVo, but that does not work.

    I just looked at the parsley framework and saw this code:
    private function save():void
    contact.firstName = firstName.text;
    contact.lastName = lastName.text;
    contact.email = email.text;
    service.save(contact);
    So, it is doing the same thing I'm doing.
    I'm using Spring and hibernate on the server level, it is my own framework.

  • Anyway To Make Video Brighter like in iGlasses?

    Anyway to make the video brighter like in iGlasses?

    Any Other way ?
    Add more light.
    7:50 PM Sunday; November 18, 2007

  • Is there anyway to make a audio file copy of a song for my computer?

    Is there anyway to make an audio file copy of a song from iTunes for my computer?

    Yes.
    Type "Mp3" or "convert to MP3" or similar into the help feature of itunes.

  • Is There Anyway To Make A Composistion Without A Set Time?

    Ok, so is there anyway to make a composistion that doesn't have a set time? Oh yeah...and, whenever i look at the time bar at the bottom it's coming up in 1f - 2f -3f - 4f ...So on, is there anyway to change this to like 5s - 10s - 15s   Like it was before? Thank you.
    (CS6)

    You change the length of a composition with the composition settings. There is no automatic way to expand a comp. If you need to add more time then press Ctrl/Cmnd + K or go to Composition>Composition Settings and change the time.
    In the timeline, you can see more or less of the composition by adjusting the area of view using the icons at the bottom left side of the layer view.

  • Bought an album off iTunes and two songs from the album will not download. Is there anyway to make them force load or anything along those lines?

    Bought an album off iTunes and two songs from the album will not download. Is there anyway to make them force load or anything along those lines? The Album is Sunshower-EP by UME and the songs are The Conductor and The Means.

    Hey ChandlerAdaway!
    I have an article here that can provide you some guidance for this issue. First, you will want to check for the songs in your past purchases list for your account, if you haven't already:
    Downloading past purchases from the iTunes Store, App Store, and iBooks Store
    http://support.apple.com/kb/HT2519
    If the songs cannot be found there, you will want to report an issue with your download by following the directions in this article:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • How to make this object static ?

    Hi,
    I have such an InputStream :
    InputStream kombinace = getClass().getResourceAsStream("/kombinace.txt");is there anyway how to make it static ?
    thanks for help

    BigDaddyLoveHandles wrote:
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    InputStream in = loader.getResourceAsStream(path);
    I'm not sure that this is guaranteed to work since the class loader you have obtained from the current thread may not be the one that holds the resource.

  • Passing VARs between MXML Application and MXML components!

    Hi,
    I'm trying to pass a variable between the MXML Application and the MXML Component with ValueObjects.
    But when i call the variable on the MXML Component it is null!
    ValueObject Class Code:
    package valueObjects
        [Bindable]   
        public class MyGlobalVars
            public var NomeGaleria: String;
            public function MyGlobalVars()
    MXML Application Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  xmlns:comp="components.*" layout="vertical" height="100%" width="100%" >
    <mx:Script>
        <![CDATA[
            import valueObjects.MyGlobalVars;
            import mx.managers.PopUpManager;
            import mx.core.Container;
            [Bindable]
            public var nomeGaleria:MyGlobalVars;
            private function AbreGaleria():void{
                  nomeGaleria=new MyGlobalVars();
                nomeGaleria.NomeGaleria = "Moda";
                PopUpManager.addPopUp(new galeriaImagens(),this,true);
        ]]>
    </mx:Script>
    <mx:Panel height="673" width="839" verticalAlign="middle" borderStyle="none" layout="absolute">
        <mx:Canvas id="SMGaleria" width="815" height="30" x="2" y="98"">
            <mx:LinkButton x="474" y="5" label="moda" click="AbreGaleria()"/>   
         </mx:Canvas>
        <mx:ViewStack id="content" height="440" width="815" borderStyle="none" x="2" y="128">
            <comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria}"/>
        </mx:ViewStack>
    </mx:Panel>
    </mx:Application>
    MXML Component Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow  xmlns:mx="http://www.adobe.com/2006/mxml"
        showCloseButton="true" creationComplete="CenterMe()" backgroundColor="#000000" xmlns:components="components.*" >
    <mx:Script>
        <![CDATA[
            import valueObjects.MyGlobalVars;
            import mx.controls.Alert;
            [Bindable]
            public var strGaleria:String;
            private function CenterMe(): void{
                 Alert.show(strGaleria);
        ]]>
    </mx:Script>
    </mx:TitleWindow>
    On the MXML component the value of strGaleria is null! It would not have to be: Moda??

    You may need to change your code as follows:
    <comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria.NomeGaleria}"/>
    Previously you had set strGaleria to the value of the object, not the string within the object.
    But I think you will still have a problem because function AbreGaleria will not be called until the user clicks the link button, and only then will NomeGaleria have a value, so I would set a default value as follows, otherwise at app launch it will be null:
    public var NomeGaleria: String = "";
    or  if that does not work
    public var NomeGaleria: String = " ";
    Another possible problem is that you are calling this code at the component creationComplete, but the LinkButton has not been clicked yet, so the value object string value has not been set, so the alert will not display anything:
    private function CenterMe():void{
        Alert.show(strGaleria);
    I think you need to reorganize some things here.
    If this post answers your question or helps, please mark it as such.

Maybe you are looking for

  • How can I enter special characters in a text title?

    Hello to all! Have been trying to get in a special character [the tick mark] onto a text title on my current project. Had gone to the special character option under EDIT menu, and added the desired special character to the 'favourite' list, but after

  • Problems with PC Suite 7.1.30.9 USB connection

    Ok, So I've been having trouble the last 2 weeks or so getting this to work. I Correctly installed the PC suite 7.1.30.9 on my PC (windows vista home premium 32) some time back. It used to work well with my old N95 8GB, but after I got the N97, for t

  • REPLICATION BETWEEN ORACLE 10g and postgresql/MySQL/MSSQL SERVER??

    Hi Friends. I want to know if there are a manner of replication between ORACLE and (postgresql or mysql or mssqlserver). Please, my email is [email protected] Thanks Manuel

  • Dreamweaver log in issues

    Is there anyone experiencing log in issues to B.C. through Dreamweaver? My log in issue started about a few hours ago. I can log in directly to B.C., but when I try to log in using the same name and password that I've always used, I can't log in.

  • FYI don't be afraid

    Just a FYI, There are many ipods that are now off warranty or have damage and are off warranty because of dents or heavy scratches. To those I write, hang in there. There are so many things that can be done by you to repair your own nano if you have