View Full Version : [Flex] - Q about screens
Digitalosophy
December 17th, 2007, 01:04 PM
This is my first week working with Flex Builder 2 and so far so good. However I have a question that seems like it should have a real obvious solution but I haven't found it yet :)
Basically what I want to do is have 3 sections in my application.
Section 1 - Contact Information:
A form that gathers the users contact information. Once it's validated, I want to go to a different screen (form) that will gather quoting information.
I have the validation working fine, and the data is passed to php with no problem and send back a result to the Flex app. If the result is 1 (which means everything was inserted into my sql table) I want Flex to jump to a different screen which will have a different form.
In Flash there are tons of different ways to do this, but because of no time line or movie clips in Flex, I have no idea how to achieve this.
A work around I guess would to just have a conditional in the xmxl file that will generate the appropriate code based on a query.
if (section1 == 1){
// make form 1
}else if (section2 == 1){
// make form 2
}else{
// yada yada yada
}
The above seems overly complicated for such a simple task. I'm hoping this is something really simply I am just overlooking.
Also since we are on topic, I find the documentation for Flex not too helpful. What resources are you guys using to learn this stuff?
Thanks
Dave
Stratification
December 17th, 2007, 02:07 PM
You can do that pretty easily a couple of ways. The first would be to create each form on a layer of a View stack, then just set the correct index on the stack. Or, you can set up states for each of the forms, and just set the currentState property.
Digitalosophy
December 17th, 2007, 02:27 PM
You can do that pretty easily a couple of ways. The first would be to create each form on a layer of a View stack, then just set the correct index on the stack. Or, you can set up states for each of the forms, and just set the currentState property.
Thanks for the reply.
I'm not familiar with a View Stack, I will have to look that up in the documentation. Basically what I did (I'm at work and don't have the code handy) was just set up a form, but I didn't include the form tag, would I have to do that for the second suggestion?
I'm a little confused as there seems to be several ways to set up a form.
When you say states for each of the forms, is this similar to a button let's say? Then I can use whatever the currentState property is to say which state to show I'm assuming?
-D
Stratification
December 17th, 2007, 02:41 PM
You'll have to do some looking into the states for Flex, very powerful, but it's kind of complex and sometimes hard to work with. As far as the ViewStack, basically each main container under the ViewStack is shown separately, think tabs without the tab navigator. Setting the index decides which container (canvas, vbox, hbox, etc.) is shown. Hopefully that makes sense, let me look around and see if I can find more on states.
EDIT:
http://www.adobe.com/devnet/flex/quickstart/creating_states/
http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000923.html
Digitalosophy
December 17th, 2007, 03:16 PM
You'll have to do some looking into the states for Flex, very powerful, but it's kind of complex and sometimes hard to work with. As far as the ViewStack, basically each main container under the ViewStack is shown separately, think tabs without the tab navigator. Setting the index decides which container (canvas, vbox, hbox, etc.) is shown. Hopefully that makes sense, let me look around and see if I can find more on states.
EDIT:
http://www.adobe.com/devnet/flex/quickstart/creating_states/
http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000923.html
Appreciate the help and links man.
That does look a bit complex, although all of Flex does to me right now lol.
Cheers.
Stratification
December 17th, 2007, 03:20 PM
Yeah, starting with Flex can be a bit intimidating. If you're building apps (not just websites, or simple interaction) with Flash now though, you're going to find it very hard to go back to Flash pretty soon. (At least that's my experience)
Digitalosophy
December 18th, 2007, 08:50 AM
Yeah, starting with Flex can be a bit intimidating. If you're building apps (not just websites, or simple interaction) with Flash now though, you're going to find it very hard to go back to Flash pretty soon. (At least that's my experience)
Well I spent a few hours last night trying to get this to work with my app and not too much luck although I did get something going.
What I don't understand is how to set a default layout based on a state. In other words, the examples I've seen just show you how to add elements to a pre existing layout. What I want is my default form to be deleted and a new one to show.
I know I can eventually get this working, I wish there was a more clear tutorial on how to do a really basic one.
Right now I have my code like
<mx:states>
// bla bla
</mx:states>
// then down here I have my original form
<mx:panel>
// default form is here
</mx:panel>
So what I would have to do I'm assuming is have my original form in a state so it would get replaced with the new state (which has the new form).
Does that sound right? Hate to be a pest :)
Thanks again.
Stratification
December 18th, 2007, 12:14 PM
Something along those lines. States make the most sense when there's something common between the two portions, that allows you to do transitions later when moving from one state to another. Personally I find that states are easier to work with in the visual editor (drag and drop), but that's just me. If there are only a couple of forms and they are completely different then the ViewStack method I mentioned might make more sense.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.