I originally wanted to use flash as2 to call the HTML + JavaScript method to obtain the local path, but the project was too busy and there was no time to study HTML. I had to use the familiar VC for a whole day and work out a solution. No, see the text.
================================= The as2 script on the flash end is as follows:
// Call Open File Dialog
// Fscommand ("EXEC", "deletefile.exe ");
// Fscommand ("EXEC", "forflash.exe ");
System. usecodepage = true;
// System. setclipboard ("Hello World ");
VaR gfilepath: string;
Function btn1_fun (){
VaR my_lv: loadvars = new loadvars ();
VaR bisstopwait: Boolean = false;
VaR intervalid: number;
VaR duration: Number = 300000; // 5 minus
Fscommand ("EXEC", "openfile.exe ");
Intervalid = setinterval (timerevent, duration );
My_lv.load ("fscommand/filepath.txt", my_lv, "get ");
Function timerevent (): void {
Bisstopwait = true;
Clearinterval (intervalid );
Title_txt.text = "time is over .";
// My_lv.load ("fscommand/filepath.txt", my_lv, "get ");
}
My_lv.ondata = function (SRC: string ){
If (src = undefined ){
Trace ("error loading title .");
Title_txt.text = "loading ...";
If (true = bisstopwait ){
Title_txt.text = "time is over .";
Bisstopwait = false;
Return;
}
My_lv.load ("fscommand/filepath.txt", my_lv, "get ");
Return;
} Else {
Clearinterval (intervalid );
If ("error_or_cancel" = SRC ){
Title_txt.text = "user not open a file .";
} Else {
Title_txt.text = SRC;
Loadcontent (SRC );
// File path process
Gfilepath = SRC;
}
// Call Delete path File
Fscommand ("EXEC", "deletefile.exe ");
Return;
}
};
}
Function loadcontent (pcon: string ){
VaR my2_lv: loadvars = new loadvars ();
My2_lv.ondata = function (SRC: string ){
If (src = undefined ){
Trace ("error loading content .");
Return;
}
Content_txt.text = SRC;
};
My2_lv.load (pcon, my_lv, "get ");
}
// ------------------ Background -------------------------
Function btn2_fun (){
VaR my_lv: loadvars = new loadvars ();
VaR bisstopwait: Boolean = false;
VaR intervalid: number;
VaR duration: Number = 300000; // 5 minus
Fscommand ("EXEC", "openpic.exe ");
Intervalid = setinterval (timerevent, duration );
My_lv.load ("fscommand/picpath.txt", my_lv, "get ");
Function timerevent (): void {
Bisstopwait = true;
Clearinterval (intervalid );
Title_txt.text = "time is over .";
// My_lv.load ("fscommand/filepath.txt", my_lv, "get ");
}
My_lv.ondata = function (SRC: string ){
If (src = undefined ){
Trace ("error loading title .");
Title_txt.text = "loading ...";
If (true = bisstopwait ){
Title_txt.text = "time is over .";
Bisstopwait = false;
Return;
}
My_lv.load ("fscommand/picpath.txt", my_lv, "get ");
Return;
} Else {
Clearinterval (intervalid );
If ("error_or_cancel" = SRC ){
Title_txt.text = "user not open a file .";
} Else {
Title_txt.text = SRC;
Loadpic (SRC );
}
// Call Delete path File
Fscommand ("EXEC", "deletepic.exe ");
Return;
}
};
}
Function loadpic (psrc: string ){
VaR mcllistener: Object = new object ();
Mcllistener. onloadinit = function (target_mc: movieclip ){
Trace ("3:" + target_mc. _ x + "," + target_mc. _ y );
Trace ("4:" + target_mc. _ width + "," + target_mc. _ height );
Target_mc. _ x = stage. width/2-target_mc. _ width/2;
Target_mc. _ y = stage. Height/2-target_mc. _ height/2;
// Trace ("?? : "+ Stage. height +", "+ target_mc.height );
Trace ("5:" + target_mc. _ x + "," + target_mc. _ y );
Trace ("6:" + target_mc. _ width + "," + target_mc. _ height );
};
VaR image_mcl: movi1_loader = new movi1_loader ();
Image_mcl.addlistener (mcllistener );
Image_mcl.loadclip (psrc, pic_mc );
}
================================= The VC end program is as follows:
============ File creation section:
// Forflash. cpp: defines the entry point for the console application.
//
# Include "stdafx. H"
# Include "windows. H"
// # DEFINE _ Unicode
# Include <commdlg. h>
// # Define compile_as_file1
# Ifdef compile_as_file
# Define file_pathtext (". // filepath.txt ")
# Else
# Define file_pathtext (". // picpath.txt ")
# Endif
# Define file_end 2
Bool popfileopendlg (hwnd, ptstr pstrfilename, ptstr pstrtitlename );
Bool fbfilewrite (tchar *);
Static tchar szfilename [max_path], sztitlename [max_path];
Static openfilename ofn;
// # Pragma comment (linker, "/subsystem: Windows/entry: ___ tmaincrtstartup") // set the entry address
// # Pragma comment (linker, "/subsystem:/" Windows/"/entry:/" maincrtstartup/"") // set the entry address
Tchar aszbasepath [max_path];
Int _ tmain (INT argc, _ tchar * argv [])
{
Zeromemory (aszbasepath, max_path * 2 );
Getcurrentdirectory (max_path, aszbasepath );
If (true = popfileopendlg (null, szfilename, sztitlename ))
{
If (false = fbfilewrite (szfilename ))
{
MessageBox (null, text ("Write File error! "), Text (" error "), mb_ OK );
}
} Else
{
Fbfilewrite (text ("error_or_cancel "));
// MessageBox (null, text ("Open File error! "), Text (" error "), mb_ OK );
}
Return 0;
}
Bool popfileopendlg (hwnd, ptstr pstrfilename, ptstr pstrtitlename)
{
# Ifdef compile_as_file
Static tchar szfilter [] = text ("text files (*. txt)/0 *. txt/0 ");
// Text ("Bitmap (*. BMP)/0 *. BMP/0 ");/
// Text ("all files (*. *)/0 *. */0/0 ");
# Else
Static tchar szfilter [] = text ("JPEG files (*. jpg)/0 *. jpg/0 ");/
Text ("Bitmap (*. BMP)/0 *. BMP/0 ");
// Text ("all files (*. *)/0 *. */0/0 ");
# Endif
Ofn. lstructsize = sizeof (openfilename );
Ofn. hwndowner = hwnd;
Ofn. hinstance = NULL;
Ofn. lpstrfilter = szfilter;
Ofn. lpstrcustomfilter = NULL;
Ofn. nmaxcustfilter = 0;
Ofn. nfilterindex = 0;
Ofn. lpstrfile = NULL; // set in Open and Close Functions
Ofn. nmaxfile = max_path;
// Ofn. lpstrfiletitle = NULL; // set in Open and Close Functions
Ofn. nmaxfiletitle = max_path;
Ofn. lpstrinitialdir = NULL;
Ofn. lpstrtitle = NULL;
Ofn. Flags = 0; // set in Open and Close Functions
Ofn. nfileoffset = 0;
Ofn. nfileextension = 0;
Ofn. lpstrdefext = text ("TXT ");
Ofn. lcustdata = 0l;
Ofn. lpfnhook = NULL;
Ofn. lptemplatename = NULL;
Ofn. lpstrfile = pstrfilename;
Ofn. lpstrfiletitle = pstrtitlename;
// Ofn. Flags = ofn_hidereadonly | ofn_createprompt;
Return getopenfilename (& ofn );
}
Bool fbfilewrite (tchar * pbuff)
{
// Tcharaatcconpath [max_path];
Dwordauwrite;
Handleahconfig;/* file handle */
Charaactemp [max_path];
// Zeromemory (aatcconpath, max_path * 2 );
Zeromemory (aactemp, max_path );
Auwrite = 0;
Widechartomultibyte (cp_acp, 0, pbuff,-1, aactemp, max_path, null, null );
// Setfileattributes (aatcconpath, file_attribute_normal );
Setcurrentdirectory (aszbasepath );
/* Set file attribute of only read existing */
Ahconfig = createfilew (file_path,
Generic_read | generic_write,
File_pai_read | file_pai_write,
Null,
Create_always, // create_always, // open_existing
Null,
0 );
If (invalid_handle_value = ahconfig)
{
/* Read configure file failed */
MessageBox (null, text ("createfile error"), text ("error"), mb_ OK );
Return false;
}
Setfilepointer (ahconfig, 0, 0, file_end );
Int AAA = strlen (aactemp );
Writefile (ahconfig, aactemp, strlen (aactemp), & auwrite, null );
// Setfileattributes (aatcconpath, file_attribute_readonly );
Closehandle (ahconfig );
Return true;
}
================================ Delete the file section; # include "stdafx. H "# include" windows. H "// # define compile_as_file1 # ifdef compile_as_file # define file_pathtext (". // filepath.txt ") # else # define file_pathtext (". // picpath.txt ") # endifint _ tmain (INT argc, _ tchar * argv []) {tchar aszbasepath [max_path]; zeromemory (aszbasepath, max_path * 2); getcurrentdirectory (max_path, aszbasepath); setcurrentdirectory (aszbasepath); deletefile (file_pat H); Return 0 ;}========================== method Description: 1. in VC, the compilation switch is turned on and off to generate four EXE files: deletefile.exe,deletepic.exe,openfile.exe,openpic.exe creates the/fscommand folder at the same level of the Flash file Fla and puts the four EXE files. 2. Create two buttons in flash and call btn1_fun (); btn2_fun (); 3. Publish an EXE video (SwF cannot call an external EXE file ). 4. No.