Aplicación Flex para la variable de entrada de texto de PlayBook

I know this is probably a very simple question, but can someone please walk me through how to take what a user inputs into a s:TextInput and use that as a variable in a JSON data request?

Basically, I want to have a user enter a search term, like "math" and then have that placed into a variable so I can use it in a JSON request.

Something like public var q:String, except that my search box (and hence user input) is on another "view" of the application.

I've just started with Flex Mobile applications and I might be way out of my league. Does anyone know how to do this?

preguntado el 08 de enero de 11 a las 15:01

1 Respuestas

The containing view should still be able to access teh child view's properties (and therefore controls); you just need the control(s) to have a unique ID, which then becomes a property name. That said, I would consider the whole search feature to be self-contained, so it'd have its own controller (action script class for handling actions) wired up to the search button, adn have a reference to the view that it can extract the info from, etc.

Respondido el 08 de enero de 11 a las 18:01

I don't fully understand. You think that the button should capture the user input and then pass it along to another script? What would be the advantage of doing so, and how would I go about doing it? Part of the problem is there's a disconnect in my mind between actionscript and the MXML. - Jay Hankins

ok, so when your app compiles, mxml becomes a class merged w/ its associated codefile and inline actionscript. that class exposes a property for each control w/ an id that you've defined on it. A well architected app, though, will also have regular classes taht handle most of hte business logic, and your views will just wire events to methods on those classes, which helps promote reuse and maintainability. Look into the Model-View-Controller patterna nd Model-View-ViewModel pattern for some insight and explanation of the benefits. - paul

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.