include actionscript
- Started
- Last post
- 21 Responses
- stewart
little problem:
i have this little piece of code...
myArray = new Array();
myArray[0] = Array(1,"title 01");
myArray[1] = Array(2,"title 02");
myArray[2] = Array(3,"title 03");
myArray[3] = Array(4,"title 04");
etc etc...that i want to be part of the actionscript, but NOT in the swf file itself.
i tried to # include the actionscript, but than i'm not able to change this actionscript after publishing the swf online.
what's the easiest solution to make this piece of actionscript editable after publishing the swf file??
- urban100
if you're wanting to change it dynamically on the fly, could use a php script to open the .as file and edit it.
- stewart0
urban, i can't use php because of the server type.
another thing is that editing the .as file is not my problem.
the problem is how to get that edited script back into my .swf file.
# include .as doesn't work in this case, because i don't want to re-publish the .swf file.
know what i mean??
- unfittoprint0
well, as long as you use the include in the top of your code, you'll be able to change afterwards.
i think this is what you meant.
ps: this would probably be faster:
ntitle=20;
myArray = new Array()
for(i=0; i
- j_red0
if you use "include" you will have to republish everytime you make changes.
if you want dynamic data, load it in via XML.
- unfittoprint0
shit.
I see you want to change your content, not exactly your code.You coul use an XML file to list all your tittles, and have an for loop to check for al the nodes an construct your array.
myArray = new Array();
content = myXML.firstChild.ChildNodes;
for(i=0; i { content.length; i++){
myArray[] = Array(i+1, content[i].attributes.title);
}
- stewart0
if you use "include" you will have to republish everytime you make changes.
j_red------
exactly!
but, silly question, how do i get this exact variable list i posted into my actionscript via XML ?
- System-Idle0
can u not update it in flash using the array class functions?
see array class (flash help)
- System-Idle0
sorry, ignore that. go with the xml route if you want to use the array for e.g updating projets/content
- stewart0
okay, XML.
anyone with an example how to get...
myArray = new Array();
myArray[0] = Array(1,"title 01");
myArray[1] = Array(2,"title 02");
myArray[2] = Array(3,"title 03");
myArray[3] = Array(4,"title 04");...via XML into my swf file?
i never used the XML in Flash before, so a little push in the right direction can be very useful!
- System-Idle0
http://www.ultrashock.com/ff.htm…
http://www.macromedia.com/devnet…
I am shure there are many better eg's out there than these, but is a starting point
- stewart0
thanks System, you made your point ;)
but i have to solve this little problem before tomorrow.all the rest is finished, i only have to put this piece of code dynamicaly into my swf file...
eehr... unfit?
where you saidmyArray[] = Array(i+1, content[i].attributes.title);
}it has to be something like
myArray[i] or something?man, i think i can't get this to work today.
this is my last flashthing ever, for sure...
- unfittoprint0
use this instead
myArray.push(new Array(i+1, content[i].attribute s.title));
your xml should look like:
< titles >
< item title="asas" />
< item title="wew2" />
< item title="wew2123" />
. . .
< / titles >
- stewart0
thanks unfit, it looks great, but it still doesn't work,
is it because i have to 'parse' the xml in flash, or is...
load_xml = new XML();
load_xml.load('document.xml');...enough??
- urban100
if using unfit's format as your xml... you can pull in the xml data into flash using:
function xmlParser (success) {
listing = thisXML.firstChild.firstChild;
if (listing.hasChildNodes) {
if (listing.nodeName == "titles") {
listing = listing.nextSibling;
itemTitle = listing.attributes.title;
}
}
}dataXML = new XML();
dataXML.ignoreWhite = true;
dataXML.onLoad = xmlParser;
dataXML.load("data.xml");
- stewart0
owkay, thanks, let's try that!
- stewart0
the result is still sort of zero.
please have a look at this, maybe it explains everything: