Flex viewstack question

My default creationpolicy for my viewstack causes each child
component to be created only when a user navigates to it. This is
good for performance. I was wondering if there was a way to have it
recreate itself each time a user comes back to that particular
view. Also is there a way to explicitly call a recreate on a
particular child in a viewstack?
Thanks

Let's say the child component in question displays the
information about a house for sale: the price, square footage,
number of bedrooms, etc. In this component you would have Label
components and either Text or TextInput fields to hold the values:
Price: $175,000
In Flex you could code this as: <mx:Label text="Price"
/> <mx:Text text="{price}" />
Here, the price is a variable in the component which is bound
to the Text component using the Flex binding notation of { and }.
You declare price (and all of the other values) using:
[Bindable] public var price:Number;
[Bindable] public var bedrooms:Number;
// etc.
To repopulate this component with new data you just set the
variables:
<mx:ViewStack ..>
....<AgentInfo id="agentInfo" ../.>
....<RealEstateInfo id="realInfo" .../ >
</mx:ViewStack>
realInfo.price = 200000; or realInfo.price =
dataFromServer.price;
You set up some variables in the component to hold your data
and bind those variables to the UI controls. Whenever you change
the variables the values on the screen change.
The beauty of data binding is that you don't need to have the
component created - the ViewStack by default only creates the
contents of its first child. If this realInfo child is the second
or third, the controls within it won't be created until the user
visits it. But the variables are created so you can change them and
data binding will take care of the rest.
There is a simpler way to do the binding. Every component has
a "data" property. Let's say you have an ActionScript class that
represents the information about a house (House class). Rather than
doing:
realInfo.price = house.price;
realInfo.bedrooms = house.bedrooms;
etc.
You can do:
realInfo.data = house;
and then instead of <mx:Text text="{price}" /> in the
component, do <mx:Text text="{data.price}" />

Similar Messages

  • Flex language questions should go in the General Discussion Forum

    This forum is intended for Flex Builder questions.
    Of course you can post wherever you like, but if you want
    help, go where the helpers are.
    Tracy

    can you define what goes where then?
    General discussion sounds like thoughts, comments, hopes and
    wishes.
    Builder 2, (meaning Flex Builder 2?), seems to be the only
    area for other Flex 2 questions.
    I don't mean to be wise here, but I personally don't
    understand what a "builder 2" question is if not those that deal
    with flex 2, such as those posted here. I want to post my questions
    where they should be so that I might find help, so maybe the forum
    labelling should be re-considered or better defined.

  • Simple Flex Chart question - Plot Chart labels

    I'm playing around with displaying data from WDA as charts in Flex 3.
    I'm able to bind my internal table, which has 3 fields, to the plot chart.
    The table looks like this
    ext_id      type string    " bound to prjname in Flex
    cost         type string    " bound to prjcost in Flex
    benefit     type string    " bound to prjbenefit in Flex
    These are all bound to my island's DataSource.
    I have bound these in Flex and the Cost and Benefits are showing up as points on my chart. However, I can't seem to get the Project Name to display on the plot points. All I see when I mouse over the point is EXT_ID, and the values for cost and benefits.
    The cost/benefit values are coming across correctly, just not the project name (ext_id) value. any ideas?
    here's the Flex code for the chart
         [Bindable]
         public var dataSource:ArrayCollection;
         [Bindable]
         public var prjcost:String;
         [Bindable]
         public var prjbenefit:String;
         [Bindable]
         public var prjname:String;.
        <mx:PlotChart id="plotchart1" dataProvider="{dataSource}" showDataTips="true">
           <mx:series>
                <mx:PlotSeries displayName="{prjname}" yField="{prjcost}" xField="{prjbenefit}" dataProvider="/>
            </mx:series>
        </mx:PlotChart>

    This is really a Flex question not an Islands specific one.  I don't think the displayName properity is what you want to use here.  This is the name for the entire series as it will be displayed in the legend. I think what you want is a dataTip.  You register a callback for the dataTip rendering and then fill the custom dataTip quick info.
    This is an example from a bar chart, but the theory is the same:
    <mx:BarChart id="barChart" dataTipFunction="dtFunc" xmlns:mx="http://www.adobe.com/2006/mxml" type="clustered" width="100%" showDataTips="true" height="100%">
         <mx:verticalAxis>
              <mx:CategoryAxis categoryField="{SalesOrd}" dataProvider="{dataSource}" />
         </mx:verticalAxis>
         <mx:series>
              <mx:BarSeries id="bsGross" xField="{grossAmt}" displayName="Gross Amount" dataProvider="{dataSource}" fill="{otdFill}" showDataEffect="{slideIn}"  />
              <mx:BarSeries id="bsNet" xField="{netAmt}" displayName="Net Amount" dataProvider="{dataSource}" fill="{rtyFill}" showDataEffect="{zoomIn}"  />          
         </mx:series>
    </mx:BarChart>
    private function dtFunc(hd:HitData):String {
                  switch(BarSeries(hd.element).id){
                       case "bsGross":
                             return "Sales Order #: " +  hd.item.SO_ID + "\n" + FlashIsland.formatNumber(hd.item.TTL_GROSS_AMOUNT) + " " + hd.item.CURRENCY_CODE;                        
                             break;
                       case "bsNet":
                             return "Sales Order #: " +  hd.item.SO_ID + "\n " + FlashIsland.formatNumber(hd.item.TTL_NET_AMOUNT) + " " + hd.item.CURRENCY_CODE;
                             break;                   
                  return "Amount";

  • Flex Newbie Questions

    I have just started to explore the capabilites of Flex for
    possible implementation within my organization, and I have a few
    questions, answers to which I couldn't find on adobe's site. I'm
    hoping the Flex community can help.
    Firstly, can Flex easily integrate with exisiting J2EE-Web
    applications? For example, if I have an EJB-based application, can
    I use the existing EJBs and swap out the JSP-based front-end with
    Flex? If so, how easy is it to do this What kind of a learning
    curve are we looking at? If someone can explain how exactly this is
    done....I'd greatly appreciate it.
    Secondly, It seems the Flex framework itself is free....only
    the IDE costs money. Is my understanding correct?
    Third, What really is Flex Data Services? And what does it
    do?
    We have a bunch of J2EE-based applications in our
    organization, and the most time consuming part is always developing
    the front-end. Can Flex solve this problem without jeoparadizing
    our J2EE investment?
    I would really appreciate all the feedback!

    aamya
    Firstly: "Easily" is a relative term, so I"ll stay away from
    that one. The short answer is "yes", you can access java objects
    from Flex. I can't really tell you the learning curve, because I
    don't know you or your skills, however I've been told that Java
    programmers will be quite at home with ActionScript.
    Second: You are correct.
    Third: FDS essentially allows you to connect your Flex app
    with "live" back end data. For example, if a helpdesk ticket status
    changes because User A has closed it, User B's interface will
    automatically refresh.
    Flex is a pesentation layer solution, so the idea is to keep
    your back end intact - I can't guarantee that NO changes to your
    back end systems will be needed though, but I'd guess that you'd be
    90% good to go. Get started by downloading a 30-day trial, and go
    through the articles posted on Adobe.com and recently at CFDJ (
    http://cfdj.sys-con.com/).
    My user group site also has a list of resources:
    http://www.cfugitives.com/index.cfm?commentID=7
    Good luck!

  • Flex 2 questions

    Hello,
    I have 2 questions.
    1.  Is it necessary that the data from php to flex should be in xml format, if not then please provide a link or some code snippet in php and flex?
    2.  I have a webserver which gets socket values from another server, should i have to send the policy file from webserver or should it be from server which sends the sockets?
    Thanks

    http://support.lenovo.com/us/en/products/laptops-and-netbooks/flex-series/flex-2-14-notebook-lenovo?...
    1. Install the generic driver:
    1. Disable signature enforcement: https://www.youtube.com/watch?v=NM1MN8QZhnk
    2. Install the synaptic driver: 17.0.19
    3. Install the aforementioned patch
    2. Try the link above.

  • Basic Flex RPC question

    Hi.  I apologize for such a basic question.
    But when it comes to Flex RPC via BlazeDS does it use blocking IO?  Meaning say if we want to make 5 rpc calls.  1 of them takes 5 minutes and the rest of them 1 second.  The ones that are quicker will return first right?  All 5 are using the same service destination and new RemoteObject instances.
    The reason why I'm asking is that we're seeing behavior where the IO seems to be blocking.  The server side rpc calls aren't getting called until after the one before it finishes.
    thanks in advance.

    Basically, Flex is single threaded, so it might work serially.
    Anyway, you can reuse a single RemoteObject instance...

  • Flex Security Questions

    Hi,
    I am new to flex. How can I protect the source code of my written flex application? As we know, there a quite a number of program that can easily decomplie flex to get back the source code such as Sothink SWF Decomplier. How is it possible to prevent people from viewing the source code and then modify it and then even use it to connect to our databases?
    Thanks.

    You can check this too.
    http://www.tokaos.com/swf-encrypt-example.asp
    with Regards,
    Shardul Singh Bartwal

  • Flex 2 question. Just want to know

    Hi,
    I been studing Flex 2 for few days. I hear more about cold
    fusion and flex 2 (Cold fusion as back end) .
    1- Why cold fusion is good to use with Flex 2 for backend,
    mailing etc?
    2- Does Flex 2 have its own component that give back end
    support for SQL, Oracle etc?
    3- Can I use .NET 2.0 instead of cold fusion for whatever
    purpose Cold fusion is fullfilling?

    you can use any server side technology for your backend that
    you like, there are a number of ways to communicate with your
    server in flex, the most generic being the HTTPService component
    which allows you to send standard HTTP requests to any url and also
    retrieve results from any url.

  • Flex fields question

    Hi,
    I'm trying to use flex fields in Worklist оn SOA Suite 11.1.1.4 but I cant see protected flex fields on Administration tab under weblogic, only public.
    Is it some new bug on 11.1.1.4 on new "feature"?
    How can i can enable protected flex fields? Is it posible?

    It seems I found solution.
    After extending weblogic domain with Oracle BPM Suite protected flex fields appers and become usable.

  • Flex Compiler Question

    Hi,
    I have several PHP Scripts that I use with my Flex App. I have the PHP files in a subdirectory 'PHP/'. However, when I compile the Application the PHP files are overwritten and are blank. I tried placing the PHP directory in the 'src' source folder so when the app compiles the PHP files will compile much like assets. This method will work for some projects but not for others. How can I configure my application to leave the PHP directory alone without changing the path?

    You could create a folder outside the SRC and link this folder to a folder in the  file system so your files will be localted where you want them to be.

  • Flex Time question

    How do u stretch audio using Flex, like moving a small area of a wave a lil to the right or left to correct for the tempo, without it sounding scratchy at the end of the region? I tried moving it using "Rhythmic" setting, but there's some noise at the last Flex Marker.

    You can flex any audio.
    The results you get will depend on a variety of factors, what the audio is, what you want to do etc, but don't be afraid to try. You'll get a handle on what you can do well and can't do well the more you use it.

  • Flex profiler questions

    Is there anyway to tell WHY an instance of a class is trapped in
    memory?
    So I discovered the flex builder profiler yesterday. I have
    never used something like that before, and I am now aware that many
    of the instaces I thought I was clearing for garbage collection are
    NOT being garbage collected.
    I have been trying for a whole day now and I am still trying
    to get rid of the excess instances of the same class I started
    with.
    So I made an interface called IDestroyable, which has one
    function destroy() which first loops through all its children and
    sets them to null and if they implement IDestroyable then call
    destroy on them as well. Then it removes all its own event
    listeners. and set the instance and all its children and grand
    children to implement IDestroyable.
    Yet all my work has been for nothing because the instances
    are STILL trapped in memory.

    Garbage collection isn't triggered by simply destroying a
    component and all refs to it. Garbage collection will run when
    Flash Player wants it to. Like when it need more memory to create
    another component.
    You can click the garbage collection button while running the
    profiler, and you will see the instances go away (after you have
    destroyed them of course).

  • Flex FileReference questions

    I want to make a Flex application (that must be able to run in flash player) which prompts the user to select a file, and then Base64 encodes the file before sending it in a web service call. Anyone know if this is possible?

    Hi jonathan,
    Can you tell me how you did this.
    I get rubbish out of the base64 encoder.
    my code is :
    var FileByteArr:ByteArray = loadFileRef.data;
    var enFileBase64:Base64Encoder = new Base64Encoder();
    enFileBase64.encode(FileByteArr.toString());
    var strFileBase64:String=enFileBase64.toString();
    txtText.text = strFileBase64;
    I cannot convert it back to a file.

  • Flex Charting Question

    Does anyone know how include a labeled 'phase change line'
    within a Flex chart? These types of charts are normally used to
    track behavior over time (the phase change denotes changes in
    medication, etc.). Any advice would be greatly appreciated.

    Yes it is possible
    You need to use the cartesian chart and a secondSeries and
    secondHorizontalAxis or secondVerticalaxis

  • Flex Store Question

    http://examples.adobe.com/flex2/inproduct/sdk/hybridstore/srcview/index.html
    so i was wondering since i want to start practice building
    apps i figured this would be good practice to duplicate it, so
    looking at the source code i see that all the phones are hardcoded
    with x and y values for filtering and stuff like that so i was
    wondering would it be viable to try and use say a TileList will i
    be able to get the same effect?

    A good place to explore the options that you have is in the
    livedocs.
    http://livedocs.adobe.com/flex/201/langref/index.html

Maybe you are looking for