Extending Flash |
|
|
|
| Objects > Project object > project.addFile() | |||
Flash 8.
project.addFile(fileURI[ ,autoCreateFolder])
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.
If successful, returns a ProjectItem object; otherwise, returns undefined. See ProjectItem object.
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:
autoCreateFolder or pass a value of false, the file is added at the root level of the project. 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.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.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!" );
fl.getProject(), project.items, ProjectItem object
|
|
|
|