Upload
kevin-schroeder
View
1.437
Download
3
Tags:
Embed Size (px)
Citation preview
©All rights reserved. Zend Technologies, Inc.
Building mobile and tablet applications in Flex and PHP with Flash Builder for PHPKevin Schroeder
Zend Technologies
©All rights reserved. Zend Technologies, Inc.
About Kevin
Past: Programming/Sys Admin
Current: Technology Evangelist/Author/Composer
@kpschrade
©All rights reserved. Zend Technologies, Inc.
©All rights reserved. Zend Technologies, Inc.
Agenda
• The basics
• Creating a project
• Working with MXML
• Working with ActionScript
• Connecting to PHP
©All rights reserved. Zend Technologies, Inc.
The Basics
• What is Flash? A platform for building highly interactive web content
• What is AIR? A runtime of the Flash environment for the desktop
• What is ActionScript The natively supported programming language for building
more than just simple graphic animations
• What is Flex? An SDK for building Rich Internet Applications in
Flash/ActionScript
©All rights reserved. Zend Technologies, Inc.
Flash/Flex Projects
©All rights reserved. Zend Technologies, Inc.
Creating a project ( w/ PHP )
Connects the projects
©All rights reserved. Zend Technologies, Inc.
Flex Project Basics
• AIR projects will have an Application Descriptor file Defines
• Application Name
• Versioning
• Initialization settings– Width
– Height
– Visible
– Etc. etc. etc.
• Etc. etc. etc.
• Flex/web projects inherit this from the browser
©All rights reserved. Zend Technologies, Inc.
MXML
©All rights reserved. Zend Technologies, Inc.
MXML
• An XML-based UI markup language
• Describes UI elements Position
Data Bindings
Events
• Two primary component sets (for widgets) MX – the older brother (Flex 3)
Spark – the new hotness (Flex 4)• Most of what you need to do will be in Spark
©All rights reserved. Zend Technologies, Inc.
MXML Example
XML Namespace declaration for Spark Components
XML Namespace declaration for Flex (non-visual, generally)
©All rights reserved. Zend Technologies, Inc.
MXML – Adding a component
Choosing from a list of Spark Components
©All rights reserved. Zend Technologies, Inc.
MXML – Creating Flex Elements
Defining local data container
Defining local ActionScript container
©All rights reserved. Zend Technologies, Inc.
MXML – Binding Static Data
Declared a data source
Accessed the data source
©All rights reserved. Zend Technologies, Inc.
MXML - Events
Defining the event
Event callback
©All rights reserved. Zend Technologies, Inc.
MXML – Events (alternatively)
©All rights reserved. Zend Technologies, Inc.
ActionScript
©All rights reserved. Zend Technologies, Inc.
ActionScript
• ActionScript is what makes Flash interesting
• Strong Typing (optional)
• Object Oriented
• Embeddable in MXML or writable in standard class files
©All rights reserved. Zend Technologies, Inc.
Language Features
• Very similar syntax to Java
• Object Oriented
• Namespaced
• Variables defined with a var keyword
• Variable type definitions are done with a semi-colon
• Casting is done with an as keyword
• Event Driven - No threading
©All rights reserved. Zend Technologies, Inc.
Language Features
Variable Declaration
Type Declaration
NamespaceReturn Value Type
Variable Type Casting
Variable Type Checking
Event Based
©All rights reserved. Zend Technologies, Inc.
Remoting
©All rights reserved. Zend Technologies, Inc.
Action Message Format
• Protocol for serializing objects to/from a Flash player
• Supports strong typing of data
• Support in multiple languages
• Support for any binary transport that ActionScript supports
• Two versions AMF0
AMF3
©All rights reserved. Zend Technologies, Inc.
Zend_Amf
• A Zend Framework based component to facilitate connections to Flash
• Two mechanisms Direct Serializer
• Used for non-service endpoints (SMTP, Stomp, File System)
• Generally not what you will use
Zend_Amf_Server• Used for service-based endpoints
• Manages calls to service classes similar to MVC
• Generally what you will use
©All rights reserved. Zend Technologies, Inc.
Direct Serializer
Weird, but required
Create an object
Create the output stream
Create the serializer
Write the object
Get the output from the stream
©All rights reserved. Zend Technologies, Inc.
Reading the (PHP) serialized object
Not just for PHP!
Magic!
Regular binary data
©All rights reserved. Zend Technologies, Inc.
PHP Application
Building a Service Oriented Architecture
Service Class 1
Flash Application
Service Call 1
Service Call 3
Service Class 2Service Class 3Service Class 4
Gateway
HTTP
©All rights reserved. Zend Technologies, Inc.
A Simple Architecture
Services to expose
Document Root
Libraries and Value Objects*
*/services is not in the include_path, otherwise value objects would go there
©All rights reserved. Zend Technologies, Inc.
Integrating into your own application
• Define service classes
• Bootstrap your application
• Call Zend_Amf_Server
©All rights reserved. Zend Technologies, Inc.
Demo : Creating and binding a PHP endpoint(slides would mean endless screen shots that would result in… well… this:
©All rights reserved. Zend Technologies, Inc.
Follow us! Zend Technologies
http://twitter.com/zend
http://twitter.com/kpschrade (me!)