Flash Builder
Cut down Flex in a Week
Watch the videos, indicated by the
icon;
then do the exercises indicated by the
icon.
You should do all of these before the timetabled workshop so that you can do the independent task at the end of this page during the workshop with the lecturer.
Section 3: Data handling and manipulation
Extending events
- Creating an event type and dispatching the event object (13:28) Covers:
- Creating custom event types for you custom components
- Handling the event in the main application
- Creating an event type and dispatching the event object
- Extending the Event class to pass data in the event object (22:11). This video covers:
- Dispatching custom data in an event object
- Extending the Event class
- Understanding the problem with bindings
- Cloning the subclass instance for event propagation
- Using the extended event data in a second component
- Extending the Event class to pass data in the event object
- Dispatching a value object from the custom component (17:27).
At the end of page two you learned how to create classes, or what the videos also call value objects, and at the start of this page you learned how to package your own properties into an event object by extending the event object class. This video brings those two topics together and covers:
- Defining a value object as a custom event class argument
- Dispatching a value object in an event object
- Dispatching a value object from the custom component
Sending remote data
- Making a server request using:
HTTPService (12:50) You've covered retrieving data using the HTTPService, this video covers:- Sending data to the server to update the database using the HTTPService
- Handling a server response
- HTTPService exercise covering passing data to the server
Remote Data: author php and flash
Another set of my videos putting what you've learned above into context and showing it in action
- Modifying the PHP Service Class (18:50) This video screencast of mine shows how modify the php service pipe, and associated classes, to handle updates to the database.
- Sending parameters via the HTTPService (20:29) Another of my screencasts showing how to use Flash Builder to send parameters to the PHP Service Class using the HTTPService. It covers how to edit Author information, send the changed author object via a custom event and then to pass the information it contains to the server side script.
- Making the save button active (11:29) A short screencast to just show how to make the Save button only become active if the user has edited any values.
Independent Task
These tasks you can do in class if you want, having first followed the videos and exercises above in your own time.
Task Overview
The tasks will require you to implement an extension to your AuthorServicePipe to call an Author class update method to modify author details stored in the database, then to modify your display/edit form in Flash Builder so that it will send information back to the main program using a custom event containing the updated Author object. The main program will invoke an author http service sending appropriate parameters to the updated AuthorServicePipe php script. In other words you're going to implement exactly what the three videos above demonstrate.
php serverside
- Modify the AuthorClassPipe to include an update action in which it will get the appropriate values from the request stream to enable you to update the author information (you'll need ID, surname, forename and phone). Check those values aren't blank before..
- Modify the Author class constructor to allow ID, surname, forename and phone but with default values of null -remember this is important else your other php code will break since pdo doesn't send values to the constructor.
- Make your update action in the AuthorClassPipe create a new Author class instance using the values sent in the request stream.
- Modify the AuthorService update method to take an author instance passed as a parameter and, using prepared statements, create and execute the appropriate sql statment using named placeholders.
- Test your AuthorServicePipe.php works correctly by manually typing in values in your URL - as shown in the screencast.
Flash Builder project
- You should already have an AuthorDisplay component that uses a form with a drop down list to choose authors and which displays author data in TextInput boxes - the screencast has more detail.
- Make sure also that you have an Author class in a valueObjects package that you have made
Bindable - Create a new project, named
authorInfo-withCustomEventsand copy and paste all the source code and directories (components and valueObjects) from the earlier version completed as part of the last set of Flash Tasks. By the way, you can do this directly from inside Flash Builder by clicking on the directories within src from the left pane and choosing copy and then pasting into the src directory of the new project. - Create a Custom Event, named as in the screencast, that will receive an instance of Author as demonstrated in the screencast.
- Modify your AuthorDisplay component to add a Save button, create a Save button click event handler inside of which you will create an Author instance and dispatch it to an instance of your AuthorEvent class.
- Modify your main program to listen for the
authorEventand, inside a handler for that event, create the appropriate parameters to pass to a new HTTPService request object. - Modify your program so that after a successful update operation the new updated author information is correctly displayed.
- Implement the appropriate code so that the save button is only active if the user has edited the data.