|
|||
|
Hi everybody .. I am asking how can I call a FFish Function from actionscript using import SWFKit .* ? I tried to do like that : import SWFKit .* ShowForm(); And the ShowForm is a function written in the Swfkit script editor . so please tell me what's the mistake and how can I call the function from flash 8 ? |
|
|||
|
To call a global ffish script from actionscript, please use the external interface:
Code:
ExternalInterface.call(functionName, param0, param1, ..., paramN); Code:
ExternalInterface.call("ShowForm");
Code:
function add(a, b)
{
return a+b;
}
ExternalInterface.addCallback("AS_add", null, add);
Code:
Application.registerASMethods("AS_add");
AS_add(1, 2);
|
|
|||
|
Yes, but the DataFile object is used to save and load ffish script variables. Therefore it is unnecessary to call it in actionscript, and we do not provide an actionscript wrapper class for the DataFile object. Do you mean to find out a way to save and load actionscript variables by using swfkit express?
|
|
|||
|
You can use the following class to save and load actionscript variables
Code:
import SWFKit.*;
import flash.external.*;
class SavedObject {
static private var initCount:Number = 0;
private var objSaved:Object;
private var fileName:String;
public function SavedObject(fileName:String) {
this.fileName = Global.getAppDir() + fileName;
init();
}
private function init() {
if (SavedObject.initCount == 0)
{
SavedObject.initCount++;
Global.eval("__asVars = new Object;" +
"function __setAsVars(value) {" +
"__asVars = value;" +
"}" +
"function __getAsVars() {" +
"return __asVars;" +
"}");
}
}
public function load() {
ExternalInterface.call("ffish_call", "DataFile", "load", this.fileName);
this.objSaved = ExternalInterface.call("__getAsVars");
}
public function save() {
ExternalInterface.call("__setAsVars", this.objSaved);
ExternalInterface.call("ffish_call", "DataFile", "remove",
this.fileName);
ExternalInterface.call("ffish_call", "DataFile", "save",
this.fileName, "__asVars");
}
public function get data() {
return this.objSaved;
}
}
|
|
|||
|
For example, loading variables
Code:
import SWFKit.*;
var so = new SavedObject("1.dat");
so.load();
Dialogs.msgBox(so.data.score);
Dialogs.msgBox(so.data.userName);
Dialogs.msgBox(so.data.arr);
|
|
|||
|
Saving variables
Code:
so.data.score = 100; so.data.userName = "Hello"; so.data.arr = new Array(); so.data.arr[0] = true; so.data.arr[1] = 100.1; so.save(); |
|
|||
|
Hi everybody!
I use this nice class "SavedObject" and it work correct allways. It save and load variables without problems. But when i'm replacing ExternalInterface.call("ffish_call", "DataFile", "save", "this.fileName", "__asVars"); with ExternalInterface.call("ffish_call", "DataFile", "saveAndEnc", "this.fileName", "__asVars"); it continue working, but only in Flash "commands -> swfkit_previewapp" And standalone EXE file does't want save anything. Can you help me to fix it? p.s. sorry for awful english :) |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|