Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-10-2006, 05:08 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Call FFish Function From Flash Directly


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 ?
Reply With Quote
  #2 (permalink)  
Old 10-24-2006, 11:10 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Call FFish Function From Flash Directly

To call a global ffish script from actionscript, please use the external interface:
Code:
ExternalInterface.call(functionName, param0, param1, ..., paramN);
E.g.

Code:
ExternalInterface.call("ShowForm");
To call an actionscript function from within ffish script, please first use the ExternalInterface.addCallback in actionscript to export the function, second in ffish script use the Application.registerASMethods method to register the function, and then you can call it as if a ffish script function. E.g. in actionscript:
Code:
function add(a, b)
{
    return a+b;
}

ExternalInterface.addCallback("AS_add", null, add);
in ffish script
Code:
Application.registerASMethods("AS_add");
AS_add(1, 2);
Reply With Quote
  #3 (permalink)  
Old 10-28-2006, 07:35 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Call FFish Function From Flash Directly

thank you very very much

And I have an other question :

How can I read and write to file using DataFile method directly from flash ??
Reply With Quote
  #4 (permalink)  
Old 10-30-2006, 10:54 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Call FFish Function From Flash Directly

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?
Reply With Quote
  #5 (permalink)  
Old 10-31-2006, 03:24 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Call FFish Function From Flash Directly

Yes please .
Reply With Quote
  #6 (permalink)  
Old 11-04-2006, 09:52 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Call FFish Function From Flash Directly

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;
}
}
Reply With Quote
  #7 (permalink)  
Old 11-04-2006, 09:56 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Call FFish Function From Flash Directly

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);
where "1.dat" is the name of the data file, without path name. The data files will be saved into the same folder as the executable files.
Reply With Quote
  #8 (permalink)  
Old 11-04-2006, 09:58 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Call FFish Function From Flash Directly

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();
Note: the data property of the SavedObject is read-only, so you can only change its properties and cannot change itself.
Reply With Quote
  #9 (permalink)  
Old 11-05-2006, 02:57 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Call FFish Function From Flash Directly

That's what I want :-*

I will test it

Thank you very much .
Reply With Quote
  #10 (permalink)  
Old 01-22-2007, 11:42 PM
Junior Member
 
Join Date: Jan 2007
Posts: 2
Default Re:Call FFish Function From Flash Directly

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 :)
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 03:55 AM.


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.