ProjectItem object

 < Day Day Up > 

Availability

Flash 8.

Description

The ProjectItem object represents an item (file on disk) that has been added to a project. This object is a property of the Project object (see project.items). You can use the following commands to return a ProjectItem object.

  • To add a new file to a project, use project.addFile().

  • To locate an item that has already been added to a project, use project.findProjectItem().

Method summary for the ProjectItem object

The following methods can be used with the ProjectItem object.

Method

Description

projectItem.canPublish()

Determines whether a project item can be published.

projectItem.canTest()

Determines whether a project item can be tested.

projectItem.publish()

Publishes a project item.

projectItem.test()

Tests a project item.


Property summary for the ProjectItem object

The following properties can be used with the ProjectItem object.

Property

Description

projectItem.displayName

Read-only; a string that specifies the name of a project item.

projectItem.isMissing

Read-only; a Boolean value that specifies whether a file is missing from the disk.

projectItem.itemURI

Read-only; a string that specifies the path and name of the project item.

projectItem.publishProfile

A string that specifies the publish profile to use when publishing a project item (FLA file).


projectItem.canPublish()

Availability

Flash 8.

Usage

projectItem.canPublish()

Parameters

None.

Returns

A Boolean value specifying whether a project item can be published.

Description

Method; determines whether an item can be published. An item can be published only if it is a FLA file.

Example

The following example displays a message in the Output panel if the first item in the project cannot be published.

var item = fl.getProject().items[0]; if (!item.canPublish()) {   fl.trace(item.displayName + " cannot be published!"); }

See also

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

projectItem.canTest()

Availability

Flash 8.

Usage

projectItem.canTest()

Parameters

None.

Returns

A Boolean value specifying whether a project item can be tested.

Description

Method; determines whether an item can be tested. An item can be tested if it is a FLA or HTML file.

Example

The following example displays a message in the Output panel if the first item in the project cannot be tested.

var item = fl.getProject().items[0]; if (!item.canTest()) {   fl.trace(item.name + " cannot be tested!"); }

See also

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

projectItem.displayName

Availability

Flash 8.

Usage

projectItem.displayName

Description

Read-only property; a string that specifies the name of a project item, such as "file.fla".

Example

The following example displays the names of all the files in the project in the Output panel.

fl.trace( "These are all the files in the project: "); var files = fl.getProject().items; for (i = 0; i < files.length; i++) {   fl.trace(files[i].displayName + " "); }

See also

fl.getProject(), project.items, projectItem.itemURI

projectItem.isMissing

Availability

Flash 8.

Usage

projectItem.isMissing

Description

Read-only property; a Boolean value that specifies whether a file is missing from the disk (for example, if the item has been moved, deleted or renamed).

Example

The following example displays a message in the Output panel that indicates whether a specific file is on the disk in the expected folder.

var item = fl.getProject().findProjectItem("file:///C|/Projects/files/   DynamicHighAscii.fla"); fl.trace("DynamicHighAscii.fla is missing: " + item.isMissing);

See also

fl.getProject(), project.findProjectItem(), project.items

projectItem.itemURI

Availability

Flash 8.

Usage

projectItem.itemURI

Description

Read-only property; a string, specified as a file:/// URI, that specifies the path and name of the project item. Folder items contain an empty string ("").

Example

The following example displays the path and name of each item in the project in the Output panel.

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

See also

fl.getProject(), projectItem.displayName, project.items

projectItem.publish()

Availability

Flash 8.

Usage

projectItem.publish()

Parameters

None.

Returns

A Boolean value of TRue if successful; false otherwise.

Description

Method; publishes a project item. Only FLA files can be published.

Example

The following example publishes all of the publishable items in the project.

for (var i in fl.getProject().items) {   var item = fl.getProject().items[i];   if (item.canPublish()) {     item.publish();   } }

See also

fl.getProject(), project.canPublishProject(), project.items, projectItem.canPublish(), projectItem.publishProfile

projectItem.publishProfile

Availability

Flash 8.

Usage

projectItem.publishProfile

Description

Property; a string that specifies the publish profile to use when publishing a project item (FLA file). The publish profile must be an existing profile in the item, or a subsequent call to projectItem.publish() will fail. See projectItem.publish().

If the item is not a FLA file, this property is an empty string (""), and any attempts to set this property fail.

Example

The following example sets the publish profile of all the items in the project to a specified profile that already exists in the item, and then publishes each item. If the profile doesn't exist in a file, the file isn't published.

var items = fl.getProject().items; for ( i = 0 ; i < items.length ; i++ ) {   items[i].publishProfile = "mySpecialProfile";   items[i].publish(); }

See also

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

projectItem.test()

Availability

Flash 8.

Usage

projectItem.test()

Parameters

None.

Returns

A Boolean value that indicates whether the item was successfully tested or not.

Descriptionn

Method; tests a project item. If the test operation fails because the item is not a FLA or HTML file, this method returns false.

Example

The following example tests all the FLA and HTML files in the project:

for (var i in fl.getProject().items) {   var item = fl.getProject().items[i];   if (item.canTest()) {     item.test();   } }

See also

fl.getProject(), project.canTestProject(), project.items, projectItem.canTest()

     < 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