|
Projects consist of resources (folders and files) that
you can manage from the Package Explorer. Projects are contained
within a workspace. The Package Explorer provides a logical representation
of the workspace in the file system. The Package Explorer is refreshed
each time you add, delete, or modify a resource.
You can also edit project resources directly in the file system,
bypassing Flash Builder and the Package Explorer.
Create or delete files and folders in a projectAn application in Flex typically consists of an MXML application
file, one or more views (mobile projects only), and one or more
standard Flex components. You can also have one or more custom components
defined in separate MXML, ActionScript, or Flash component (SWC)
files. By dividing the application into manageable chunks, you can
write and test each component independently from the others. You
can also reuse a component in the same application or in other applications,
which increases efficiency.
You can use Flash Builder to build custom MXML and ActionScript
components and then insert them into your applications. For information
on building ActionScript components, see Create an ActionScript class.
You can also build an MXML component directly using code.
Create files and folders in a projectIn the Package Explorer, select File >
New > File.
If you have multiple projects in your workspace, select the
project to which you want to add the file.
Enter the filename and click Finish.
You can also add folders and files that are located outside the
current project; for more information, see Link to resources outside the project workspace.
You can add folders to your project as needed. For example, you
can create a folder to store all of your data models. Or, you can
organize all the assets that make up the visual design of your application.
In Package Explorer select File > New >
Folder.
If you have multiple projects in your workspace, select the
project to add to the stand-alone folder.
If you create the
folder in the source path folder, it is treated like a package name.
You can then place source files inside that folder, which the compiler recognizes.
If
you create the folder outside the source path folder, you can later
make it the root of a package structure by adding it to your source
path. After you complete this procedure, select Project >
Properties and then select Flex Build Path. Click Add Folder and
navigate to the newly created folder.
Enter the folder name and click Finish.
Delete folders and filesDeleting
folders and files from your project removes them from the workspace and,
therefore, from the file system.
Note: If you delete a linked resource, you delete
only the link from your project, not the resource itself (see Link to resources outside the project workspace). However, if you’ve
linked to a folder and you delete any of the files in it, they are
removed from the file system.
In the Package Explorer, select the resource to delete.
Select Edit > Delete or press the Delete key,
and click Yes.
The resource is deleted from the file system.
Create MXML application filesIn the Package Explorer, select the project to
which you want to add the MXML application file.
From the Package Explorer context menu, select New >
MXML Application.
The application file is created in the src folder, by default.
You can select a different folder within the project, if necessary.
Specify a name for the application file, and select a Spark
Layout, if necessary. For more information about Spark Layouts,
see About Spark layouts.
The following apply only for mobile projects:
Specify an application ID.
Specify the application template.
See Choose an application template.
Specify the mobile application permissions for the Google
Android platform.
See Choose mobile application permissions.
Specify the platform settings.
See Choose platform settings
Specify the application settings.
See Choose application settings.
Click Finish.
Create an ActionScript fileYou can use a wizard in Flash Builder to quickly create
an ActionScript file for your Flex and ActionScript projects. Select File > New > ActionScript File.
Select a package name for your ActionScript file. If you
don't specify a package, the default package is selected. If you
specify a package folder that does not exist, the wizard creates
it.
Name the ActionScript file.
Click Finish.
Create an ActionScript classYou can use a wizard in Flash Builder to quickly create
ActionScript classes for your Flex and ActionScript projects. The
wizard also provides an easy way to generate stubs for functions
that must be implemented.
Select File > New > ActionScript
Class.
Specify the basic properties of your new class in the dialog
box, and then click Finish.
After clicking Finish, Flash Builder
saves the file in the specified package and opens it in the code
editor.
Write the definition of your ActionScript class.
For
more information, see Create simple visual components in ActionScript.
Create an ActionScript interfaceYou can use a wizard in Flash Builder to quickly create
ActionScript interfaces for your Flex and ActionScript projects.
An interface is a collection of constants and methods that
different classes can share.
Select File > New > ActionScript
Interface.
Specify the basic properties of your new interface in the
dialog box, and then click Finish.
Add any constants or methods to your ActionScript interface
that different classes share.
Create an ActionScript skinnable componentYou can use a wizard in Flash Builder to quickly create
ActionScript components for your Flex projects. Select
File > New > ActionScript Skinnable Component.
Specify the basic properties of your new skinnable component,
and then click Finish.
Flash Builder creates an ActionScript
class that extends from the base component or the skinnable component.
By default, the base component is spark.components.supportClasses.SkinnableComponent.
You can, however, change the base component to any other component
that is a subclass of the skinnable component.
You can also
add any ActionScript interfaces that the new skinnable component
can implement. For more information on creating ActionScript interfaces,
see Create an ActionScript interface.
The SkinnableComponent is
created in the selected location and package. A reference to the
component is added automatically, by default, in the main MXML file.
Using ActionScript WorkersFlash Builder supports multi-thread ActionScript programing
by letting you run an ActionScript program as a worker. A worker
runs in parallel to the main ActionScript program, and can communicate
with the main ActionScript program and other ActionScript workers.
ActionScript workers let you create more responsive games and
applications by offloading tasks and computations to the background
workers. The workers run concurrently, making your game-play more
responsive. To understand more about ActionScript workers, see Using workers for concurrency.
For a video on creating and using ActionScript workers, see this
video by Adobe Evangelist Lee Brimelow.
Create an ActionScript workerYou can use a wizard in Flash Builder to create an ActionScript
worker for your Flex and ActionScript projects by following these
steps:
Select File > New > ActionScript Worker.
Specify a package name for your ActionScript worker. If you
don't specify a package, the class is declared in the default package.
If you specify a package folder that does not exist, the wizard
creates it.
Name the ActionScript worker file.
An ActionScript worker extends from the flash.display.Sprite class by
default. So, you can select only those classes that extend from
Sprite.
Add any interface that contains constants and methods that
you want to use in your ActionScript worker.
Specify any of the following code generation options:
- Generate Constructor from Superclass
- Generates a constructor with a super() call. If the superclass
constructor takes arguments, the arguments are included in the generated
constructor and passed up in the super() call.
- Generate Functions Inherited from Interfaces
- Generates function stubs for each interface method. The stubs
include a return statement that returns null (or 0 or false for
primitive types) so that the stubs compile.
- Generate Comments
- Inserts a "//TODO: implement function" in
the generated functions or constructors.
Specify the ActionScript worker usage. For more information,
see Specify ActionScript worker usage.
Click Finish to save the worker (.as filename extension)
in the specified package and open it in the code editor.
Write the code for your ActionScript worker.
Flash
Builder provides ActionScript worker code templates that let you
quickly add code for a worker file. For more information on using
code templates, see Code templates.
To convert an existing ActionScript class into a worker, follow
these steps:
In the Package Explorer, select the ActionScript class
that you want to convert into an ActionScript worker.
From the Package Explorer context menu, select Set As ActionScript
Worker.
Whenever you create an ActionScript worker, the worker file is
added to the list of ActionScript workers in the Project Properties
dialog box.
Specify ActionScript worker usageWhen you create an ActionScript worker, edit the worker,
or convert an ActionScript class to a worker, you can specify the
worker usage.
You can choose to embed the worker or load it externally by selecting
one of the following options:
- Embedded Worker
- Generates a SWF file for the ActionScript worker class that you
want to embed. The SWF file is generated in the "workerswfs" folder
of your project, instead of a user-selected output folder.
When
you choose to embed a worker, Flash Builder generates a class named Workers.as.
The generated class contains code to embed the SWF file and also create
a getter method. You can use the getter method to access the ByteArray class
of the embedded ActionScript worker.
Important: You
should not modify the contents of automatically generated class.
For
example, if you create an embedded ActionScript worker called “MyWorker”, code
like the following is generated: public class Workers
{
[Embed(source="../workerswfs/MyWorker.swf", mimeType="application/octet-stream")]
private static var MyWorker_ByteClass:Class;
public static function get MyWorker():ByteArray
{
return new MyWorker_ByteClass();
}
}
Whenever you add, rename, move, or delete an
ActionScript worker, Flash Builder modifies the generated code in
the Workers.as file.
If a file named Workers.as exists in
the project, Flash Builder generates the class with these filenames
in the specified order: WorkersManager.as
WorkersHolder.as
If files with all these
names exist, then Flash Builder generates the class with a unique
filename by appending numbers to these filenames sequentially. For example,
Workers1.as, WorkersManager1.as, WorkersHolder1.as, Workers2.as, and
so on. You can choose to rename these files if you want; Flash Builder remembers
and uses the new filename to generate code.
When you run or
debug the project containing an embedded ActionScript worker, the
"workerswfs" folder contains the debug SWF files. When you export
a release build, the release SWF files overwrite the debug SWF files
in the "workerswfs" folder.
- Externally Loaded Worker
- Generates the SWF file for the ActionScript worker class
in a user-selected output folder.
When you run or debug a
project with an externally loaded ActionScript worker, the debug
SWF files are generated in the "bin-debug" folder and the release
SWF files in the "release" folder.
Manage ActionScript worker filesThe project’s Properties dialog box lets you manage the
worker files in your ActionScript or Flex project.
In the Package Explorer, select a project.
Select Project > Properties from the main menu or select
Properties from the context menu. The project’s Properties dialog
box appears.
In the left pane, select ActionScript Workers.
Add, edit, or remove worker files as needed, and click OK.
Add an ActionScript worker or convert an ActionScript class to a workerFlash Builder provides you with an option to convert an
ActionScript class in your project to a worker.
Go to the project’s Properties dialog box and select
ActionScript Workers.
Click Add.
Click Browse to select the class that you want to set as
an ActionScript worker. Flash Builder displays only those classes
that extend from Sprite and Public classes.
Specify the worker usage. For more information, see Specify ActionScript worker usage.
Alternatively, you can also use the context menu for a project
in the Package Explorer, select Set As ActionScript Worker, and
specify the worker usage preference.
Search for resources in the workbenchFlash
Builder provides a search tool that lets you quickly locate resources.
To search the document that is currently open in the editor,
do the following
Open the document to search.
Do either of the following:
Enter
the text string to locate.
(Optional) Enter the replacement text string.
(Optional) Set the advanced search criteria.
Click
Find, Replace, Replace All, or Replace/Find.
If the text
string is located in the document, it is highlighted and, optionally, replaced.
Note: To do an incremental find, press Control+J (Windows)
or Command+J (Mac OS).
To search all resources in the workspace, Flash Builder includes
advanced search features that are more powerful than find and replace.
Flash Builder lets you find and mark references or declarations
to identifiers in ActionScript and MXML files, projects, or workspaces.
For more information, see Find references and refactor code.
Search for files Select Search > Search to conduct
complex searches for files.
Note: Click Customize to define what kinds of search
tabs are available in the Search dialog box.
Use the Search viewThe Search
view displays the results of your search.
Open a file from the list Double-click
the file.
Remove a file from the list Select
the file to remove and click Remove Selected Matches.
Remove all files from the list Click Remove All Matches.
Navigate between matched files Click Show Next Match or Show Previous Match.
View previous searches Click the
Down Arrow next to Show Previous Searches and select a search from the
pull-down list.
Return to the Search view after closing itSelect Window > Show View > Other.
Expand the General category, select Search, and click OK.
Link to resources outside the project workspaceYou can create links to resources outside
the project and workspace location. You can link to folders and
files anywhere on the file system. This option is useful when you
have resources that are shared between your projects. For example, you
can share a library of custom Flex components or ActionScript files
among many different Flex projects.
Folders that contain linked resources are marked in the Package
Explorer (as the following example shows), so that you can distinguish
between normal and linked resources.
Other examples for linking resources include a folder of image
file assets, or situations when the output folder is not in the
project root folder.
When you work with shared resources, the changes you make to
the source folders and files affect all of the projects that are
linked to them. Be cautious when you delete linked resources from
your projects. In some cases you merely delete the link reference,
and in others you delete the source itself. For more information,
see Delete folders and files.
Note: A best practice is to link other projects to
your Library Project. Linked resources are encouraged only for third-party
libraries with a SWC file.
Link to resources outside the project workspaceIn the Package Explorer, select the project to add linked
resources to.
Select File > New > Folder (or File).
Select the project or project folder to add the linked resources
to.
Enter the folder or filename. The folder or filename you
enter can be different from the name of the folder or file you are
linking to.
Click the Advanced button.
Select Link to folder in the file system. Enter or browse
to the resource location.
Click Finish to link the resource to your project.
Use a path variable to link to resourcesRather than linking
to resources by entering the full path to the local or network folder
where you store your files, you can define path variables. For more
information, see Create a path variable.
In the Package Explorer, select the project to add linked
resources to.
 Path variables can also be
used in certain project settings, such as the library path and source
path.
Select File > New > Folder (or File
if you want to add files).
Select the project or project folder to add the linked resources
to.
Click the Advanced button to display the advanced options.
Select Link to folder in the file system. Click the Variables
button.
Select a defined path variable, or click New to create a
path variable.
If you selected a defined path variable, skip
to step 9. If you clicked New, you’ll see the New Variable dialog
box.
Enter the path variable name and enter or browse to the file
or folder location.
Click OK to create the path variable.
Select the new path variable in the Select Path Variable
dialog box and click OK.
Click Finish to complete the link to the resource.
 You can also define and manage path variables
by using the Flash Builder workbench preferences (Open the Preferences
dialog and select General > Workspace >
Linked Resources).
Move or share resources between projects in a workspaceMove resourcesWhen
you work with multiple projects in a workspace, you can move resources from
one project to another.
In the Package Explorer, select the resource to move.
Do one of the following:
When
moving resources between projects, you can choose to update references.
Share resourcesTo share resources between projects,
place all shared resources into folders that can then be linked
to each project by using the project’s source path. This is the best
method for using shared resources such as classes, MXML components,
and images. Updates to these resources are immediately available
to all projects that use them. When your projects are compiled,
the shared resources are added to the SWC file.
Add an external resource folder to the source pathSelect the project in the Package Explorer.
Select Project > Properties > Flex
Build Path (or ActionScript Build Path if you are working with an
ActionScript project).
On the build path properties page, select the Source Path
tab.
Click the Add Folder button.
Enter or and browse to the folder’s path, and click OK.
The
folder is added to the source path.
You can also use the Source Path properties tab to edit, delete,
or reorder items in the source path.
Folders that are added to the source path are marked in the Package
Explorer.
Refresh resources in the workspaceAs you edit, add, or delete a project’s
resources, the workbench automatically refreshes the various views
that display these resources. For example, when you delete a file
from your project, that change is immediately reflected in the Package
Explorer.
You can also edit resources outside Flash Builder, directly in
the file system. These changes are visible only inside Flash Builder
after you refresh the workspace.
By default, in the stand-alone configuration of Flash Builder,
the workspace is refreshed automatically. This option is configurable
in Flash Builder preferences. Open the Preferences dialog and select
General > Workspace. You can also change the Flash Builder
default behavior so that it never refreshes the workspace automatically.
Manually refresh the workspace In the Package Explorer, select Refresh from the
context menu. All project resources in the workspace are refreshed.
Turn off automatic refresh preferenceOpen the Preferences dialog and select General >
Workspace.
Deselect Refresh Automatically.
|
|
|