30 June 2011
The steps in the tutorial are designed to get you up to speed on working with the Project panel, whether you're an experienced developer or brand new to Flash. Previous experience programming with ActionScript is required if you wish to extend the supplied templates beyond the scope of this article.
Intermediate
The best way to avoid web development projects that become disorganized, cluttered, and downright confusing is to take advantage of the project management tools available in your development environment. The Project panel in Adobe Flash Professional can help you manage your projects and publish multiple files within a single project. It's a great way to visualize your Flash projects and move quickly between files and folders as you work.
By using the Project panel and following best practices for asset organization, you'll be able to quickly launch and maintain projects—saving production time and making it easier to deliver the final product. The Project panel helps you do the following:
The Project panel has been updated in Flash Professional CS5.5 to include better development workflows using shared assets and a standard project format, as well as to optimize integration with Adobe Flash Builder 4.5.
Follow this tutorial to create a slideshow sample project. You'll learn how to use the Project panel as you set up your project using shared assets and then publish the slideshow to three different platforms to deploy for web, desktop, and mobile (see Figure 1). Use the provided slideshow asset files to build the completed project.
You'll learn the project development workflow and how to leverage the new author-time shared assets feature. Along the way, you'll become familiar with the structure of the FLA file as you build the project, so that you can edit the artwork assets. You can use the provided sample files to build and review a fully functional slideshow application, analyze the project structure and (if desired) update the template using your own image files to customize it.
Before you get started, you may find it helpful to read the section titled Create projects in the Flash Professional Help documentation and watch Improved project workflows on Adobe TV. To get a detailed overview of the improved Project panel, check out Tareq AlJaber's article, Sharing projects between Flash Professional and Flash Builder, which covers the details of working with Flash Professional CS5.5 and Flash Builder 4.5.
Before you begin building the sample project, let's review the provided assets in the sample files folder to get an overview of the workflow you'll use to create and manage Flash projects.
The supplied slideshow assets create a simple image viewer including a display area with transitions, a play button, a caption bar, back and forward buttons, and a full-screen button (see Figure 2).
The display area is the heart of the slideshow powered by the PhotoGallery component. The PhotoGallery is designed as a dynamic widget that loads a list of images from an external source. An XML file supplies the names and captions for the images, which allows you to change the list without updating the SWF file (see Figure 3).
The primary objective in this tutorial is to create variations of the supplied slideshow elements using a Flash project and the author-time shared assets feature.
Building a Flash project is easy to do. You usually start by creating a project folder and a strategy for structuring files and folders within it. From there, you gather the artwork and assets you'll need before moving to Flash.
Here's an overview of the steps you'll follow in this tutorial:
The following sections describe each of these steps and walk you through the workflow.
The provided sample files contain the slideshow assets as well as some sample images to work with. Use these files to follow the tutorial and jump right into building a Flash project.
Follow these steps to set up the sample files:
Tip: If you plan on working with a lot of different projects for many different clients, it can be useful to create a "work" folder where you can store multiple project folders. Doing so makes your projects easy to find and you can use the Flash Player Global Security Settings panel to set the folder as a trusted location, which helps to avoid security errors during local development.
The easiest way to create a project is to create a quick project from a FLA file open in Flash. The FLA's folder becomes the project folder and the FLA becomes the default file selected for publishing.
Follow these steps to create your Flash project:
That's it! You've created the Flash project. Take a moment to explore the project (see Figure 5). Notice that Flash automatically created the AuthortimeSharedAssets.fla file. You'll use this FLA to store shared assets in the next steps.
The project includes two folders along with the FLA files: assets and src. The assets folder contains the images and XML file which describes them. The src folder contains ActionScript script files which provide functionality to the slide show assets. For the purposes of this tutorial, you don't need to edit any of the code in the src folder, but you can browse and open the files using the Project panel if you're curious and want to learn how the code controls the behavior of the slideshow.
The default configuration of the Project panel doesn't display image file types in the view.
Follow these steps to add the JPEG file type filter:
At this point, you can see all the project asset files listed in the Project panel.
One of the improvements of the Flash CS5.5 Project panel is the ability to use author-time shared symbols across FLA files in the project. This opens up new work flows for defining common assets which update across files any time a change is made. In the next steps you'll convert the supplied files into shared assets which can be used to create slide shows of different sizes.
Follow these steps to convert the slide show assets to shared symbols:
At this point, you can use the shared assets to define any number of file variations.
Another new feature in Flash CS5.5 is the improved workflow for publishing Flash content to mobile and desktop formats. To understand how this works, you'll set up a slideshow to run in an AIR for Android FLA file.
Follow these steps to create the FLA:
Notice that the new FLA is added to the Project panel and opened in the Flash workspace. Choosing the AIR for Android option automatically configures the Stage size (480 x 800) and the player settings for the file.
Follow these steps to add the author-time shared assets:
At this point, both the SlideShow.fla file and the SlideShowMobile.fla file are linked to the shared content in the AuthortimeSharedAssets.fla file.
Author-time shared assets simplify the process of editing content that repeats across files. For example, if you create a series of banners that reuse common graphic elements, you can easily edit those common elements from a single file. When you update any file, all the other files linked to that shared symbol update automatically.
Follow these steps to change the colors of the controls across files:
Tip: If you check the other FLA files and don't see the shared assets updates, you probably didn't save the edited file when you made the changes. Saving the file after edits is the operation that updates the linked files.
The Android file is intended for playback on a mobile device which uses touch and gesture events for user interaction instead of mouse events. That means you'll need to rework the ActionScript code in the sample files to accommodate the characteristics of the device. To do this, you'll create a new ActionScript file and assign it as the document class of the FLA.
You have two options at this point: You could use the Project panel to create an ActionScript file which you can edit in Flash Professional, or you can open the Flash project in Flash Builder and use the Flash Builder text editor to create and edit the file. The following sections describe both approaches.
Follow these steps to create an ActionScript file in Flash Professional:
You'll add the ActionScript to the file in a moment, but first take a moment to review how you would create the file if you want to work with the project in Flash Builder.
Follow these steps to open the project in Flash Builder for editing:
Note: Flash Professional CS5.5 and Flash Builder 4.5 share the same project structure, enabling you to combine workflows more smoothly than before. This means that you can open a Flash Professional project in Flash Builder, and vice versa, interchangeably and seamlessly.
Whichever route and editor you prefer to use, the next step involves updating the file with the ActionScript code below and assigning it as the document class of the FLA file.
Follow these steps to complete the file:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.events.Event;
import flash.events.TransformGestureEvent;
import flash.events.MouseEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import src.gallery.Photo;
import src.gallery.PhotoGallery;
public class SlideShowMobile extends MovieClip
{
//********************
// Properties:
public var slideShowDataURL:String = "assets/images.xml";
public var slideShowDelay:uint = 6000;
//********************
// Initialization:
public function SlideShowMobile()
{
// Configure the Multitouch object for gesture input
Multitouch.inputMode = MultitouchInputMode.GESTURE;
// Configure slide show
slideShow_mc.slideShowDelay = slideShowDelay;
slideShow_mc.scaleMode = Photo.SCALEMODE_ZOOM;
slideShow_mc.transition = slideShow_mc.transitions["iris"];
slideShow_mc.addEventListener(Event.COMPLETE, onDataLoaded);
slideShow_mc.addEventListener(Event.CHANGE, onImageChanged);
slideShow_mc.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
slideShow_mc.maxWidth = 480;
slideShow_mc.maxHeight = 759;
slideShow_mc.loadXML(slideShowDataURL);
// Configure buttons
playPause_btn.initialize(clickHandler, true, true);
prev_btn.initialize(clickHandler, false);
next_btn.initialize(clickHandler, false);
fullScreen_btn.initialize(clickHandler, false);
}
//********************
// Events:
protected function clickHandler(event:MouseEvent):void
{
// Route button clicks
switch( event.target )
{
case playPause_btn:
if( slideShow_mc.isPlaying ) {
timer_mc.stopTimer();
}else{
timer_mc.resetTimer();
}
slideShow_mc.playSlideShow(!slideShow_mc.isPlaying);
break;
case prev_btn:
slideShow_mc.back();
break;
case next_btn:
slideShow_mc.forward();
break;
case fullScreen_btn:
toggleFullScreen();
break;
}
}
protected function onDataLoaded(event:Event):void
{
slideShow_mc.playSlideShow(true);
}
protected function onImageChanged(event:Event):void
{
var str:String = slideShow_mc.selectedPhoto.id+" of "+
slideShow_mc.selectedPhoto.total+": "+
slideShow_mc.selectedPhoto.caption;
captions_mc.maxChars = 44;
captions_mc.setText(str);
if( slideShow_mc.isPlaying ){
timer_mc.startTimer(slideShowDelay);
}
}
protected function onSwipe( event:TransformGestureEvent ):void
{
if( event.offsetX == 1 ){
// Swiped towards right
slideShow_mc.forward();
}
else if( event.offsetX == -1 ){
// Swiped towards left
slideShow_mc.back();
}
}
//********************
// Methods:
function toggleFullScreen():void
{
if( stage.displayState == StageDisplayState.NORMAL ){
stage.displayState = StageDisplayState.FULL_SCREEN;
}else{
stage.displayState = StageDisplayState.NORMAL;
}
}
}
}
SlideShowMobile.as is configured slightly differently than the supplied SlideShow.as file. It includes additional code that responds to gesture swipes on a device. This allows you to swipe left to see the previous picture or swipe right to see the next picture in the slideshow.
At this point, your project is ready to publish.
You can publish one or more FLA files from the project at a time using the Test Project button on the Project panel. In the next steps you'll publish the original SlideShow.fla file for the web, convert its settings to publish it to the desktop, and set up the Android file to publish to mobile format.
To publish the SlideShow.fla to web format, open the SlideShow.fla file in Flash Professional and click the Test Project button in the Project panel. The SWF plays and the related HTML file is automatically added to the project.
Notice that the web published files include the SlideShow.html file, the SlideShow.swf file, and the files in the assets folder. To display the slideshow on the web, upload all of these files to a server.
Follow these steps to publish the SlideShow.fla to a desktop format:
Notice that the published files are encapsulated in the SlideShow.air file. This is an installer file which will install the slideshow as a desktop application for the user.
Follow these steps to publish the SlideShowMobile.fla file to a mobile format:
Notice that the published files are encapsulated in the SlideShowMobile.apk. This is an installer file that you can upload to the Android market.
Another exciting feature in Flash Professional CS5.5 is the ability to preview and debug Android applications on an Android device plugged into your computer via USB.
Follow these steps to preview the SlideShowMobile app on an Android device:
To get more instructions on publishing for mobile, check out this Adobe TV video by Paul Trani demonstrating the Android publishing process: Publishing an AIR for Android app.
Packaging your application for Google Android, Apple iOS, or BlackBerry Tablet OS devices involves acquiring signing certificates and provisioning application packages for the various platforms. For more specifics, read the following tutorials (written for ActionScript and Flex developers but applicable to Flash Profesional developers as well):
Practice using author-time shared assets and working with the Project panel to port a single application to multiple platforms. As a next step, try working with the iOS mobile platforms and the extended ActionScript APIs for touch and gesture devices.
See the following resources for more information on using the Project panel in Flash Professional CS5.5 and author-time shared assets:
Also check out the following links for details on working with AIR and mobile apps in Flash Professional:
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.
| 04/23/2012 | Auto-Save and Auto-Recovery |
|---|---|
| 04/23/2012 | Open hyperlinks in new window/tab/pop-up ? |
| 04/21/2012 | PNG transparencies glitched |
| 04/01/2010 | Workaround for JSFL shape selection bug? |
| 02/13/2012 | Randomize an array |
|---|---|
| 02/11/2012 | How to create a Facebook fan page with Flash |
| 02/08/2012 | Digital Clock |
| 01/18/2012 | Recording webcam video & audio in a flv file on local drive |