Currently my class code looks like this:
[AS]package {
import flash.display.MovieClip;
//import flash.net.URLLoader;
import mcPromotion;
import mcContent;
import addTest;
public class BannerClassEN extends MovieClip {
private var imagenumber:Number;
//private var imageRequest:URLRequest = new URLRequest("test.jpg");
private var promotion:mcPromotion;
private var _mcContent:mcContent;
private var _mcContentX:Number;
private var _mcContentY:Number;
private var loadImage:String;
//private var addBox:addTest = new addTest();
// If anyone manages to load the XML dynamically please send the source files to [email]iancremona@gmail.com[/email]
////==============================================================================================================================================================================================================================================================================================================================================================================================================================================
////==============================================================================================================================================================================================================================================================================================================================================================================================================================================
public var promotionsXML:XML =
<promotions>
<promotion source="imagepath" urlLink="imagelink"></promotion>
<promotion source="imagepath" urlLink="imagelink"></promotion>
<promotion source="imagepath" urlLink="imagelink"></promotion>
</promotions>;
////==============================================================================================================================================================================================================================================================================================================================================================================================================================================
////==============================================================================================================================================================================================================================================================================================================================================================================================================================================
public function BannerClassEN() {
loadXML();
createPromos();
}
private function loadXML():void {
trace(promotionsXML.children()[0]);
}
private function createPromos():void {
_mcContentX=195;// I don't know why I had to do this! I guess the MC positioning needs amending
_mcContentY=31.5;//Extra
for (var i:Number = 0; i < promotionsXML.promotion.length(); i++) {
promotion = new mcPromotion();
addChild(promotion);
_mcContent = new mcContent();
promotion.setType(_mcContent);
_mcContent.x=_mcContentX;
_mcContent.y=_mcContentY;
_mcContentX+=_mcContent.width;
trace("XXXXX content width" + _mcContent.width);
// ------------------------------
// I would like to add image here
//_mcContent.promoThumb.alpha = .2;
// ------------------------------
_mcContent.promoTxt.text=promotionsXML.children()*;
promotion.name="promotion"+i;
trace(promotionsXML.children()*);
loadImage=promotionsXML.children()*.attribute("source");
trace("URLURL == "+promotionsXML.children()*.attribute("urlLink"));
_mcContent._URLLink=promotionsXML.children()*.attribute("urlLink");
_mcContent.imageSrc=loadImage;
trace("loadImage"+ loadImage);
//_mcContent.promoThumb
//imagenumber = loadImage;
trace("imagenumber"+ i);
}
}
}
}[/AS]
I have tried to modify the code to load the XML externally:
[as]
public function BannerClassEN() {
loadXML();
createPromos();
kungFuContent = new XML();
kungFuContent.ignoreWhite=true;
kungFuContent.load("promo.xml");
kungFuContent.onLoad = function(success1)
{
if(success1)
{
promotionsXML=kungFuContent;
trace(promotionsXML);
}
};
}
[/as]
But get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at BannerClassEN/createPromos()
at BannerClassEN()
Does anyone know why I am getting this? thanks
Ian