[Expand]
This is a brilliant tip that I've just discovered,
and expands on the reuse theme. I've been experimenting
with creating generic components in Flash, and I've
developed a simple method of creating components which
are identical, but can be changed using XML. Let's
take a simple Flash component for a multiple choice
question:
The code that is inserted into the component includes
a part which reads the URL of the Flash component,
and determines the name of the component. Next this
name can be converted into a file name with a .xml
extension, with:
var
infile;
getfilename();
urlXML
= new XML();
urlXML.onLoad = convertXML;
if (!urlXML.loaded) {
urlXML.load(infile);
trace("Loaded from local file");
if (!urlXML.loaded) {
question.title("XML file not found");
}
}
trace("XML LOADED");
Now, all we have to do is to copy the test01.swf
file into test02.swf, test03.swf, and so on. The test02.swf
component will use the test02.xml
file, test03.swf will use the test03.xml
file, and so on. Thus we have: