Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-12-2009, 01:58 PM
Junior Member
 
Join Date: Jun 2007
Posts: 9
Default File copy with relative path problem.

Hi

I am trying to copy a file specified through an xml to a path you can chose from a filesave dialog.

SWF script

//copy
//var basePath = FlashPlayer.getVariable("_root.cale"); - tried this also , doesn't work
var basePath = Global.getAppDir()+"\\"; doesn't work
var ourFile = FlashPlayer.getVariable("_root.lng_p4_exe"); - works
var path = basePath+"Products\\Products\\"+ourFile;
var file = new File (ourFile);
var f = "file(*.*)|*.*|";
a=file.name;
var res = Dialogs.fileSave(f, ".exe", ""+a);
var outPath = res;
file.copy(outPath);

problem here:
var basePath = Global.getAppDir()+"\\"; this line returns undefined



I i use in flash the
var basePath = Global.getAppDir()+"\\"; it works

but i can't pass it to swfkit

var basePath = FlashPlayer.getVariable("_root.cale"); doesn't work


Any ideas?
If you need more info i'll tell more

Thanks a lot.
Reply With Quote
  #2 (permalink)  
Old 06-13-2009, 10:25 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

it looks like ffish script code, so you cannot use "Global.getAppDir()", but "getAppDir()" directly. "Global" is a wrapper class for actionscript.

If you use
Code:
var basePath = Global.getAppDir()+"\\"; it works
in actionscript, you can write all your code in actionscript so that you won't need to pass any variable from actionscript to swfkit.
Reply With Quote
  #3 (permalink)  
Old 06-16-2009, 09:47 AM
Junior Member
 
Join Date: Jun 2007
Posts: 9
Default

Thanks
After you reply i decided to do everything in flash to avoid variable transfer problems.

although there were some other posts about copying files that i read before posting here none of them was complete.So here you go, there are 2 ways of copying files.

1. One of them is with the file save dialogue:

on(release)
{
import SWFKit.*;
var basePath = Global.getAppDir() + "\\";
var path = basePath+"Product_path\\"+_root.imported_path_from _xml;
//_root.imported_path_from_xml contains also the file name and extension
var ourFile = path;
textpath.text = ourfile;
var file = new File (ourFile);
var f = "somename(*.exe)|*.exe|";
a=file.name;
var res = Dialogs.fileSave(f, ".exe", a);
var outPath = res;
file.copy(outPath);
}




2. The other way is by using a Dialogs.browse component


on(release)
{
import SWFKit.*;
var basePath = Global.getAppDir() + "\\";
var path = basePath+"Product_path\\"+_root.imported_path_from _xml;
//_root.imported_path_from_xml contains also the file name and extension
var ourFile = path;
var srcName = path
if (!File.exists(srcName)) return false;
var pathc = Dialogs.browse("Please choose a path:");
if (pathc == false) return false;
pathc += "\\";
var file = new File(srcName);
pathc += file.name;
return file.copy(pathc);

}



Both of them work great.You can use wich one is best suited for you.
Reply With Quote
  #4 (permalink)  
Old 07-21-2010, 03:09 PM
Junior Member
 
Join Date: Jun 2007
Posts: 9
Default

Hi
I bring back the file copy issue.

Is there any way to test the finish of the copying process.

Having this command f.copy(path), can i show a progress for this operation, or at least the beginning and the success of the operation?

on(release)
{
f.copy(path);

if (f.copy(path) in progress)
{
Dialogs.msgBox("copying");
} else {
Dialogs.msgBox("done");
}
}

Thanks
Reply With Quote
  #5 (permalink)  
Old 07-26-2010, 09:56 AM
Junior Member
 
Join Date: Jun 2007
Posts: 9
Default

As i have found out , the copy action is kinda linear, that means the copyiing actions hangs the application and the passes on to the next action when it's finished.


var path = Dialogs.browse(_text);
if (path == false) {
----------some action
return false;
}

f.copy(path);
------------some other action

The problem is with the application not responding until completion.

Is there any way to copy in a new thread?
Reply With Quote
  #6 (permalink)  
Old 08-19-2010, 09:01 PM
Junior Member
 
Join Date: Aug 2006
Location: Germany
Posts: 28
Send a message via MSN to snakemedia Send a message via Yahoo to snakemedia
Smile

Hello @mc_toto:

Make sure your file from relative path! But it is problematy because you are using with Windows 7 / Vista. Do not forget for clicking to privatage administrator like in Contentmenu Run Administrator .. than Your swfkit application will to prompt before to coniture than you can work with copy functions.. Thanks!

I hope you because you understand sure..

I am using Windows 7, too
__________________
Sorry I am deaf! I have problem with eys... Thanks!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:01 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.