MACROMEDIA FLEX-GETTING STARTED WITH FLEX Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Manuais de software MACROMEDIA FLEX-GETTING STARTED WITH FLEX. Getting Started with Flex™ 3 Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 148
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes

Resumo do Conteúdo

Página 1 - Getting Started with Flex

Getting Started with Flex™ 3

Página 3

<mx:String>megan5.jpg</mx:String></mx:Array><mx:List id="ctlImage" dataProvider="{images}" selectedInde

Página 4

images don’t have to be local; they can be any URL, pointingto any server. So, the list could be a set of URLs to variousimages. And that list cou

Página 5

amazing, as you will learn as you delve more deeply into Flex.It’s also something that is easy to support as you build yourown controls.Drag-and-DropF

Página 6

Example 6-5. Dragger.mxml<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/m

Página 7 - Contents

Figure 6-6. Dragging and dropping between two listsThis will add “Bad sci-fi” to the list of things I like.I realize that this may seem like a silly e

Página 8

application that references my open/close box that I call theFlexiBox. The code for the application appears in Example 6-6.Example 6-6. States.mxml<

Página 9 - Table of Contents

</mx:State></mx:states><mx:Button id="btnChanger" label="Open" click="onChangerClick(event);" />&l

Página 10

backgroundColor="#ffdddd" borderStyle="solid" borderThickness="3" paddingBottom="5" paddingLeft="5&

Página 11 - Who Should Read This Book

]]></mx:Script><mx:states> <mx:State name="open"> <mx:SetProperty target="{this}" name="height&qu

Página 12 - How This Book Is Organized

<mx:SetProperty target="{this}" name="height" value="100" /> <mx:SetProperty target="{btnChan

Página 13 - How to Contact Us

PrefaceHow many times have you gotten an idea for a killer applicationin your mind, only to have the implementation fail when theframework you use bog

Página 14 - About the Author

the application called ffmpegx (http://homepage.mac.com/major4/) which runs on the Mac and handles all of the nasty com-mand-line stuff for me. If vid

Página 15 - Preface

I can select the movie I want to see, and then use the Play andPause buttons to start and stop the playback. It is really thiseasy to get started with

Página 16

layout="vertical"><mx:Script><![CDATA[public function updateUI() : void { btnPlay.label = ( cntlDisp.playing ) ? 'Paus

Página 17 - Installing Flex Builder 3

I also added a few effects (a rotation, glow, and drop shadow)to the video to demonstrate how you can create a more novelpresentation for the movie us

Página 18 - Having Some Image Fun

layout="vertical"><mx:Script><![CDATA[private var cues:Array = [ { start: 0.0, stop: 1.0, text:'Megan' }, { st

Página 19 - Having Some Image Fun

</mx:Canvas><mx:HBox> <mx:Button id="btnPlay" label="Pause" click="onPlay()" /> <mx:Button la

Página 21 - Having Some Image Fun

CHAPTER 7Advanced Flex ControlsAs we already discussed, Flex has a lot of great controls bakedright into it, including a chart control, an advanced gr

Página 22

copy and paste the graphing code directly into your applica-tion.Figure 7-2 shows a combination of controls that includes a U.S.map displaying financi

Página 23 - Flex in Action

Figure 7-3. A sample of ILOG Elixir’s treemap functionalityFigure 7-2. An interactive map created with a combination of ILOGElixir controlsILOG Elixir

Página 24 - 8

Google, which is your best friend when it comes to learningabout the nooks and crannies of the Flex API.How This Book Is OrganizedHere is a summary of

Página 25 - Online Applications

ILOG Elixir is not free, but if highly customizable data visual-ization is a requirement for your Flex applications it’s a loteasier to buy th

Página 26

The FlexLib ProjectThe FlexLib Project (http://flexlib.googlecode.com/) is an opensource set of containers, controls, and classes to which you arefree

Página 27 - Multimedia

between graphical elements, such as TitleWindows, using a roll-ing cube effect.He also provides movie-style effects, such as flipping and gat-ing, and

Página 28 - Plug-ins and Widgets

Figure 7-7. The SpringGraph tree visualization toolSpringGraph | 107

Página 30

CHAPTER 8Flex for WidgetsFlex 1 was primarily a server-based technology. Flex 2 allowedus to compile SWFs in Flex Builder and then deploy them. Flex3

Página 31 - Dashboards

paddingTop="0" creationComplete="flickReq.send();" backgroundAlpha="0" backgroundColor="white"

Página 32 - Desktop Applications

Once I test this in the browser, I use the Project→Export ReleaseBuild command (shown in Figure 8-1) to build the release buildof the slide show contr

Página 33 - Desktop Applications

the framework. Flash Player will download the RSL once andthen cache it for future use.To enable the RSL linking I go to the Properties dialog for the

Página 34 - What Will You Do?

Figure 8-4. Ensuring the location of the RSLFigure 8-3. Selecting RSL linkingSlide Show Widget | 113

Página 35 - Flex 101: Step by Step

Chapter 8This chapter discusses how to build small Flex movies foruse on other people’s web pages. A full working chatwidget is provided as a

Página 36 - A Flickr Viewer

Now when I export the release build, using the same mecha-nism as before, I get a slideshow.swf file that is 98 KB. That’sfar less than half the size

Página 37 - A Flickr Viewer

<![CDATA[import mx.rpc.events.ResultEvent;import mx.rpc.http.HTTPService;private function sendMessage() : void { var message:String = txtMessage

Página 38 - /2006/mxml"

</mx:columns></mx:DataGrid><mx:Form width="260"> <mx:FormItem label="User"> <mx:TextInput id

Página 39 - A Flickr Viewer

Figure 8-5. The startup chat widgetChat Widget | 117

Página 41 - A Flickr Viewer

CHAPTER 9Flex on AIRAdobe’s AIR runtime is your ticket to the world of cross-plat-form desktop application development. And the great news isthat you

Página 42

layout="horizontal” creationComplete="onMilesChange(event)"><mx:Script><![CDATA[private function onMilesChange( event:Event

Página 43 - A Flickr Viewer

text="3.1" /> </mx:FormItem> <mx:FormItem label="Weeks"> <mx:Label id="txtWeeks" />

Página 44

get that from Adobe (http://adobe.com/air), and you can linkto it on your website. Once they have AIR installed, you canuse Flex Builder to package up

Página 45 - A Flickr Viewer

CHAPTER 10Resources for Flex DevelopersIn addition to the resources I already talked about, lots of ad-ditional resources are available from which you

Página 46 - Example 3-15. Adding the VBox

O’Reilly Media, Inc.1005 Gravenstein Highway NorthSebastopol, CA 95472800-998-9938 (in the United States or Canada)707-829-0515 (international or loca

Página 47 - A Flickr Viewer

implementing Flex solutions yourself. Here’s a list of what Iconsider to be some of the best Flex blogs out there:Flex Team Blog (http://weblogs.macro

Página 48

something, the first place you will want to visit is the FlexCookbook (http://www.adobe.com/go/flex_cookbook).When you think you are ready

Página 49 - A Flickr Viewer

also an excellent resource, as is Essential ActionScript 3, whichdemonstrates use of ActionScript that will blow your mind (allthree books are publish

Página 50

IndexSymbols2D graph type, 1013D graph type, 101Aabsolute positioning (Canvascontainer), 41absolute property(Applicationcontainer), 38accordions, 55–5

Página 51 - A Flickr Viewer

Ccancel method, 27Canvas container, 41–44Cascading Style Sheets (seeCSS)chat applications, 16chat widgets, 114–116checkboxes, 50CIA World FactBook, 15

Página 52

Box class and, 39–41Herrington, Jack, 124horizontal property(Applicationcontainer), 37horizontalCenter property(Canvas container), 43HTML (HyperText M

Página 53 - Flex Controls and Layout

OObject variables, 27onFetchResult method, 110online applications, 9–11open state (mx:State), 90Outline inspector (Eclipse), 2PPanel container, 48phot

Página 54

VideoDisplay component, 95VideoDisplay control, 94Wwidgets, 12, 109–116YYourMinis portal, 13Index | 131

Página 56 - Figure 4-2. A VBox layout

This book is dedicated to my beautiful wife, Lori, and awesomedaughter, Megan. They are both the reason and the inspirationfor this book.—Jack Herring

Página 58

CHAPTER 1Installing Flex Builder 3Getting started with Flex begins with downloading the FlexBuilder 3 integrated development environment (IDE). You ca

Página 59 - Example 4-6. Photo.mxml

Once you have the software installed, launch it and you shouldsee the splash screen shown in Figure 1-1.On the splash screen you will see the words Bu

Página 60 - The Form Container

computer, rename it to myimage.jpg, and drop it into the srcfolder of your new project.Next, double-click on the MXML file for the application andadd

Página 62 - Combined Layouts

some things that are difficult to do in the browser without anycode.Our next step will be to add some dynamic behavior to theexample by adding control

Página 63 - Combined Layouts

Example 1-3. The updated image code<mx:Image id="myimg" source="@Embed('mypicture.jpg')" height="100" top

Página 65 - The Panel Container

CHAPTER 2Flex in ActionFlash has always been a great tool for adding interactivity to awebsite. But with the advent of Flex a whole new group of

Página 66 - Controls

lector in Figure 2-1. At the top of the page you can hover yourmouse pointer over each snowboard design to find out moreabout it, as well as filter th

Página 67 - Data Grids

The controls, event model, and CSS skinning in Flex make iteasy to build complex interfaces that are easy to understandand maintain at the ActionScrip

Página 68 - AdvancedDataGrid in action

Figure 2-3. SlideRocket’s editor screenSlideRocket is one of the most amazing applications I’ve seenon any platform in years. It’s well worth your tim

Página 69 - In-Place Editing

This application shows not only the functionality and elegancethat you can achieve in Flex interfaces, but also the speed ofthe Flash Player in execut

Página 70 - Grid and set it to true

(http://www.robots.com/movies.php?tag=40). Figure 2-7 showsthe RobotWorx page with the embedded custom video player.The Flex application is seamlessly

Página 71 - Tabs and Accordions

nodes more friends pop out and I get a better feel for how I amconnected to people simply by interacting with this control.Even with my sparse set of

Página 72 - Example 4-15. Accord.mxml

Getting Started with Flex™ 3Jack Herrington and Emily KimJava™ ThreadsPocket ReferenceSECOND EDITIONScott Guelich, Shishir Gundavaramand Gunther Birzn

Página 73 - Tabs and Accordions

Figure 2-9. The YourMinis portal built into FlexYou can have multiple pages in your portal. And you can evenplace a YourMinis widget on any regu

Página 74 - Example 4-16. Menu.mxml

standalone piece. This makes YourMinis not only a great por-tal, but also a great place to build widgets that can go anywhere.DashboardsControlling a

Página 75 - Menus

U.S. government profiles of countries and territories aroundthe world. This is shown in Figure 2-11.Figure 2-11. The CIA World FactBook viewerThis sho

Página 76 - Divider Boxes

Figure 2-12. The Pownce chat clientI can tell you from experience that building this type of chatapplication in Ajax is a real hassle. Cross-domain se

Página 77 - CSS

Figure 2-13. The eBay Desktop applicationFrom here, you can browse what is available for sale, bid onitems, watch your auctions, and so on. And it eve

Página 78 - Example 4-19. CSS.mxml

CHAPTER 3Flex 101: Step by StepThis chapter will walk you step by step through the process ofconstructing a Flex application. That starts with learnin

Página 79 - Skinning

Flex Builder is actually a bit more useful than this in that itreally manages projects, which are sets of Flex applications andcomponents, as well as

Página 80 - Figure 4-20 shows the result

1. In the Flex Builder IDE, select File→New→Flex Projectand name the project FlickrRIA.2. Accept the default location for the project and confirmthat

Página 81 - Filters and Effects

Example 3-1. The Application tag<mx:Application xmlns:mx="http://www.adobe.com /2006/mxml" backgroundGradientColors="[0xFFFFFF,

Página 82 - Example 4-22. Effect.mxml

Figure 3-4. The search label5. Drag the TextInput component from the Controls fold-er to the position following the Label component in theHBox. The Te

Página 83 - Working with the Server

Getting Started with Flex™ 3by Jack Herrington and Emily KimCopyright © 2008 Jack Herrington and Emily Kim. All rights reserved.Printed in Canada.Publ

Página 84

dler(event). The photoHandler event packages the serv-ice results. We will create the {{photoHandler}} functionlater.Example 3-2 shows the relevant co

Página 85 - Example 5-1. Form.mxml

that the HTTPService generates. You can see this in Ex-ample 3-5.Example 3-5. The second import statement<mx:Script><![CDATA[ import mx.co

Página 86 - Using the HTTPService Tag

Figure 3-6. The Button component in the Outline view2. To the Button component, add a click attribute with avalue of requestPhotos():<mx:Button lab

Página 87

5. In the function, cancel any previous requests to photoService by using the cancel method. The instance nameof the HTTPService component is photoSer

Página 88

vice call. At this point, your code should look like Ex-ample 3-9.Example 3-9. The complete script block<mx:Script><![CDATA[ import mx.col

Página 89

params.tags = searchTerms.text; photoService.send(params); } private function photoHandler(event:ResultEvent) :void{

Página 90

Example 3-13. The itemRenderer attribute<mx:TileList width="100%" height="100%" dataProvider="{photoFeed}">

Página 91 - The Server Code in ColdFusion

attribute with a value of 75. The itemRenderer passesvalues to the Image component through the Image com-ponent’s data property. Add a sou

Página 92 - Example 5-7

</mx:itemRenderer></mx:TileList>8. Save and then run the application. You should see aform. In the form, submit a search term

Página 93 - Going on from Here

"off” horizontalAlign="center"> <mx:Image width="75" height="75" source="{dat

Página 94

Adobe Developer Library, a copublishing partnershipbetween O’Reilly Media Inc., and Adobe Systems, Inc., is theauthoritative resource for developers u

Página 95 - More Flex Applications

var params:Object = new Object(); params.format = 'rss_200_enc'; params.tags = searchTerms.tex

Página 96

As you can see from this example, it is very easy to access webservices from Flex. It’s also easy to parse their contents usingthe E4X syntax built di

Página 98

CHAPTER 4Flex Controls and LayoutThe first step in building a Flex application is to create the userinterface. Flex not only has a rich set of control

Página 99 - A Simple Image Viewer

absoluteDoes no automatic layout, and requires you to explicitlydefine the location of each child componentIf the Application component’s layout pro

Página 100

The Box ClassThe Box class is the base class for the VBox and HBox classes:• The VBox container renders all child display objects verti-cally.• The HB

Página 101 - A Simple Image Viewer

Figure 4-2. A VBox layoutExample 4-3 shows the default layout method used by theHBox container (horizontal).Example 4-3. Using the HBox contai

Página 102 - Drag-and-Drop

strating that container controls can have other containers aschildren.Example 4-4. Using both the VBox and the HBox containers<?xml version="1

Página 103 - Drag-and-Drop

Example 4-5 is some sample code for an absolutely positionedlayout.Example 4-5. An absolutely positioned layout<?xml version="1.0" encodi

Página 104 - States and Transitions

application window. The container’s layout property must beset to absolute. All constraints are set relative to the edges ofthe container, not to othe

Página 106 - Example 6-9. FlexiBox2.mxml

</mx:Canvas> </mx:HDividedBox></mx:Application>When you launch this application you should see somethingsimilar to Figure 4-6.You

Página 107 - States and Transitions

• One or more child controls or containers, such as inputcontrolsYou can also insert other types of components into a Form con-tainer.The code in Exam

Página 108 - Figure 6-8. The open state

Figure 4-7. A form-based layoutCombined LayoutsContainers can hold other containers. You can nest them tocreate sophisticated layouts, and you can cre

Página 109 - A Simple Video Viewer

top="30" /> <mx:Label text="Photographed by Elsie Weil" horizontalCenter="0" top="250" />

Página 110 - Example 6-10. Movies.mxml

Figure 4-8 shows the result of Example 4-8.Figure 4-8. A complex layout using various types of layoutmechanismsThe Panel ContainerThe Panel c

Página 111 - Creating Better Movies

backgroundGradientColors="[#FFFFFF, #000000]"> <mx:Panel title="Featured Photograph" backgroundAlpha=".25" borde

Página 112

ControlsSo many controls are available for you to use with Flex that it’salmost hard to know where to begin. I suppose the best placeto start is wi

Página 113 - Creating Better Movies

Data GridsWe regularly have to build tables of structured information.This is easy in Flex, thanks to two controls: the DataGrid andthe AdvancedDataGr

Página 114

... </mx:XMLList> <mx:DataGrid width="100%" height="100%" dataProvider= "{employees}"> <mx:columns&g

Página 115 - Creating Better Movies

Example 4-12. Advgrid.mxml<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/

Página 116

ContentsPreface xiChapter 1: Installing Flex Builder 3 1Installing the IDE 1Having Some Image Fun 2Chapter 2: Flex in Action 7E-Commerce 7Online App

Página 117 - Advanced Flex Controls

<customer><first>Jack</first> <last>Herrington</last></customer> <customer><first>Lori</f

Página 118

Tabs and AccordionsSometimes you have more content than you can reasonably fiton the screen, so you need some way to let the user navigatearound group

Página 119 - ILOG Elixir

<mx:VBox label="Tab Three"> <mx:Label text="Tab three's content" /> </mx:VBox> </mx:TabNavigato

Página 120 - Advanced Flash Components

<mx:VBox label="Tab One"> <mx:Label text="Tab one's content" /> </mx:VBox> <mx:VBox label=&qu

Página 121 - Distortion Effects

MenusFlex also has support for menus, including those that appearat the top of the window as well as pop-up menus. Exam-ple 4-16 shows how

Página 122 - SpringGraph

Figure 4-16. An example menuThere is also a handy control called ApplicationControlBarthat gives a nice-looking control set along the top of the

Página 123 - SpringGraph

Figure 4-17. An application control barOne thing I love about Flex is that even by default, it looksreally good. I’m not a graphic designer by any str

Página 124

<mx:HDividedBox width="100%" height="100%"><mx:HBox backgroundColor="#ff9999" width="50%" height=&quo

Página 125 - Flex for Widgets

Example 4-19. CSS.mxml<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml

Página 126

SkinningFlex also allows you to change the look of your whole appli-cation in a process called skinning. You can use CSS to applynew skins to your Fle

Página 127 - Slide Show Widget

The Form Container 44Combined Layouts46The Panel Container 48Controls 50Data Grids 51Tabs and Accordions 55Menus 58Divider Boxes 60CSS 61Filters and E

Página 128

<mx:Panel title="Subscription form" paddingTop="20"> <mx:Form> <mx:FormItem label="First Name">

Página 129 - Slide Show Widget

Filters and EffectsFlex supports a wide variety of filters and effects that you canapply to any user interface object. Take, for example, how easyit i

Página 130 - Chat Widget

You can also apply filters based on certain events, such as roll-overs, to provide interactive effects. Example 4-22 shows abutton that glows

Página 131 - Chat Widget

CHAPTER 5Working with the ServerMost Flex applications are going to work with a web server insome shape or form. Thankfully, Flex makes this very easy

Página 132

Remote objectsFlex applications can also make use of Flash’s remotingcapabilities by using remote objects. To make this happenthe server code needs to

Página 133 - Chat Widget

POSTing to the Server with FlexIn this example, I’ll post a simple subscription form to theserver. The Flex code for the interface appears i

Página 134

Example 5-2. Formtest.php<?phpecho( "Thanks ".$_REQUEST['first'] );?>When I run this example in Flex Builder it starts up wi

Página 135 - Flex on AIR

a shipping weight, such as 3, into the text boxes and click theGet Shipping Options button to retrieve and display the plaintext data in a text box (s

Página 136 - 120

The Flex application, which is running on the customer’s com-puter, uses the HTTPService tag to talk directly to the web serv-er. The code on the web

Página 137

<![CDATA[ import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.controls.Alert; public function handlePlain(event

Página 138 - 122

Chat Widget 114Chapter 9: Flex on AIR 119Creating an AIR Version of the Runner’s Calculator 119Chapter 10: Resources for Flex Developers 123Flex Webs

Página 139 - Resources for Flex Developers

Example 5-4. The XML version of the Flex application<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="

Página 140 - The Flex Cookbook

<mx:Button x="130" y="95" label="Get Shipping Options" click="xmlRPC.send();" width="160" hei

Página 141 - Community Resources

Example 5-6. XmlHttpService.cfm<cfsetting enablecfoutputonly="true" /><cfsilent> <cfinvoke component="Shipping"

Página 142

<cffunction name="getShippingOptions_CFQuery" access= "remote" returntype="query"> <cfargument

Página 144

CHAPTER 6More Flex ApplicationsThis chapter will show some sample Flex applications to dem-onstrate various aspects of Flex development. You can

Página 145

while( mile < miles ) { weeks += 1; mile *= 1.1; } txtWeeks.text = weeks.toString();}]]></mx:Script> <mx:Form> <mx:FormIte

Página 146

Example 6-2. Runner2.mxml<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/m

Página 147 - Index

<mx:Script><![CDATA[private function onMilesChange( event:Event ) : void { var miles:Number = parseFloat( txtMiles.text ); var mile:Number =

Página 148

Figure 6-3. The calculator with the week tableNow I can build my training calendar using this handy tool. Ofcourse, I can put an application such as t

Comentários a estes Manuais

Sem comentários