Hello,
I am rather new to AS3 and was wondering if anyone knows any good tutorials for creating an image grid with text and hyperlinks.
I want to create a page with art work where images are pulled externally and the items in the grid also have text and are clickable (all taken from XML).
I succesfully extracted information from XML and am using a for loop to create my image gird but not sure this is the best method? I have used an XML gallery tutorial from Republic of Code to get me started.
Below is the for loop what I am struggling with at the moment is that the product images are not loading into the individual movie clips.
Im new to AS3 so sorry if I am doing this all wrong.
function callProductThumbs():void {
//Loops through the XML Lists as defined by external Web Service
for (var i:Number = 0; i < product_total; i++) {
//-------Product Container END------------------------------------
var product_mc:MovieClip = new MovieClip();
product_mc.name = productid* + "_mc"
productcontainer_mc.addChild(product_mc);
product_mc.graphics.lineStyle(2,0x000000);
product_mc.graphics.beginFill(0x0000FF);
product_mc.graphics.drawRect(0, 0, 150, 100);
product_mc.graphics.endFill();
product_mc.y = -20
product_mc.x = i*180;
product_mc.buttonMode = true;
//-------Product Container END------------------------------------
//-------Product Image START------------------------------------
/* Dynamically loads images as defined by external XML file */
var thumb_url = "images/" + productimage* + ".jpg";
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
function thumbLoaded(e:Event):void{
var my_thumb:Loader = Loader(e.target.loader);
product_mc.addChild(my_thumb);
}
//Defines product image placment
//thumb_loader.x = 0;
//thumb_loader.y = 0;
thumb_loader.name = i;
thumb_loader.x = 0;
//-------Product Image END------------------------------------
//-------Product Title START------------------------------------
producttitle_txt = new TextField();
var defaultFont = new Font1();
var producttitle_txtformat:TextFormat = new TextFormat();
producttitle_txtformat.size = 11;
producttitle_txtformat.font = defaultFont.fontName;
producttitle_txt.defaultTextFormat = producttitle_txtformat;
producttitle_txt.embedFonts = true;
producttitle_txt.antiAliasType = AntiAliasType.ADVANCED;
producttitle_txt.width = 100;
producttitle_txt.height = 75;
producttitle_txt.wordWrap = true;
//Defines products title placment
producttitle_txt.x = thumb_loader.x + 90;
producttitle_txt.y = 10;
product_mc.addChild(producttitle_txt)
producttitle_txt.text = producttitle*
//-------Product Title END------------------------------------
}
}
function callProductURL(e:MouseEvent):void {
var thumb_linkURL = "mywebsite/_" + productimage[e.target.name] + ".aspx"
var linkProductTarget:URLRequest = new URLRequest(thumb_linkURL);
txtXMLOutput.text = thumb_linkURL;
navigateToURL(linkProductTarget, "_blank");
}