30
© All rights reserved. Zend Technologies, Inc . Building mobile and tablet applications in Flex and PHP with Flash Builder for PHP Kevin Schroeder Zend Technologies

Flex for php developers

Embed Size (px)

Citation preview

Page 1: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Building mobile and tablet applications in Flex and PHP with Flash Builder for PHPKevin Schroeder

Zend Technologies

Page 2: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

About Kevin

Past: Programming/Sys Admin

Current: Technology Evangelist/Author/Composer

@kpschrade

Page 3: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Page 4: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Agenda

• The basics

• Creating a project

• Working with MXML

• Working with ActionScript

• Connecting to PHP

Page 5: Flex for php developers

©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

Page 6: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Flash/Flex Projects

Page 7: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Creating a project ( w/ PHP )

Connects the projects

Page 8: Flex for php developers

©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

Page 9: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML

Page 10: Flex for php developers

©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

Page 11: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML Example

XML Namespace declaration for Spark Components

XML Namespace declaration for Flex (non-visual, generally)

Page 12: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML – Adding a component

Choosing from a list of Spark Components

Page 13: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML – Creating Flex Elements

Defining local data container

Defining local ActionScript container

Page 14: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML – Binding Static Data

Declared a data source

Accessed the data source

Page 15: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML - Events

Defining the event

Event callback

Page 16: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

MXML – Events (alternatively)

Page 17: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

ActionScript

Page 18: Flex for php developers

©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

Page 19: Flex for php developers

©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

Page 20: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Language Features

Variable Declaration

Type Declaration

NamespaceReturn Value Type

Variable Type Casting

Variable Type Checking

Event Based

Page 21: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Remoting

Page 22: Flex for php developers

©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

Page 23: Flex for php developers

©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

Page 24: Flex for php developers

©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

Page 25: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Reading the (PHP) serialized object

Not just for PHP!

Magic!

Regular binary data

Page 26: Flex for php developers

©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

Page 27: Flex for php developers

©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

Page 28: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Integrating into your own application

• Define service classes

• Bootstrap your application

• Call Zend_Amf_Server

Page 29: Flex for php developers

©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:

Page 30: Flex for php developers

©All rights reserved. Zend Technologies, Inc.

Follow us! Zend Technologies

http://twitter.com/zend

http://twitter.com/kpschrade (me!)