Project object

 < Day Day Up > 

Availability

Flash 8.

Description

The Project object represents a Flash Project (FLP) file. You can use the following commands to return a Project object:

  • To create a new project file, use fl.createProject().

  • To open an existing project file, use fl.openProject().

  • To return a Project object for the currently open project, use fl.getProject().

Method summary for the Project object

The following methods can be used with the Project object.

Method

Description

project.addFile()

Adds the specified file to the project.

project.canPublishProject()

Determines whether the project can be published.

project.canTestProject()

Determines whether the project can be tested.

project.findProjectItem()

Searches for a specified file in the project.

project.publishProject()

Publishes the FLA files in a project.

project.testProject()

Tests the project.


Property summary for the Project object

The following properties can be used with the Project object.

Property

Description

project.defaultItem

Specifies the ProjectItem object that represents the default document in the project.

project.items

An array of ProjectItem objects (see ProjectItem object) contained in the project (read-only property).

project.name

The name of the project that appears in the Project panel.

project.projectURI

A string representing the path and name of the project file, expressed as a file:/// URI (read-only property).


project.addFile()

Availability

Flash 8.

Usage

project.addFile( fileURI [ , autoCreateFolder ] )

Parameters

fileURI A string specifying the file to be added to the project, expressed as a file:/// URI.

autoCreateFolder An optional Boolean value specifying if folders should be automatically created in the Project panel to mirror the path in fileURI; the default value is false.

Returns

If successful, returns a ProjectItem object; otherwise, returns undefined. See ProjectItem object.

Description

Method; adds the specified file to the project. You can use autoCreateFolder to determine where the new file should be positioned in the Project panel:

  • If you omit autoCreateFolder or pass a value of false, the file is added at the root level of the project.

  • If you pass a value of true for autoCreateFolder, and fileURI is below the FLP file in the folder structure on disk, the folder structure of the files is mirrored in the Project panel. That is, new folders are added to the Project panel if necessary to reflect the location of the file on disk.

  • If you pass a value of true for autoCreateFolder, and fileURI is above the FLP file in the folder structure on disk, the file is added at the root level. That is, autoCreateFolder is ignored.

Example

The following example illustrates several ways to use this command. In this case, the open project file is in the c:\Projects directory, and the only files currently in the project have been added at the root level.

// Get the project object var myProject = fl.getProject(); // The following command creates a folder named "files" below the root level   in the project, and places myFile.fla in that folder. var newFile = myProject.addFile("file:///C|Projects/files/myFile.fla",   true) fl.trace(newFile.isMissing); // false // The following two commands have the same effect: placing myFile_02.fla in   the root level of the project. var newFile = myProject.addFile("file:///C|Projects/files/myFile_02.fla" ,   false) var newFile = myProject.addFile("file:///C|Projects/files/myFile_02.fla") fl.trace(newFile.isMissing); // false // The following command places myFile_03 in the root level of the project   as a missing file. var newFile = myProject.addFile("file:///C|myFile_03.fla") fl.trace(newFile.isMissing); // true

The following example attempts to add a new file to the project, and displays a message in the Output panel indicating whether the file was added.

var myProject = fl.getProject(); var newItem = myProject.addFile("file:///C|Projects/files/Integra.fla",   true); fl.trace( "Item " + ( newItem ? "was" : "was not" ) + " added!" );

See also

fl.getProject(), project.items, ProjectItem object

project.canPublishProject()

Availability

Flash 8.

Usage

project.canPublishProject()

Parameters

None.

Returns

A Boolean value specifying whether the project can be published.

Description

Method; determines whether the project can be published. A project can be published if it contains at least one FLA file.

Example

The following example displays a message in the Output panel if the project cannot be published:

if (!fl.getProject().canPublishProject()) {   fl.trace("Project cannot be published!"); }

See also

fl.getProject(), project.publishProject(), projectItem.canPublish()

project.canTestProject()

Availability

Flash 8.

Usage

project.canTestProject()

Parameters

None.

Returns

A Boolean value specifying whether the project can be tested.

Description

Method; determines whether the project can be tested. A project can be tested if a default document has been specified.

Example

The following example displays a message in the Output panel if the project cannot be tested:

if (!fl.getProject().canTestProject()) {   fl.trace("Project cannot be tested!"); }

See also

fl.getProject(), project.testProject(), projectItem.canTest()

project.defaultItem

Availability

Flash 8.

Usage

project.defaultItem

Description

Property; specifies the ProjectItem object that represents the default document in the project. You must specify a default item if you want to test the project. See ProjectItem object.

Example

The following example sets the default document in the project to the Flower.fla file:

var myProject = fl.getProject(); var item = myProject.findProjectItem("file:///C|/Projects/files/   Flower.fla"); fl.myProject.defaultItem = item;

The following example displays the name of the default document in the Output panel:

fl.trace(fl.getProject().defaultItem.displayName);

See also

fl.getProject(), project.findProjectItem(), ProjectItem object

project.findProjectItem()

Availability

Flash 8.

Usage

project.findProjectItem( fileURI )

Parameters

fileURI A string specifying the file to search for in the project, expressed as a file:/// URI.

Returns

A ProjectItem object for the item if successful; otherwise, returns false. See ProjectItem object.

Description

Method; searches for a specified file in the project.

Example

The following example displays an error message in the Output panel if a specified file is not found in the project:

var myProject = fl.getProject(); var item = myProject.findProjectItem("file:///C|Projects/files/   Integra.fla"); if (item == undefined) {   fl.trace("Integra.fla is missing!"); }

See also

fl.getProject(), ProjectItem object, projectItem.isMissing

project.items

Availability

Flash 8.

Usage

project.items

Description

Read-only property; an array of ProjectItem objects (see ProjectItem object) contained in the project.

Example

The following example displays the names of all the items in the project in the Output panel:

for (i = 0; i < fl.getProject().items.length; i++) {   fl.trace(fl.getProject().items[i].displayName); }

See also

fl.getProject(), ProjectItem object

project.name

Availability

Flash 8.

Usage

project.name

Description

Property; the name of the project that appears in the Project panel.

Example

The following example specifies a new name to be displayed in the Project panel:

fl.getProject().name = "New project name";

See also

fl.getProject(), project.projectURI

project.projectURI

Availability

Flash 8.

Usage

project.projectURI

Description

Read-only property; a string representing the path and name of the project file, expressed as a file:/// URI.

Example

The following example displays the path and name of the currently open project file in the Output panel:

fl.trace("Project is located at: " + fl.getProject().projectURI);

See also

fl.getProject(), project.name

project.publishProject()

Availability

Flash 8.

Usage

project.publishProject()

Parameters

None.

Returns

A Boolean value indicating if the project was successfully published.

Description

Method; publishes the FLA files in a project.

Example

The following example publishes the project after confirming that it can be published, and then indicates whether the project was published in the Output panel:

if (fl.getProject().canPublishProject()) {   var bSucceeded = fl.getProject().publishProject(); } fl.trace(bSucceeded);

See also

fl.getProject(), project.canPublishProject(), projectItem.publish()

project.testProject()

Availability

Flash 8.

Usage

project.testProject()

Parameters

None.

Returns

A Boolean value indicating if the project was successfully tested.

Description

Method; tests the project. A project must have a default document to be tested.

Example

The following example tests the project after confirming that it can be tested, and then indicates whether the project was tested in the Output panel:

if (fl.getProject().canTestProject()) {   var bSucceeded = fl.getProject().testProject(); } fl.trace(bSucceeded);

See also

fl.getProject(), project.canTestProject(), project.defaultItem, projectItem.test()

     < Day Day Up > 


    Developing Extensions for Macromedia Flash 8
    Developing Extensions for Macromedia Flash 8
    ISBN: 032139416X
    EAN: 2147483647
    Year: 2005
    Pages: 81

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net