import af xml data i flashvar (ActionScript)
Hejsa,Jeg forsøger at få min flashfil til at importere noget xml data, som ikke ligger i en xml-fil men er indtastet i en flashVar i min swfobject embedding.
Dette er hvad der bliver brugt i den tutorial jeg har taget udgangspunkt i, men den er beregnet på en fysisk xml-fil.
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("slideshow.xml");
myShowXML.onLoad = function() {
_root.myWidth = myShowXML.firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.attributes.speed;
_root.myImages = myShowXML.firstChild.childNodes;
_root.myImagesNo = myImages.length;
createContainer();
callImages();
};
Nedenstående er den kode jeg forsøger at definere mine xml data via.
<script type="text/javascript">
var flashvars = {
myShowXML: "<slideshow width="400" height="400" speed="2">
<image url="images/image1.jpg" title="Market Walk" />
<image url="images/image2.jpg" title="History" />
<image url="images/image3.jpg" title="Ying Yang" />
<image url="images/image4.jpg" title="Kid Youth" />
<image url="images/image5.jpg" title="Heart of Spice" />
<image url="images/image6.jpg" title="Elissa" />
<image url="images/image7.jpg" title="Silver Secret" />
<image url="images/image8.jpg" title="Endless Mountains" />
<image url="images/image9.jpg" title="Light of Hope" />
<image url="images/image10.jpg" title="Bored?" />
</slideshow>"
};
var params = {
wmode: "opaque"
};
swfobject.embedSWF("slideshow-endsample.swf", "FlashObject1", "400", "400", "8.0.0", false, flashvars, params);
</script>
Ideen er fra et andet site, men her formaterer de deres xml-data således (De mange tegn kan omsættes til valide tegn):
%3c%3fxml+version%3d%221.0%22+encoding%3d%22UTF-8%22%3f%3e%3cProductList%3e%3cGlobal%3e%3cCharset%3eLatin%3c%2fCharset%3e%3cLabel1%3ePrisgruppe%3c%2fLabel1%3e%3cLabel2%3eN%c3%a6ste%3c%2fLabel2%3e%3cLabel3%3eForrige%3c%2fLabel3%3e%3cLabel4%3eLuk%3c%2fLabel4%3e%3cLabel5%3e%3c%2fLabel5%3e%3cLabel6%3e%3c%2fLabel6%3e%3cLabel7%3e%3c%2fLabel7%3e%3cLabel8%3e%3c%2fLabel8%3e%3cLabel9%3e%3c%2fLabel9%3e%3cLabel10%3e%3c%2fLabel10%3e%3c%2fGlobal%3e%3cProducts%3e%3cPlaceHolder%3e%3cItem%3e%3cTextShort%3e%3cText%3eSofa%3c%2fText%3e%3c%2fTextShort%3e%3cTextLong%3eSofa+med+opbevaring%2c+f%c3%a5s+i+forskellige+stoffer+og+l%c3%a6dertyper.+Som+vist%2c+gr%c3%b8nt+Sazza+stof.%3c%2fTextLong%3e%3cPriceText%3e%3cPrice%3efra+9.150%2c-%3c%2fPrice%3e%3c%2fPriceText%3e%3cImageID%3e3366%3c%2fImageID%3e%3cImagePath%3eFiles%2fBilleder%2fBC%2fProduct1%2fSPAZE%2fSINGLE+FRIT%2fSP-S-F-SP08-0282.JPG%3c%2fImagePath%3e%3cProductLink%3ehttp%3a%2f%2fwww.boconcept.dk%2fDefault.aspx%3fID%3d83462%26amp%3bImageID%3d3366%3c%2fProductLink%3e%3c%2fItem%3e%3cItem%3e%3cTextShort%3e%3cText%3eSofa%3c%2fText%3e%3c%2fTextShort%3e%3cTextLong%3eSofa+med+opbevaring%2c+f%c3%a5s+i+forskellige+stoffer+og+l%c3%a6dertyper.+Som+vist%2c+gr%c3%b8nt+Sazza+stof.%3c%2fTextLong%3e%3cPriceText%3e%3cPrice%3efra+9.150%2c-%3c%2fPrice%3e%3c%2fPriceText%3e%3cImageID%3e985%3c%2fImageID%3e%3cImagePath%3eFiles%2fBilleder%2fBC%2fProduct1%2fSPAZE%2fSINGLE+FRIT%2fSP-S-F-SP08-0282-OPEN-WOMAN.JPG%3c%2fImagePath%3e%3cProductLink%3ehttp%3a%2f%2fwww.boconcept.dk%2fDefault.aspx%3fID%3d83462%26amp%3bImageID%3d985%3c%2fProductLink%3e%3c%2fItem%3e%3cItem%3e%3cTextShort%3e%3cText%3eSofa%3c%2fText%3e%3c%2fTextShort%3e%3cTextLong%3eSofa+med+sovefunktion%2c+f%c3%a5s+i+forskellige+stoffer+og+l%c3%a6dertyper.+Som+vist%2c+gr%c3%b8nt+Sazza+stof.%3c%2fTextLong%3e%3cPriceText%3e%3cPrice%3efra+11.974%2c-%3c%2fPrice%3e%3c%2fPriceText%3e%3cImageID%3e3985%3c%2fImageID%3e%3cImagePath%3eFiles%2fBilleder%2fBC%2fProduct1%2fSPAZE%2fSINGLE+FRIT%2fSP-S-F-7025-0282-OPEN-2-WMN.JPG%3c%2fImagePath%3e%3cProductLink%3ehttp%3a%2f%2fwww.boconcept.dk%2fDefault.aspx%3fID%3d83462%26amp%3bImageID%3d3985%3c%2fProductLink%3e%3c%2fItem%3e%3cItem%3e%3cTextShort%3e%3cText%3eSofa%3c%2fText%3e%3c%2fTextShort%3e%3cTextLong%3eSofa+med+sovefunktion%2c+f%c3%a5s+i+forskellige+stoffer+og+l%c3%a6dertyper.+Som+vist%2c+gr%c3%b8nt+Sazza+stof.%3c%2fTextLong%3e%3cPriceText%3e%3cPrice%3efra+11.974%2c-%3c%2fPrice%3e%3c%2fPriceText%3e%3cImageID%3e3693%3c%2fImageID%3e%3cImagePath%3eFiles%2fBilleder%2fBC%2fProduct1%2fSPAZE%2fSINGLE+FRIT%2fSP-S-F-7025-0282-OPEN-3.JPG%3c%2fImagePath%3e%3cProductLink%3ehttp%3a%2f%2fwww.boconcept.dk%2fDefault.aspx%3fID%3d83462%26amp%3bImageID%3d3693%3c%2fProductLink%3e%3c%2fItem%3e%3c%2fPlaceHolder%3e%3c%2fProducts%3e%3c%2fProductList%3e
Hele problemet er fordi mit CMS system ikke kan outputte en xml-fil med de billeddata jeg har brug for, men jeg kan godt konstruere xml-dataene i en flashVar.
Hjælp !! :-)