Flex 3 with Java
By Satish Kore
()
About this ebook
Related to Flex 3 with Java
Related ebooks
jQuery UI 1.7: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsPHPEclipse: A User Guide Rating: 3 out of 5 stars3/5Meteor Design Patterns Rating: 0 out of 5 stars0 ratingsInstant Play Framework Starter Rating: 0 out of 5 stars0 ratingsjQuery 1.3 with PHP Rating: 0 out of 5 stars0 ratingsjQuery Mobile Web Development Essentials - Third Edition Rating: 0 out of 5 stars0 ratingsOpenCart Theme and Module Development Rating: 0 out of 5 stars0 ratingsBuilding Websites with VB.NET and DotNetNuke 4 Rating: 1 out of 5 stars1/5Symfony2 Essentials Rating: 0 out of 5 stars0 ratingsjQuery Design Patterns Rating: 0 out of 5 stars0 ratingsMastering MeteorJS Application Development Rating: 4 out of 5 stars4/5NW.js Essentials Rating: 0 out of 5 stars0 ratingsResponsive Media in HTML5 Rating: 0 out of 5 stars0 ratingsMVVM Survival Guide for Enterprise Architectures in Silverlight and WPF Rating: 0 out of 5 stars0 ratingsGetting Started with Meteor.js JavaScript Framework - Second Edition Rating: 0 out of 5 stars0 ratingsHTML5 for Flash Developers Rating: 5 out of 5 stars5/5Developing Windows Store Apps with HTML5 and JavaScript Rating: 0 out of 5 stars0 ratingsLearning Yii Testing Rating: 1 out of 5 stars1/5Professional ASP.NET Design Patterns Rating: 4 out of 5 stars4/5CodeIgniter Web Application Blueprints Rating: 0 out of 5 stars0 ratingsRedmine Plugin Extension and Development Rating: 0 out of 5 stars0 ratingsPython for Google App Engine Rating: 0 out of 5 stars0 ratingsjQuery Game Development Essentials Rating: 0 out of 5 stars0 ratingsAdvanced Express Web Application Development Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsLearning SQLite for iOS Rating: 0 out of 5 stars0 ratingsLearning Modular Java Programming Rating: 0 out of 5 stars0 ratingsFlash with Drupal Rating: 0 out of 5 stars0 ratingsAJAX Interview Questions, Answers, and Explanations: AJAX Certification Review Rating: 0 out of 5 stars0 ratingsInstant Highcharts Rating: 0 out of 5 stars0 ratings
Information Technology For You
Health Informatics: Practical Guide Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5CompTIA ITF+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsAWS Certified Cloud Practitioner: Study Guide with Practice Questions and Labs Rating: 5 out of 5 stars5/5How To Use Chatgpt: Using Chatgpt To Make Money Online Has Never Been This Simple Rating: 0 out of 5 stars0 ratingsMicro Niches Rating: 0 out of 5 stars0 ratingsComputer Science: A Concise Introduction Rating: 4 out of 5 stars4/5How to Write Effective Emails at Work Rating: 4 out of 5 stars4/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5The Basics of Hacking and Penetration Testing: Ethical Hacking and Penetration Testing Made Easy Rating: 4 out of 5 stars4/5Windows Registry Forensics: Advanced Digital Forensic Analysis of the Windows Registry Rating: 4 out of 5 stars4/5ChatGPT: The Future of Intelligent Conversation Rating: 4 out of 5 stars4/5Practical Ethical Hacking from Scratch Rating: 5 out of 5 stars5/5Inkscape Beginner’s Guide Rating: 5 out of 5 stars5/5CompTIA Network+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam N10-008 Rating: 0 out of 5 stars0 ratingsHandbook of Digital Forensics and Investigation Rating: 4 out of 5 stars4/5Data Governance For Dummies Rating: 0 out of 5 stars0 ratingsCompTIA A+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Core 1 Exam 220-1101 Rating: 0 out of 5 stars0 ratingsHacking Essentials - The Beginner's Guide To Ethical Hacking And Penetration Testing Rating: 3 out of 5 stars3/5Just Enough R: Learn Data Analysis with R in a Day Rating: 4 out of 5 stars4/5Codeless Data Structures and Algorithms: Learn DSA Without Writing a Single Line of Code Rating: 0 out of 5 stars0 ratingsPanda3d 1.7 Game Developer's Cookbook Rating: 0 out of 5 stars0 ratingsComputer Organization and Design: The Hardware / Software Interface Rating: 4 out of 5 stars4/5Cybersecurity for Beginners : Learn the Fundamentals of Cybersecurity in an Easy, Step-by-Step Guide: 1 Rating: 0 out of 5 stars0 ratingsAn Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Supercommunicator: Explaining the Complicated So Anyone Can Understand Rating: 3 out of 5 stars3/5CISSP Study Guide Rating: 4 out of 5 stars4/5Hack Proofing Your Network Rating: 0 out of 5 stars0 ratingsA Practical Guide Wireshark Forensics Rating: 5 out of 5 stars5/5
Reviews for Flex 3 with Java
0 ratings0 reviews
Book preview
Flex 3 with Java - Satish Kore
Table of Contents
Flex 3 with Java
Credits
About the Author
About the Reviewers
Preface
What this book covers
What you need for this book
Conventions
Reader feedback
Customer support
Downloading the example code for the book
Errata
Piracy
Questions
1. Installing and Configuring Adobe Flex
Installing open source Flex 3 SDK
Installation directory structure
About configuration files
Flex compilers
Using compc—the component compiler
Using mxmlc—the application compiler
Installing Flex Builder 3
Creating a Flex project
UI designer and source code editor
Flex LiveDocs
Summary
2. Introduction to Flex 3 Framework
How Flex works
Compiling and running an application
About MXML
Understanding namespaces
Using namespaces in your code
Containers
Layout manager
Layout containers
Using Box, HBox, and VBox containers
Navigator containers
Form containers
Constraint-based layout
Using events in MXML
Creating custom events
Validating and formatting data
Restricting user entry
Formatting
Data binding
Using the [Bindable] metadata tag
Creating MXML custom components
Understanding Flex itemRenderers
Drop-in itemRenderers
Inline itemRenderers
External itemRenderers
Summary
3. Introduction to ActionScript 3.0
ActionScript 3.0 language features
Strict data typing
Runtime exceptions
Sealed classes and dynamic classes
Method closure
XML and E4X
New primitive data types
Regular expressions
Object-oriented programming
ActionScript 3.0 fundamentals
Variables
Access modifiers
Packages
Classes and interfaces
Classes
Interfaces
Implementing an interface in a class
Inheriting classes
Functions and methods
Named functions
Anonymous functions
Function parameters
The default parameter values
The ...(rest) parameter
Setter and getter methods
Flow control and looping
If/else statement
switch statement
Looping
While looping
do..while looping
for looping
for..in looping
for each..in looping
Exceptions and error handling
try...catch...finally statements
Create your own custom Error class object
Reserved words and keywords
Using ActionScript 3.0 with MXML
Using the
Using the include directive
Working with events
Registering event handlers
Dispatching an event
About the target and currentTarget properties
Event propagation
Capturing phase
Targeting phase
Bubbling phase
Creating custom events
Creating and using ActionScript components
The commitProperties() method
The createChildren() method
The layoutChrome() method
The measure() method
The updateDisplayList() method
Summary
4. Using External API and LocalConnection
Using External API
Using the ExternalInterface class
Getting information about external container
Calling JavaScript code from ActionScript
Calling ActionScript code from JavaScript
Using LocalConnection
Summary
5. Working with XML
XML basics
Understanding E4X
The XML object
The XMLList object
Working with XML objects
Using XML as dataProvider
Loading external XML documents
An example: Building a book explorer
Summary
6. Overview of LiveCycle Data Services and BlazeDS
LiveCycle Data Services
BlazeDS
BlazeDS vs LiveCycle Data Services
LiveCycle Data Services
BlazeDS
Understanding AMF
Summary
7. Flex Data Access Methods
Flex data access components
The HTTPService class
Using the HTTPService tag in MXML
An example of HTTPService
Using the HTTPService class in ActionScript
The WebService class
Using the WebService tag in MXML
An example of WebService
WSDL document
Using the WebService class in ActionScript
Working with SOAP headers
The RemoteObject class
Using the RemoteObject tag in MXML
An example of RemoteObject
Working with strongly-typed objects
Understanding the Flash Player security sandbox
Understanding the cross-domain policy file
Creating a proxy service
Summary
8. Communicating with Server-side Java
The HTTPService class
Working with XML data
Working with JSON data
Summary
9. Debugging Techniques
Flash Debug Player
Using client-side logging
Flex Builder Debugger
The Debug view
The Variables view
The Breakpoints view
The Expressions view
Network monitoring
ServiceCapture
Charles Web Debugging Proxy
Summary
10. Styling your Application
Using inline styles
Using external CSS files
Creating and designing Cascading Style Sheets
Loading stylesheets at runtime
Summary
11. Packaging and Deployment
Packaging your application
Using Flex Ant Tasks
Deploying your application
Flex deployment options
Using a single SWF file deployment
Using web-tier compilation
Summary
12. Internationalization and Localization
Internationalization (i18n) and localization (l10n)
Language
Assets
Culture
Time zones
Localization of Flex applications
Creating a resource file
Creating resource modules
Summary
13. Creating an E-commerce Application
The general anatomy of the application
Let's start coding
The Flex code
The Java code
Directories and files
Summary
Index
Flex 3 with Java
Satish Kore
Flex 3 with Java
Copyright © 2009 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2009
Production Reference: 1220609
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847195-34-0
www.packtpub.com
Cover Image by Vinayak Chittar (<vinayak.chittar@gmail.com>)
Credits
Author
Satish Kore
Reviewers
Wim Bervoets
Trevor Burton
Acquisition Editor
James Lumsden
Development Editor
Swapna Verlekar
Technical Editor
Dhiraj Bellani
Copy Editor
Sneha Kulkarni
Indexer
Hemangini Bari
Editorial Team Leader
Abhijeet Deobhakta
Project Team Leader
Lata Basantani
Project Coordinator
Neelkanth Mehta
Proofreaders
Laura Booth
Lynda Sliwoski
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Satish Kore is a software engineer, an amateur blogger, and a dreamer based in a beautiful city Bangalore in India. He has worked on a variety of technologies including Adobe Flex, Java, and J2ME over the past eight years. He has always been passionate about Rich Internet application (RIA) technologies and loves working on Adobe Flex. He always enjoyed writing software applications and solving common problems using technology. You can keep up with his work by visiting his blog at http://blog.satishkore.com, or by following him on Twitter http://twitter.com/satishkore.
I thank my family for being encouraging and supportive and special thanks to my friends for always inviting me on parties even though I constantly refused to join them by giving them the same boring reason that I am busy with writing.
This book means a lot to me since I have spent all my weekends and free time writing this book for the past 6-7 months. However, this book would not have been possible without some individuals who have worked alongside me during the writing, reviewing, and publishing phases.
I would thank James Lumsden for giving me the opportunity to write this book. I would also like to thank Neelkanth Mehta, Swapna Verlekar, Dhiraj Bellani, and all my technical reviewers for proofreading, reviewing, and refining the content of this book; without their efforts, this book wouldn’t have been completed.
About the Reviewers
Wim Bervoets is a Senior J2EE/Java software engineer and architect from Belgium, Europe, who helps organizations to implement complex web-based business applications.
Since 2000, Wim Bervoets has specialized in developing and architecting web-based solutions in various companies and industries (for example, banks, pharmacy, and so on) and in various roles (as a lead developer, architect, consultant, designer, and so on).
Since 2008, he has also started working with Adobe Flex RIA Technologies in combination with existing Java applications.
Wim Bervoets is also no stranger to Web2.0, internet marketing and web site launches. He created successful international web sites, such as http://www.javablog.be —a blog about Java and Flex, http://www.dancevibes.be —a blog about music, and http://www.wimsbios.com — a site for PC tech enthusiasts.
To contact Wim Bervoets, please email to<wim@javablog.be>or go to his blog at http://www.javablog.be.
Trevor Burton is a software developer based in London, UK. He works primarily in Actionscript and Java. He has been working with Flash since the release of Flash 4 and Flex since the release of version 3 and has a wealth of experience developing Flash games from the banner advergames to multi-million pound online gambling applications.
He currently works for Infrared5, developing a wide range of web applications. In his spare time, he experiments with multi-user interaction and human—computer interaction.
Dedicated to my beautiful wife, Archana. I remain thankful to her for being supportive and understanding
Preface
Rich Internet applications (RIAs) are a new breed of web applications that are capable of doing things such as loading and handling heavy data ten times faster than HTTP, designing great-looking and sophisticated user interfaces that resemble desktop-based applications, and having the possibility of utilizing existing server technology such as Java, that would have never been possible with typical web technologies, such as HTML. Flex 3 is a leading technology for developing RIAs for the Web, as well as for the desktop. This book gives you an insight into, and provides a hands-on experience in, programming in Flex 3 by utilizing your existing knowledge of Java programming.
This book includes comprehensive information on various concepts of Flex 3 and ActionScript 3.0, such as developing simple applications and handling events to creating custom components and events, using RPC services, integration with Java and BlazeDS, styling and formatting, and how to package and deploy Flex applications. Finally, this book provides a step-by-step tutorial for developing e-commerce applications using Flex 3, ActionScript 3.0, BlazeDS, and Java.
You will start with downloading, installing, and configuring Flex 3 SDK and Flex Builder 3 and learn basic concepts, such as what is Macromedia Flex Markup Language (MXML) and ActionScript, understanding UI components, controls and compilers, and so on. Furthermore, you will start developing simple applications and slowly go into more depth where you will learn advanced concepts, such as creating custom components, debugging, integrating with Java, using RPC services, styling, internationalizing, and deploying Flex applications, and much more.
What this book covers
Chapter 1: Installing and Configuring Adobe Flex—In this chapter, you will learn the basics of Flex programming, that is, downloading, installing, and configuring Flex SDK and Flex Builder 3.
Chapter 2: Introduction to Flex 3 Framework—This chapter will introduce you to the MXML scripting for laying out User Interfaces (UI) in the Flex world. This chapter also provides hands-on examples required to get you started with MXML programming.
Chapter 3: Introduction to ActionScript 3.0—This chapter will introduce you to the ActionScript 3.0 programming language along with detailed code samples.
Chapter 4: Using External API and LocalConnection - In this chapter, you will learn how to communicate with JavaScript from a Flex application and vice versa.
Chapter 5: Working with XML—In this chapter, you will learn how to work with XML data using Flex's E4X approach.
Chapter 6:Overview of LiveCycle Data Services and BlazeDS—This chapter will provide an overview of BlazeDS and LiveCycle Data Services.
Chapter 7: Flex Data Access Methods—This chapter provides you with in-depth information about various data access methods available in Flex with detailed and step-by-step code samples along with Flash Player security model. It also gives you a detailed insight into how to use RemoteObject to communicate with Java code.
Chapter 8: Communicating with Server-side Java—This chapter provides step-by-step code examples to get started with Flex and Java communication along with clear and simple code examples..
Chapter 9: Debugging Techniques—In this chapter, you will learn how to debug your Flex application using Flex Builder 3 and some third-party tools.
Chapter 10: Packaging and Deployment—You will learn how to build and package a Flex application using available tools, such as Apache Ant, and learn about various deployment options that you can use.
Chapter 11: Styling Your Application—This chapter will give an overview of using Cascading Style Sheet (CSS) for changing the look and feel of your Flex application and components with brief code examples and tools for designing CSS files.
Chapter 12: Internationalization and Localization—This chapter will give you an overview of internationalizing your application.
Chapter 13: Creating an E-commerce Application—This chapter will provide a step-by-step guide for creating an end-to-end e-commerce application using Flex 3, ActionScript 3.0, BlazeDS, and Java.
What you need for this book
First and foremost, you need to have a need for learning Flex 3 technology; yes, I say that because most of us learn a new technology either by accident or because of some need, such as client/project demand or for doing things that are not possible with current technology or maybe you just want to upgrade your skill sets. Whatever is your reason behind learning Flex 3, I assure you that this book will serve as a simple and clear handbook for any developers to get started with Adobe Flex 3 programming.
Although this book is very easy to read and understand for any novice programmer, having some basic knowledge of Java programming in general, including Java Server Pages (JSP), would help you to pick up quickly. Apart from this, I assume that you have already heard about terms such as Rich Internet applications (RIAs) and understand theory behind it; if not, then please visit http://en.wikipedia.org/wiki/Rich_Internet_application.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: The ExternalInterface.available property can be used to determine if the container application that is hosting your Flash Player instance supports an external interface.
A block of code is set as follows:
Label
{
color: #ffff00;
fontSize: 20;
fontWeight: bold;
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Label
{
color: #ffff00;
fontSize: 20;
fontWeight: bold;
}
Label.helloStyle
{
color: red;
fontSize: 20;
fontStyle: italic;
}
Label.bonjourStyle
{
color: blue;
fontFamily: Arial;
fontSize: 20;
}
Any command-line input or output is written as follows:
mxmlc -library-path+=..../MyLibraries/bin/Main.mxml
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: clicking the Next button moves you to the next screen
.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an email to<feedback@packtpub.com>, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code for the book
Visit http://www.packtpub.com/files/code/5340_Code.zip to directly download the example code.
The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at<copyright@packtpub.com>with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at<questions@packtpub.com>if you are having a problem with any aspect of the book, and we will do our best to address it.
Chapter 1. Installing and Configuring Adobe Flex
In this chapter, you will learn how to install and configure Basic Flex 3.0 SDK (Software Development Kit) and Flex Builder 3. The Adobe Flex SDK contains everything you need to build and deploy Flex Rich Internet applications (RIAs). You can write Flex programs typically using any freely available text editing tools, such as Notepad, TextPad, or any Integrated Development Environment (IDE) of your choice. Adobe provides a specialized IDE for developing and designing Flex applications known as Flex Builder. Flex Builder is built on top of Eclipse platform. So if you are familiar with the Eclipse development paradigm, it will be very easy for you to use Flex Builder.
Although you do not need Flex Builder to write and compile Flex applications, Flex Builder does facilitate development with powerful tools, such as debugger, profiler, and visual designer apart from what the Eclipse platform offers you.
I prefer using Flex Builder 3, since I use Eclipse a lot for my Java development and I have installed Flex Builder 3 as a plugin to my Eclipse IDE.
I am assuming that you have prior knowledge of installing and configuring software packages on the Windows platform. In this chapter, I will explain how to install Flex Builder 3 on Windows. Mac and Linux users should visit Adobe's web site at http://www.adobe.com/support/documentation/en/flex/3/releasenotes_flex3_fb.html for installation instructions.
Installing open source Flex 3 SDK
Flex SDK comes in different types such as licensed Free Adobe Flex SDK (with a mixture of open source and closed open source components) and open source Flex SDK. The latter package contains entirely open source components under the Mozilla Public License version 1.1 (MPL) agreement, which includes its binaries. To know more about the available types of SDKs, visit http://opensource.adobe.com/wiki/display/flexsdk/Downloads. In this chapter, I will cover open source Flex SDK as an example.
In order to install Flex 3 SDK, download