|
|||
|
im a superb noob in SWFkit PRO...... = =!!
Well, i try to read a xml file from a flash movie, display/edit them and then save it as different xml file but i was facing the problem in retrieving the value from flash variable... the value of the flash was displayed perfectly after i built it using the SWFkit PRO but some how no xml file was created = =!! anyone ... please help me, im almost frustrated by my own stupidity, please kindly show me the complete code in Action Script and Ffish Script before i pull all of my hair out ~~ "Struggling for time" this is what i wrote in my Action Script Code:
myXML = new XML()
myXML.ignoreWhite = true
myXML.load("ABC.xml")
myXML.onLoad = function(succes){
if(succes){
var root = myXML.firstChild
nodes = root.childNodes
text1 = nodes.attributes.name
} else trace("Error loading XML document")
}
stop();
Code:
var xml = FlashPlayer.getVariable("myXML.text1");
var name = Dialogs.fileSave("XML file(*.xml)|*.xml|");
if (name)
{
var file = new FileStream(name, "w");
file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
file.writeLine(xml);
file.close();
}
|
|
|||
|
There is no property that can represent the string text of a XML object, so you have to save the string text of it in another variable in action script. And in your code, the variable or property "myXML.text1" doesn't exist at all, so it cannot work.
Please try to do it in the following way: 1. in action script, before you call the ffish script to save the xml file, save the string text of the xml object in another variable Code:
... _root.myXMLText = myXML.toString(); Code:
var xml = FlashPlayer.getVariable("_root.myXMLText");
To test whether the code is correct, you can simply call the trace method in ffish script: Code:
var xml = FlashPlayer.getVariable("myXMLText");
trace("The context of myXML is:", xml);
var name = Dialogs.fileSave("XML file(*.xml)|*.xml|");
if (name)
{
var file = new FileStream(name, "w");
file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
file.writeLine(xml);
file.close();
}
|
|
|||
|
thanx a lot for the code .....
but when i copied them into Flash and Ffish script it doesnt work out = =!! im wondering if im missing some command before the Code:
_root.myXMLText = myXML.toString(); sorry if im annoying = =!! coz im very dumb in programming .... thanx for spending time on my problem .... ![]() |
|
|||
|
1. insert a script into swfkit named "savexml" and add the following code
Code:
var xml = FlashPlayer.getVariable("myXMLText");
trace("The context of myXML is:", xml);
var name = Dialogs.fileSave("XML file(*.xml)|*.xml|");
if (name)
{
var file = new FileStream(name, "w");
file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
file.writeLine(xml);
file.close();
}
Code:
_root.myXMLText = myXML.toString();
fscommand("ffish_run", "savexml");
|
|
|||
|
Oh Yeah !! i've got it done !!! but there's a window pop up and ask me to save the file, how to get rid of it and let it automatically save as a XML file name which i describe in the script?
this is the code that i got from you ;D Code:
var xml = FlashPlayer.getVariable("_root.myXMLText");
var xml = FlashPlayer.getVariable("myXMLText");
trace("The context of myXML is:", xml);
var name = Dialogs.fileSave("XML file(abc.xml)|abc.xml|");
if (name)
{
var file = new FileStream(name, "w");
file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
file.writeLine(xml);
file.close();
}
|
|
|||
|
It launches a dialog box because you use the "Dialogs.fileSave" method to show a file save dialog box to choose the output file name. If you don't like it, you can use an appointed file name instead
Code:
var xml = FlashPlayer.getVariable("myXMLText");
trace("The context of myXML is:", xml);
var file = new FileStream("c:\\test.xml", "w");
file.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
file.writeLine(xml);
file.close();
|
|
|||
|
oh yeah, thanx for the teaching!!! gosh, it really help a lot!!!
1 more question please :P ... i was creating the XML file in C :\ ... but what if i wana create it in a directory named as below : C:\Documents and Settings\YuYu\Desktop\XML\XML\Untitled\Application i tried the following code but it doesnt seems to work ... Code:
var file = new FileStream("C:\Documents and Settings\YuYu\Desktop\XML\XML\Untitled\Application\test.xml", "w");
|
|
|||
|
Hi
@denwcp, are you sure with directory? C:\Documents and Settings\ = %homedir% If we use any language of directory: Example: My directory is in German: C:\Dokumente und Einstellungen or any language of directory. Please use frist special target directory!!! like C:\Windows\ = %windir% C:\Windows\system32\ = %systemroot% C:\documents & settings\<username>\ = %homedir% any directories i do not know everything.. Thanks and best regards |
|
|||
|
Hello again???
I have problem with autosave once config.xml like database saves automacally. If you want to load default configure by your swfkit application. I want to know about filestream and file... Example: How do file & filestream should to save while your application loads at frist afther installation? - If your config.xml does not exist than file / filestream should to write new file config.xml. Change your favorite color on application background color! If you apply at config.xml than you can restart your application - that is my currect application background color. Change your language like color! for examples.... If you want to make back default config than file & fileStream should rewrite again.. Or If you delete config.xml than file & fileStream create and write again new config.xml. That is very posible for "Loading, Writing and Updating Config File" like Adobe Air or any application with C++ by Visual Studio Applications.. Did you know about any softwares? Example OpenOffice 3.4.x is default afther installation - i change help panel to invisibled. I restart OpenOffice and work without help panel. What does it happen? No problem was config files from AppStrongDirectory saved by OpenOffice. That is trick by I/O Functions. Please make swfkit application with I/O Function sure! Thanks! I have been tried code in ffish script. i can not understand. That is high level :S Best regards, SnakeMedia |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|