Hey
I want to use a script on a button in my flash movie to open local files. This movie is going to be on a CD and I want to open some files through the movie. Actually it's an autorun.
What shall I do?
Would you please explain more and give me some examples? Can you create an example file and upload it for me? ![]()
Besides I have an extra question, I have a main flash file that loads another swf within it by "loadMovieNum". Can I use AS2.0 for the main flash file and AS3.0 for the swf which is played within the first one? ![]()
i don't have time to create an air file for you. here's code from a project i did that (among other things) reads a local xml file:
var shoremasterXMLFile:File;
var file2:File;
var partXML:XML;
var partCopyXML:XML;
var currentPartS:String;
var fileStream1:FileStream;
function openShoremasterXML(xmlDirectorySS:String){
xmlDirectoryS = xmlDirectorySS
//xmlDirectoryS = xmlDirectoryS.replace(/\//g, File.separator);
//traceF("openshoremasterxml: "+xmlDirectoryS+"shoremaster.xml");
shoremasterXMLFile = File.applicationDirectory.resolvePath(xmlDirectoryS+"shoremaster.xml" );
// done in initializations
// ReadMXLDirectoryFS = new FileStream();
ReadMXLDirectoryFS.addEventListener(Event.COMPLETE, xmlDirectoryReadCompleteF);
ReadMXLDirectoryFS.addEventListener(IOErrorEvent.IO_ERROR,xmlDirector yReadErrorF);
ReadMXLDirectoryFS.openAsync(shoremasterXMLFile, FileMode.READ);
}
function xmlDirectoryReadCompleteF(event:Event):void {
var shoremasterXML:XML = XML(ReadMXLDirectoryFS.readUTFBytes(ReadMXLDirectoryFS.bytesAvailable ));
parseShoremasterXML(shoremasterXML);
ReadMXLDirectoryFS.close();
ReadMXLDirectoryFS.removeEventListener(Event.COMPLETE, xmlDirectoryReadCompleteF);
//shoremasterXMLFile = null;
//ReadMXLDirectoryFS = null;
}
function xmlDirectoryReadErrorF(e:IOErrorEvent){
//traceF("ERROR: "+e.toString());
attachPopupF(null,"ERROR:","shoremaster.xml read-error.\n\nUse the LOAD DATA button to (re)specify the xml files' location.");
}
function parseShoremasterXML(xml:XML) {
//tf.appendText("\n\nparseShoremasterXML entered");
var xml:XML = XML(xml);
var xmlList:XMLList = xml.children();
for each (var item in xmlList) {
var childList:XMLList = item.children();
for(var i:int=0;i<childList.length();i++){
cb.addItem({label:childList[i].attribute("name"),data:childList[i].at tribute("name")});
}
}
cbListenerF();
// initial
loadXML(cb.getItemAt(0).label.split(" ").join("").split("-").join(""));
}
// and not you cannot use an as2 swf to load an as3 swf.
A simpler option might be to use a flash application builder like mProjector, it adds an openDocument command (along with many others) into Flash
Here a link to the API Docs page
http://www.screentime.com/software/flash-projector/docs/AS3-mSys-openD ocument.htm
So your would code something like this in AS
mSystem.openDocument("C:/Help.pdf");
There is a full built example fla / swf / app on this page
http://www.screentime.com/software/flash-projector/flas.html
called "Open Documents"
You would need to download the demo version of mProjector to install these new commands into Flash.
Yes you can do that too
OpenDocument is actually a pretty generic call, it can open a document, send and email, open a web browser and also open a folder, just pass it the path to the folder you want to open and it will open in the Windows Explorer (Win) or Finder (Mac)
This Code for example will open the folder that the application is running in
var fileToOpen = mApplication.getFolder() + mSystem.getPathDelimiter();
mSystem.openDocument(fileToOpen);
No, our software supports AS2 or AS3,
if the path is constant then you can hardcode it into the call
mSystem.openDocument("CDROM// Programs\Root1\1");
var applicationFolder:String = mApplication.getFolder();
mSystem.getSpecialFolder(folderName:String) : Stringthat takes a selector to return a path places like the programs folder
http://www.screentime.com/software/flash-projector/docs/AS3-mSys-getSp ecialFolder.htm
You may be able to use a batch file which in turn can open a folder/file of your choosing. I was able to muster up this short, but robust batch script:
@echo off
set file=%~n0
%SystemRoot%\explorer.exe /e, "%~dp0..\%file:@=\%"
The filename of the batch file dictates the folder which the script will open. The path is relative to the swf, with @ used in place of "\". Thus, in your case, you would name the batch file: "..@Programs@Root1@1.bat" which would be saved in the directory "Autorun/fscommand/"
And then to execute it, you'd simply use:
fscommand("exec", "..@Programs@Root1@1.bat" );
Of course, you could very well hardcode the path in the batch file to ease the naming process:
@echo off
%SystemRoot%\explorer.exe /e, "%~dp0..\..\Programs\Root1\1"
North America
Europe, Middle East and Africa
Asia Pacific