|
|||
|
Okay, so anyhow, I've been working with SWFGen lately and have just started getting it to work. I've been following the guide here:
http://www.swfkit.com/swf-generator/ And am able to change variables in the flash movie, but I'm having a hard time trying to change text font, colors, and other text stuff. Here's my SWFKit ffish code in one of the ffish scripts: Code:
var zGen = new ActiveXObject("SWFKit.ZGen");
if (zGen == null)
{
//SWFGen has not been registered yet, register it
//extract the dll, the variable swfgen contains the full path name of it
var swfgen = getAdditionalFile("swfgen.dll");
//copy it into the system folder
var sysfile = Shell.getSpecialFolder("system") + "\\swfgen.dll";
(new File(swfgen)).copy(sysfile);
//register it
ActiveXObject.register(sysfile);
//create the object again
var zGen = new ActiveXObject("SWFKit.ZGen");
}
//end of starting stuff, now moving into the actual work
zGen. OnSubActionString = function (obj)
{
if (obj.string == "{Hello world}")
{
obj.string = "Good night";
obj.needSub = true;
}
}
////////////////////////////////////////////////
zGen. OnBeforeSubText = function (obj)
{
obj.needSub = true;
}
///////////////////////////
zGen. OnSubText = function (obj)
{
if(obj.string == "Good night"){
obj.fontName = 'Arial';
obj.color = 0x000000;
obj.italic = true;
//obj.needSub = true;
}
}
var load = zGen.load("C:/Documents and Settings/CubbY/Desktop/swfkit test/Untitled/Projector/input.swf");
var save = zGen.save("C:/Documents and Settings/CubbY/Desktop/swfkit test/Untitled/Projector/export1.swf");
Dialogs.msgBox("done", 48);
Can you please help? I am sure this will help other people once they see this topic |
|
|||
|
Hi,
You must handle the onSubEditText event like this Code:
zGen. OnSubText = function (obj)
{
trace("onSubText: ", obj.text);
}
zGen.onSubEditText = function (obj)
{
trace("onSubEditText: ", obj.text);
***if (obj.text == "nbcff")
***{
******obj.fontName = 'Arial';
******obj.color = 0x000000;
******obj.italic = true;
***}
***else
***{
******obj.text = "Thank you";
******obj.fontName = "system";
***}
}
Please handle both the onSubText event and the onSubEditText event when you need to substitute texts in swf with SWFGen, for you may not know the exact type of the texts in swf, unless you use a swf parse tool. The most important thing during the text substituting is to set the right font. If swfgen cannot find the specified font, the substitution will fail. If you are not sure that the font you need to use exists in the system, you can distribute the font file with your application, and in the event handler, you can set the font name like this Code:
//obj.fontname = "my font file name"; obj.fontname = "C:/Documents and Settings/CubbY/Desktop/swfkit test/Untitled/Projector/arial.ttf" |
|
|||
|
Would I be able to inquire what "nbcff" is? Please excuse my question, however I'm just a bit confused how "Good night" got turned into "nbcff".... and I hope you don't mind one other question. I was reading into the image substituting, however am a bit confused at what the correct code is. E.g. Will this work:
Code:
SWFGen. OnSubImage = function (obj){
if(obj.id==1){ // 1 is the first image in the movie timeline
obj.image = "C:\image.jpg";
obj.needSub = true;
}
}
|
|
|||
|
Pardon me topcmm, please excuse my haste, however I would like to know if you may have an answer on this matter, your help is much appreciated as your responses have a history of being quite dedicated, and with that I guess you can call me spoiled.
Please reply as soon as you can. |
|
|||
|
'nbcff' is the initial value of the edit text field. Though you changed its value in the Action Script, swfgen can only substitute it with its initial value.
If you want to change its final value, you should substitute the string in Action Script that will be assigned to the text field. Code:
zGen. OnSubActionString = function (obj)
{
if (obj.string == "{Hello world}")
{
obj.string = "Good night";
obj.needSub = true;
}
}
|
|
|||
|
So then, I thank you for the answer.
![]() However lately I have been having trouble trying to find an easy way of figuring out an object's id. Would you happen to have your own way to figuring out an object's id? As I'm sure if you scripted the SWFGen to look for the object id's, you must have a way of finding them out. Also, SWFGen is doing some weird thing with replacing some images with a blank "void", basically the background of the Flash shows through on this weird type of replacement. Why does it do that? The image location is valid, and it's saved as non-progressive jpg... it's not the image. Something is strange with the replacement. Please assist on this one if you can. I would like to know how to stop it from doing this. (see the image below to view what the void looked like on a red background Flash file). Here's the code I am using under the replacing the images... it appears to only happen sometimes after skipping a id image or after replacing an image with a blank variable (eg. img10 = "" instead of the full C:\\....ten.jpg). Here's some of the code, I added some comments for you to sort of know what it's doing: Code:
zGen.OnSubImage = function (obj){
var img1 = FlashPlayer.getVariable("_root.cwin.img1"); //image 1 full location
var img2 = FlashPlayer.getVariable("_root.cwin.img2");
var img3 = FlashPlayer.getVariable("_root.cwin.img3");
var img4 = FlashPlayer.getVariable("_root.cwin.img4");
var img5 = FlashPlayer.getVariable("_root.cwin.img5");
var img6 = FlashPlayer.getVariable("_root.cwin.img6");
var img7 = FlashPlayer.getVariable("_root.cwin.img7");
var img8 = FlashPlayer.getVariable("_root.cwin.img8");
var img9 = FlashPlayer.getVariable("_root.cwin.img9");
var img10 = FlashPlayer.getVariable("_root.cwin.img10");
var img11 = FlashPlayer.getVariable("_root.cwin.img11");
var img12 = FlashPlayer.getVariable("_root.cwin.img12");
var img14 = FlashPlayer.getVariable("_root.cwin.img14"); //flash bg image
trace("subimg ID:",obj.id);
if(obj.id==17){if(File.exists(img1) && (img1!="")){//the first image
obj.image = img1;//replace with image one
obj.needSub = true;// do the sub
}}
if(obj.id==18){if(File.exists(img2) && (img2!="")){obj.image = img2;obj.needSub = true;}}
if(obj.id==19){if(File.exists(img3) && (img3!="")){obj.image = img3;obj.needSub = true;}}
if(obj.id==20){if(File.exists(img4) && (img4!="")){obj.image = img4;obj.needSub = true;}}
if(obj.id==21){if(File.exists(img5) && (img5!="")){obj.image = img5;obj.needSub = true;}}
if(obj.id==22){if(File.exists(img6) && (img6!="")){obj.image = img6;obj.needSub = true;}}
if(obj.id==23){if(File.exists(img7) && (img7!="")){obj.image = img7;obj.needSub = true;}}
if(obj.id==24){if(File.exists(img8) && (img8!="")){obj.image = img8;obj.needSub = true;}}
if(obj.id==25){if(File.exists(img9) && (img9!="")){obj.image = img9;obj.needSub = true;}}
if(obj.id==26){if(File.exists(img10) && (img10!="")){obj.image = img10;obj.needSub = true;}}
if(obj.id==27){if(File.exists(img11) && (img11!="")){obj.image = img11;obj.needSub = true;}}
if(obj.id==28){if(File.exists(img12) && (img12!="")){obj.image = img12;obj.needSub = true;}}
if(obj.id==29){if(File.exists(img14) && (img14!="")){obj.image = img14;obj.needSub = true;}}
//if an object id from the Flash file isn't from the list above
// then skip and don't sub it.
}
![]() |
|
|||
|
it's good for conserving space.
Heh. Anyhow, I hope topcmm will response after reading this, although personally I think that the SWFKit makers have a reputation of offering very good problem and answer support. |
|
|||
|
Thanks, Adan.
We've found there is a bug in jpg replacing, we will fix it ASAP. You need a SWF parsing tool such as "action script viewer" to find the id of the elements in a SWF movie. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|