|
|||
|
Is there a way to pass parameters into a SWFKit function when it is called by actionScript? This way each call to a function contains it own unique set of parameters and not shared with other calls to the same function.
Here's the details: I have a script in SWFKit that writes event data to a text file. Once an event is triggered in Flash, I set _root level variables (that are FlashPlayer.bindData'ed) with the details of the event and call the SWFKit script using fsCommand("FFish_Run","writeEventData"). Everything works great until there are multiple events that get triggered without much of a delay. It appears that the bindData'ed variables are set with new event data before the 1st event is written. So, I end up with the second event written twice (confirmed by using a variable to store unique eventIDs). I tried using a multidimensional array to .push() and .shiift() the data for SWFKit to retrieve but I'm have a hard time with using multidimensional arrays in SFWKit. For what it's worth... here's my code. Notice that in userdata.txt the #7 eventID is entered twice instead of recording #6: Let me know if anyone has a better way to do this.... Thanks in advance! Steve -------------------------------- In Flash: _global.writeEvent = function(vCode, vData1, vData2) { if (_root.gEventID == undefined) { _root.gEventID = 1; } else { _root.gEventID++; } var vDate = new Date(); _root.gDateTime = vDate.getHours()+":"+vDate.getMinutes()+":"+vDate. getSeconds(); _root.gDateText = vDate.getMonth()+"/"+vDate.getDate()+"/"+(vDate.getYear()+1900)+" "+_root.gDateTime; _root.gCode = vCode; _root.gData1 = vData1; _root.gData2 = vData2; _root.gDate = vDate.toString(); fscommand("FFish_Run", "writeEventData"); }; In SWFKit: //Initialize setUpFileIO(); return true; function setUpFileIO() { vFlashPlayObj = new FlashPlayer; vFlashPlayObj.bindData("_root.gDateText","_root.gD ateTime","_root.gCode","_root.gDate","_root.gCode" , "_root.gData1", "_root.gData2", "_root.gEventID"); vFileStreamObj = new FileStream("c:/userData.txt", "a+"); return true; } //writeEventData var vDelim = "~" vFlashPlayObj.updateData(true); var vTextString = new String(""); vTextString = vFlashPlayObj._root.gEventID + vDelim; vTextString = vTextString + vFlashPlayObj._root.gDateText + vDelim; vTextString = vTextString + vFlashPlayObj._root.gCode + vDelim ; vTextString = vTextString + vFlashPlayObj._root.gData1 + vDelim ; vTextString = vTextString + vFlashPlayObj._root.gData2; vFileStreamObj.writeLine(vTextString); ----------------------- userdata.txt 1~5/10/2003 18:36:27~1~0~0 2~5/10/2003 18:36:31~4~introAudio.swf~0 3~5/10/2003 18:36:42~4~science3a.swf~2,3,1 4~5/10/2003 18:36:45~4~refs.swf~4,0,0 5~5/10/2003 18:36:48~4~ask07.swf~3,0,0 7~5/10/2003 18:37:0~1~0~0 7~5/10/2003 18:37:0~1~0~0 |
|
|||
|
Another way:
In flash: Code:
_global.writeEvent = function(vCode, vData1, vData2)
{
if (_root.gEventID == undefined)
{
_root.gEventID = 1;
} else
{
_root.gEventID++;
}
var tmp = vCode + "||" + vData1 + "||" + vData2 + "||" + _root.gEventID;
fscommand("ffish_eval", "writeData('" + tmp + "')");
};
In SWFKit: Code:
//Initialize
setUpFileIO();
return true;
function setUpFileIO() {
vFileStreamObj = new FileStream("c:/userData.txt", "a+");
return true;
}
function writeData(msg)
{
var vDelim = "~"
myarray = msg.split("||");
gCode = myarray[0];
gData1 = myarray[1];
gData2 = myarray[2];
gEventID = myarray[3];
var vDate = new Date();
gDateTime = vDate.getHours()+":"+vDate.getMinutes()+":"+vDate.getSeconds();
gDateText = vDate.getMonth()+"/"+vDate.getDate()+"/"+(vDate.getYear()+1900)+" "+gDateTime;
vTextString = gEventID + vDelim;
vTextString += gDateText + vDelim;
vTextString += gCode + vDelim ;
vTextString += gData1 + vDelim ;
vTextString += gData2;
vFileStreamObj.writeLine(vTextString);
}
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|