Initializing Custom MXML component

Hello,
I am new to flex and the one thing I can't seem to get a handle on is using custom mxml components. The whole not being able to use a constructor to pass data through was a tough thing to adjust to so for the most part I've been writing my own AS classes for display purposes that extend layout containers like VBox and such. This is getting cumbersome and I would really like to use MXML to save some time when writing display classes. For the most part I'm trying to use custom mxml components this way: I put the labels and other controls and then want data to display as text from the calling class. However, when I try to set the text it says that the control I am trying to set hasn't been initialized yet. My workaround is something like this.
var data1:String = "Something";
var customComp:CustomMXMLComponent = new CustomMXMLComponent();
customComp.initialize();
customComp.someControl = data1;
Now why wouldn't someControl on the custom component be initialized when the actual component is initialized? Is there something I can change in the mxml component so that I don't always have to call .initialize() after creating an instance of the custom component?
Thanks!

.  The "initialize" stuff you had was more concerned with the lifecycle of the component.  We don't want to do that , but it is something you should learn about. I think the answer to your problem is to create Bindable variables in your mxml class,  then set those parameters.
Observe
<Panel>
  <Button label="{buttonLabel1}" >
  <Button label="{buttonLabel2}">
  <Label label = {labelLabel}>
  <Script>
     [Bindable]  public var buttonLabel1:String;
     [Bindable]  public var buttonLabel2:String;
     [Bindable]  public var labelLabel:String;
   </Script>
</Panel>
Meanwhile , in another class ...
var customComp:CustomMXMLComponent = new CustomMXMLComponent();
customComp.buttonLabel1 = "Ubuntu";
customComp.buttonLabel2 = "Rocks";
customComp.labelLabel = "My Socks";

Similar Messages

  • Add change event to a custom MXML component

    I am building an MXML project in Flash Builder 4.5
    I have a custom MXML component that contains a TextInput field. I want the custom component to have a change event that triggers a function in the main application.
    I created a test project to try and solve this.  At the moment, it appears to trigger an event once and then stops.  Please take a look and let me know where I am going wrong. Many thanks.
    customComponent.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
               width="40" height="20">
        <mx:Script>
        <![CDATA[
            [Bindable]
            public var value:Number;
            protected function inputBox_clickHandler(event:KeyboardEvent):void
                if (event.keyCode == 38 ) {
                    keyUp();
                if (event.keyCode == 40 ) {
                    keyDown();
            protected function keyUp():void
                value = value++;
                dispatchEvent(new Event('change'))
            protected function keyDown():void
                value = value--;
                dispatchEvent(new Event('change'))
        ]]>
    </mx:Script>
    <mx:Metadata>
        [Event(name="change", type="flash.events.Event")]
    </mx:Metadata>
    <mx:TextInput id="inputBox" x="0" y="0" width="40" height="20"
                  text="{value}"
                  keyDown="inputBox_clickHandler(event)"
                  change="dispatchEvent(new Event('change'))"
                  />
    </mx:Canvas>
    main.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:CustomComponents="CustomComponents.*"
                minWidth="955" minHeight="600" layout="absolute">
    <mx:Script>
        <![CDATA[
            private function changeTestLabel():void
                testLabel.text = String(myComponent.value);
        ]]>
    </mx:Script>
    <CustomComponents:customComponent x="180" y="183"
        id="myComponent" value="0"
        change="changeTestLabel()">
    </CustomComponents:customComponent>
    <mx:Label id="testLabel" x="165" y="206" text="Test label"/>
    </mx:Application>

    I have found the solution to this...
    The clue was that it worked the first time a change was made, changing the value to the default '0'.
    The problem was that the var value is type Number and the inputBox.text is type String.
    I therefore added the following function:
      protected function textChange():void
       value = Number(inputBox.text);
       dispatchEvent(new Event('change'))
    I also changed the  change="dispatchEvent(new Event('change'))"  property to
       valueCommit="textChange()"
    ... and that fixed it..
    Thanks to all those who took the trouble to look at this

  • Custom mxml component extending another mxml component

    I want to create a custom mxml component that extends another mxml component. Bacially I want structure like Group -> BaseMXMLComponent -> MyMXMLComponent. I understand that it used to be the case that trying to add child component to MyMXMLComponent would throw "Error: Multiple sets of visual children have been specified for this component (base component definition and derived component definition)." error. But i've been reading few articles that says this has been fixed in Flex 4.
    My question is.. is it an actually fixed, documented, and supported behavior of Flex 4? or just an undefined behavior that appears to be "fixed" but can change on future update?

    I dont know what is happening inside datagrid.But If
    you want to maintain a single instance you could use singleton design pattern
    read about it
    http://en.wikipedia.org/wiki/Singleton_pattern
        public class Singleton
            private static var instance:Singleton= new Singleton();
            public var userdata:*; // keep user object
            public function Singleton()
                if (instance != null) { throw new Error('Cannot create a new instance.  Must use Singleton.getInstance().') }
            public static function getInstance():Singleton
                return instance;

  • 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

  • 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

  • Capture event from mxml component

    I have an accordian control in my main mxml application. Each
    item in the control is a custom mxml component that I created that
    consists of a label and some text. When the label is clicked, I
    need to fire off a message to the containing application with a
    string value. I'm not sure how to do this. Here's what I have right
    now. I'm not sure if I'm going down the right track but if I am,
    how do I pass the string argument with the event and then capture
    this event and the argument in the main application?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="200">
    <mx:Script>
    <![CDATA[
    private var _title:String = "";
    private var _desc:String = "";
    [Inspectable(defaultValue=true)]
    public function set Title(title:String):void{
    _title = title;
    public function set Description(desc:String):void{
    _desc = desc;
    private function SetMovie(url:String):void{
    dispatchEvent(new Event("MovieTitle"));
    [Bindable(event="MovieTitle")]
    ]]>
    </mx:Script>
    <mx:VBox>
    <mx:Label id="lblTitle" text="{_title}" width="190"
    click="SetMovie('testmovie.flv');/>
    <mx:Text id="txtDescription" text="{_desc}"
    width="190"/>
    </mx:VBox>
    </mx:Canvas>

    You have several issues, and several options here. First, a
    custom event can pass any data you want, and is not very hard to
    create.
    However, there is a still easier way. All of the Event
    objects have a "target" and "currentTarget" property which give you
    a reference to the object that dispatched the event.
    So, in your component, implement a public property, say like
    this:
    public function get Title():String{
    return _title;
    then in a handler function you can do:
    private function onMovieTitle(event:Event):void {
    var sMovieTitle:String = event.currentTarget.Title; //watch
    out for reserved words, though
    There are two ways to listen for an event. One easy way is to
    use a bubbling event. Some folks advise against bubbling event
    because of potential event name collisions, but this may not be a
    concern for you. It has not yet concerned me enough to make me
    avoid using bubbling.
    The other way is to declare handler on the component itself.
    Also, if you use a metadata tag, you can assign the handler on the
    mxml tag, instead of using addEventListener():
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="200">
    <mx:Metadata>
    [Event(name="MovieTitle", type="flash.events.Event")]
    </mx:Metadata>
    <mx:Script>
    Then, in you main app:
    <myComp id="mc1" ... MovieTitle="onMovieTitle" ...
    Without the metadata, you would do
    mc1.addEventListener("MovieTitle",onMovieTitle)
    Using a bubbling event:
    change the dispatchEvent to this:
    dispatchEvent(new Event("MovieTitle",true)); //the 'true'
    makes it bubble
    Then, in the main app, listen ON the main app(this):
    this.addEventListener("MovieTitle",onMovieTitle);
    Tracy

  • Convert mxml component to an AS class?

    I just made a custom MXML component ("ProjectImage.mxml") and
    expected to be able to instantiate instances of it from AS scripts
    like so:
    var newImage:ProjectImage = new ProjectImage();
    (this is within an <mx:Script> block in Flex, and I've
    explicitly imported the component.)
    but apparently this doesn't work (got "Access of possibly
    undefined property source through a reference with static type
    customComp.views:ProjectImage.") Is there any easy way to convert
    my mxml component to an AS class without writing it from scratch?
    Flex does this anyway at runtime, yes? So it seems like it should
    be able to do it on command....
    Any help would be appreciated. Thanks!

    Ok, I realized I was making another mistake and that the mxml
    component works just fine being instantiated from AS. It'd still be
    nice to know how to get a look at AS classes generated from custom
    components though...

  • Very simple library with one MXML component ERROR

    <?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"
                         mouseDown="FlexGlobals.topLevelApplication.nativeWindow.startMove()"
                         width="350" height="42" top="0" left="0" right="0">
              <s:states>
                        <mx:State name="maxed"/>
                        <mx:State name="restored"/>
              </s:states>
              <fx:Script>
                        <![CDATA[
                                  import flash.events.MouseEvent;
                                  import mx.core.FlexGlobals;
                                  private var maxed:Boolean = false;
                                  private function restore(e:MouseEvent):void{
                                            if (maxed){
                                                      FlexGlobals.topLevelApplication.restore();
                                                      this.currentState = "restored";
                                                      maxed = false;
                                            }else{
                                                      FlexGlobals.topLevelApplication.maximize();
                                                      this.currentState = "maxed";
                                                      maxed = true;
                                  public function Maximize() : void
                                            if (this.maxed)
                                                      FlexGlobals.topLevelApplication.restore();
                                                      this.currentState = "restored";
                                                      this.maxed = false;
                                            else
                                                      FlexGlobals.topLevelApplication.maximize();
                                                      this.currentState = "maxed";
                                                      this.maxed = true;
                                            return;
                                  }// end function
                                  public function get Maximized():Boolean{
                                            return this.maxed;
                        ]]>
              </fx:Script>
              <s:Rect left="0" top="0" bottom="0" right="0">
                        <s:fill>
                                  <s:SolidColor color="#FFFFFF"/>
                        </s:fill>
              </s:Rect>
              <s:Image x="5" y="-4" source="assets/colibright_title.png" left="5"/>
              <s:Button y="10" width="32" height="32" click="FlexGlobals.topLevelApplication.minimize();" icon="assets/icons/minimize.png" y.restored="5" y.maxed="5" right.restored="74" right.maxed="74"/>
              <s:Button width="32" height="32" click="restore(event)" y="5" icon="assets/icons/restore.png" includeIn="maxed" right="39"/>
              <s:Button y="5"  click="restore(event)"  includeIn="restored" width="32" height="32" icon="assets/icons/maximize.png" right="39"/>
              <s:Button y="10" width="32" height="32" click="FlexGlobals.topLevelApplication.close();" icon="assets/icons/close.png" y.restored="5" y.maxed="5" right.restored="5" right.maxed="5"/>
    </s:Group>
    In my main application when i try to load the SWF and use the Custom MXML Component i get this error
    [SWF] C:\Users\dude\Adobe Flash Builder 4.7\Colibr8\bin-debug\extensions\00 - WindowControlUIPlugin.swf - 8,287 bytes after decompression
    VerifyError: Error #1014: Class spark.components::Group could not be found.
    private function launchPluginsInspection():void{
                                  plLoader = new Loader();
                                  plLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPluginLoaded);
                                  var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
                                  context.allowLoadBytesCodeExecution = true;
                                  context.allowCodeImport = true;
                                  var appFolder:File = File.applicationDirectory;
                                  var extensionsFolder:File = new File(appFolder.nativePath + "/extensions/");
                                  if (extensionsFolder.isDirectory){
                                            var files:Array = extensionsFolder.getDirectoryListing();
                                            for each(var file:File in files){
                                                      if (file.extension == "swf")
                                                                plLoader.load(new URLRequest(file.nativePath), context);
    Why is this happening?

    Can you try giving permissions for the player to access your swf file by adding this
    Security.allowDomain( '<Location of the swf file>' );
    or  
    System.security.allowDomain( '<location of the swf file>' );
    Thanks,
    Sudhir

  • Custom AS3 Component / Event Definition for MXML Tag

    Custom AS3 Component / Event Definition for MXML Tag
    Exposing custom event in custom MXML tag.
    I have made an AS3 custom component named,
    'CustomListComponent'.
    Is a list type component extending UIComponent.
    When an item is clicked (selected) I generate a custom event
    named, 'selChange'
    I want the user to be able to use this tag, define a handler
    on the MXML tag.
    I tried using metadata like [Event("selChange")] in the
    component AS3 file with no luck.
    Any help / examples to expose a custom event from an AS3
    custom component to the MXML tag for the end user/developer would
    help significantly.
    Anyone? Thank you.

    Well, That did not take long.
    My mistake, Typo type.
    [Event(nane="selChange", type="flash.events.Event")]
    That is: naNe not naMe :(
    Thank you all for your time and responses.
    I WILL check my code more closely next time I post a
    question.
    P.S.: @VarioPegged : My code is big and not needed now. If
    you would like it anyway just message me. TY

  • Loading an "MXML Component" at run-time creates a null object.

    Hello!
    I have a simple Flex 3 project with an MXML application file (the parent) and an MXML component file (the child).
    At run-time I create childs of this component, and I add it to the stage using a simple "this.addChild()" call.
    Now, besides that, in the creation loop, after every
      newChild = new mcComp();
    I want to setup a few more custom parameters which belongs to this class. For example, now I want to set a label's text, this label is at the child.
    The issue is that the label isn't created until I exit the creation function, and actually, until my code returns control to the Flash Player.
    See my problem here?
    With custom classes which resides at .AS files, when I instantiate them with the "new" operator, they run their constructure's code and eveything is fine.
    But, when I do the same with those MXML components (which by the way are based over the Canvas class), their constructure do not execute and actually no other child of them is created.
    Can anyone please advise? I must be missing some keyword here.. hopefully.

    Hi Natasha thanks,
    The issue is that the creationComplete event doesn't dispatch even when I addChild() the object.
    var child:mcChild = null;
    for(var i:int; i < 3; i++)
         child = new mcChild();
         // setting some properties, labels' text etc'
         this.addChild(child);
    Try this and you'll see - the event doesn't dispatch until you got out of the code flow.
    Anyway after looking at Flex's documentation I solved it differently;
    After the addChild() call the child receives an "initialize" event. After that I could modify my label.
    Thank you though!

  • Custom Pipeline Component stopped changing input filename

    Hi
    In my project, I have a custom pipeline component to change the input file name. I use it in the receive pipeline decode stage. It was working initially when I had only a receive pipeline and custom pipeline component in my solution. later I introduced
    two schemas, an orchestration, map and a send pipeline. The rename is not working anymore. Please help.
    receive adapter: FILE
    send adapter: FTP
    Custom pipeline component: (File Name Setter)
    Receive pipeline:
      decode: custom pipeline component to rename the filename
      disassemble: flatfile disassembler conecting to a document schema
    Map:
      Schema 1 to Schema 2 (transforms from Windows to Unix format)
    Orchestration:
      receive message
      transform using map above
      send message
      Exception Handler
    Send pipeline:
      FlatFile assembler
    manibest

    May be its not working now, because in the orchestration which you have added,
     you’re constructing a new message from the received message and the context properties from the Received message is not copied across to the newly constructed message. So when you use “%SourceFileName%” macro in the send port,
    the ReceivedFileName context property is missing in the newly constructed message which is sent out.
    So in your Orchestration, while constructing (in MessageAssignment shape) the outbound message from the Received message, copy the context property of the Received message to the newly constructed message. Something like this
    //This line copies all the context properties from received message to the outputted message
    msgOutputted (*)= msgReceived(*)
    //or
    //This line just copies the receive file name context property from received message to the outputted message
    msgOutputted (FILE.ReceivedFileName)= msgReceived (FILE.ReceivedFileName).
    If you’re not using the Orchestration or constructing the new message (even in map), then just add the schemas/orchestration or any pipeline would not affect the ReceiveFileName code. May be in this case, debug the pipeline and also check whether the outputted
    message has ReceivedFileName in its context property.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • How does one define a default style for a custom Flex component?

    How does one define a default style for a custom Flex component?
    hello
    I created a new set of Flex component library slib.swc (Flex 4.5). Would also like to have a default style. defaults.css file, making it the default style of the component library.
    Like flex the builder install directory of sdks \ 4.5.0 \ frameworks out \ libs directory has a spark.swc file, open with Winrar will see defaults.css this file. Defaults.css file defines the default style of the flex spark components.
    How can it be achieved?
    As follows
    slib.swc contains a CLabelEx components, and a defaults.css file
    defaults.css source file as follows:
    @ namespace s "library :/ / ns.adobe.com / flex / spark";
    @ namespace mx "library :/ / ns.adobe.com / flex / mx";
    @ namespace cn "http://os.slib.cn";
    cn | CLabelEx
            styBackgroundAlpha: 1;
            styBackgroundColor: # 569CC0;
            styBorderAlpha: 1;
            styBorderColor: # 569CC0;
            styBorderWeight: 1;
            styCornerRadius: 3;
    In slib.swc the application MyLabel.mxml of the source file as follows:
    <? xml version = "1.0" encoding = "utf-8"?>
    <s: Application, the xmlns: fx = "http://ns.adobe.com/mxml/2009
                               xmlns: s = "library :/ / ns.adobe.com / flex / spark"
                               xmlns: mx = "library :/ / ns.adobe.com / flex / mx"
                               xmlns: cn = "http://os.slib.cn
                               the minWidth = "955" The minHeight = "600">
            <fxeclarations>
            </ fxeclarations>
            <cn:CLabelEx x="67" y="112"/>
    </ s: Application>
    I hope CLabelEx default use cn | CLabelEx, style to display its appearance.
    I refer to above approach, but failed to achieve. Can you please re-Detailed
    Thanks!

    dj is right. Any Folder can be a picture folder.
    Create a root level folder and add it to your Pictures Library in Windows.  It will show up with all the scattered pictures from other programs. It can even be a different dirve if you like.  You  can even specify one to be the default save location for pictures in this dialog.
    Navigate to Pictures in your Libraries in Windows Explorer Right Click and select Properties.
    Message was edited by: Rikk Flohr forgot the instructions...

  • Loading MXML Component Dynamically

    Hi all,
    I am new to Flex and was trying out small things . I created
    a MXML Application and also MXML components.
    I tried loading MXML component to application using xmlns and
    it worked fine.(
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" backgroundColor="#ffffff" xmlns:mi="com.*">
    <mi:base1 id="base1" />
    <mi:base2 id="base2" />
    This method is ok if we are loading 3-4 components .
    but , if i have to load a mxml component dynamically how do I
    do it?
    for example ,if base1 and base2 are two components and i want
    to load them based on some event performed.
    I have tried the method which uses ViewStack and code
    myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode))
    ,where each child will have one component declared or initialized.
    Following this method is not a feasible when we have hundred
    of components to be loaded.
    Can anyone help me on this??

    "srirama.83" <[email protected]> wrote in
    message
    news:gpkoui$g3u$[email protected]..
    > Hi all,
    > I am new to Flex and was trying out small things . I
    created a MXML
    > Application and also MXML components.
    > I tried loading MXML component to application using
    xmlns and it worked
    > fine.(
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > layout="absolute"
    > backgroundColor="#ffffff" xmlns:mi="com.*">
    > <mi:base1 id="base1" />
    > <mi:base2 id="base2" />
    > )
    > This method is ok if we are loading 3-4 components .
    > but , if i have to load a mxml component dynamically how
    do I do it?
    > for example ,if base1 and base2 are two components and i
    want to load them
    > based on some event performed.
    >
    > I have tried the method which uses ViewStack and code
    >
    myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode))
    > ,where each child will have one component declared or
    initialized.
    >
    > Following this method is not a feasible when we have
    hundred of components
    > to
    > be loaded.
    > Can anyone help me on this??
    >
    >
    http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf
    Q4

  • Steps to create a custom Window component?

    What steps do I need to take to create a custom Window component? My approach now results in the component being uneditable in design view. What I do is simply select "New > MXML component", base it on spark.components.Window and supply a filename. I tried with a Panel component and that works fine.

    Hi,
    Step by Step creation of SAP Payroll Funcitons:
    1) Follow the menu path
       Human Resources>>Time Management>>Administration>>Tools>>Funtions/Operations
       or transaction PE04. Enter a four digit name for e.g ZIABC, and press the create
       button, enter the description. On creation the system proposes the name of
       the routine use it, or enter a name of your choice by selecting the option 'Self-defined'.
    2) During the execution of payroll some tables are filled with wage types and there amounts
       to make these tables available to your routine enter the name of the table for e.g (RT or
       CRT) in the input parameters, and to make the changes done to the data in the tables
       avaiable to the payroll enter the name of the table in the Output parameters as well.
       Input Parameters
       Ctry                                         Num     Object Name
       99                                           1       RT
       99                                           2       CRT
      and same shall be done in the Output Paramters if required.
    3) Create an include in the program PCBURZ990 (using Transaction:
    SE38), in which create a subroutine with the name supplied by SAP or the
    name selected by you during Funtion creation,
    in our case, it is FUZIABC.
    Note: The program PCBURZ990 is in SAP Namespace, so an Access Key
    will be required before you can proceed. But it will not be overwritten during any upgrade.
    *Example of the subroutine
       FORM FUZIABC.
    *enter the code
       ENDFORM.
    4) After this activate the program the Funtion and add it in the schema used for payroll processing.
    Reward points if helpful.
    Regards,
    Manoj.

  • Mxml component application

    Hi all,
    I am converting a asp.net website to Flex, I have five web pages which I designed as Five mxml components have buttons, grid, combos, text boxes etc.
    my question is how do I move between these pages they are distinct in there looks and functionality. I read a lot about view states and I am confused whether view states will solve my issue.
    Please tell me how do we handle this usually in flex applications.

    Hi,
    Flex 4 or Flex 3 the answer remains the same, I have a state for each form then I place a container, be it a group a canvas or a panel, in each state to show how states work, the following is in flex 3
    The Application
    ============
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" currentState="form1" xmlns:ns1="*">
    <mx:states>
    <mx:State name="form1">
    <mx:AddChild position="lastChild">
    <ns1:form1 horizontalCenter="0" verticalCenter="0">
    </ns1:form1>
    </mx:AddChild>
    </mx:State>
    <mx:State name="form2">
    <mx:AddChild position="lastChild">
    <ns1:form2 horizontalCenter="0" verticalCenter="0">
    </ns1:form2>
    </mx:AddChild>
    </mx:State>
    <mx:State name="form3">
    <mx:AddChild position="lastChild">
    <ns1:form3 horizontalCenter="0" verticalCenter="0">
    </ns1:form3>
    </mx:AddChild>
    </mx:State>
    </mx:states>
    <mx:Button label="Form 1" click="currentState='form1'" top="10" horizontalCenter="-150"/>
    <mx:Button label="Form 2" click="currentState='form2'" top="10" horizontalCenter="0"/>
    <mx:Button label="Form 3" click="currentState='form3'" top="10" horizontalCenter="150"/>
    </mx:Application>
    The Mxml Component Container (which is exactly what you said you had)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" title="First Form">
    </mx:Panel>
    You can navigate through your 'pages' however you want to, the first example I offered is pure flex the above code is pure flex only using the antiquated sdk which I would advise against for 'new' projects, flex 3 sdk maybe used in flashbuilder but I would only go to this for legacy purposes using the flex 4 sdk is by far the better option.
    I try to help where I can, there is no reward for doing this, but I did answer your initial question about states, I hope you get to understand flex a little better with time.
    David.

Maybe you are looking for

  • Only 1 Mac at a time can connect to Comcast via Snow ABS ?

    I have 2 Macs, a new MacBookPro Core 2 Duo running 10.4.8 and the other an iMac G4 flat panel (swivel) running 10.3.9. The ABS is the old snow model. Separately, each computer can be easily connected to the Comcast network via the ABS. But when I try

  • Error While creating User using userservcenter Webservice

    Hi All, I have generated the java client stub from the um_workflowSaveCreateProfile.wsdl file successfully and I have developed one client code to call the web service to create user in Oracle Internet Directory. I am invoking one workflow for creati

  • Problem in resetting the Page numbers

    Hi, I am using to print PO report using XML publisher. The layout that is needed is Header ---- It cointains page number x of y ,po number,po creation date,and other details. Body ---- It cointains po lines and po headers data. end body After the bod

  • Losing messages from queue

    (OT: i can't figure out these newsgroups too well. i tried using the public newsgroups from my isp usenet server, but they don't seem to get posted here...)           we have a mdb which acts like a pass through to a stateless session bean. (command

  • Mac mini (late 2012) when booting shows flashing question mark folder

    Hello, so after installing software update to my mac mini *late 2012* it froze for few mins so then I rebooted it and now it wont boot it shows flashing question mark folder, I can't use the boot buttons because it asks me for a frimware password and