Trouble loading xml images...
- October 9, 2009
- 2 replies
- 4684 views
I have loaded an XML file in the class LoadXML and have here created a method which parses the data and returns various arrays: an array of background urls (i called the array: hintergrund[]), an array of image paths (pfad[]), an array of website urls (website[]) and so forth. In the main class I would now like to load the backgrounds and images. I must have made a mistake in my onBackgrLoad() because I keep receiving the error msg:
Error #1084: Syntax error: expecting rightparen before colon.
I can´t see any paranthesis missing though...
Here are the relevant sections in my Main class:
package {
import flash.display.Sprite;
import flash.net.*;
import flash.display.*;
import flash.events.*;
import flash.display.Loader;
import flash.filters.DropShadowFilter;
import flash.net.URLRequest;
import flash.text.*;
// import de.container.text.Container_Text;
// To edit dropshadow. Atm not using.
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
public class Main extends Sprite
{
//____________________________________________________________________________Vars : Newly created
public var images : Vector.<DisplayObject>;
private var maxProducts : int;
private var loaders : Vector.<Loader> = new Vector.<Loader>();
private var loader : URLLoader = new URLLoader();
private var backgr : Bitmap;
private var img : Bitmap;
private var titel : String;
// private var textContainer : Container_Text = new Container_Text();
//____________________________________________________________________________Vars : From other classes
public var coverflow : CoverFlow;
private var bg : BG;
private var sb : ScrollPaneExample;
private var sl : ScrollLabels;
private var productSummaryLabel : ProductSummaryLabel;
// private var reflection : Reflection;
private var xmlLoad : LoadXML = new LoadXML();
private var xmlData : XML = xmlLoad.getXMLData();
private var hintergrund : Array = xmlLoad.getBackgr();
private var pfad : Array = xmlLoad.getPath();
private var maxProducts : int = xmlLoad.getMaxProducts();
private var numOfProducts : int = xmlLoad.getNumOfProducts();
private var numOfCategories : int = xmlLoad.getNumOfCategories();
//____________________________________________________________________________Constructor
public function Main()
{
initBG();
onBackgrLoad(e : Event);
}
//____________________________________________________________________________Methods
// Load the backgr for each image.
private function onBackgrLoad(e : Event) : void // Take away : void ?
{
// A summary should appear for each object once it is in the center
for (var i : uint = 0; i < numOfProducts; i++)
{
var backgrLoader : Loader = new Loader();
var backgrRequest : URLRequest = new URLRequest(hintergrund[i]);
backgrLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
backgrLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleXMLError);
try
{
backgrLoader.load(backgrRequest);
} catch (error: ArgumentError) {
trace("An Argument Error has occurred.");
} catch (error: SecurityError) {
trace("A Security Error has occurred.");
}
// OR can use method below without needing var backgrRequest
// backgrLoader.load( new URLRequest( hintergrund ) );
var myNewBackgr = e.target.loader; // Necessary?
// Hold the backgrs inside the Bitmap
backgr = e.target.content as Bitmap;
trace("onBackgrLoad Loop: " + i);
}
}
// Load image that will lie above backgr. When event is completed call onTextLoad().
public function onImageLoad(e : Event) : void
{
// FOR statement: summary should appear for each object once it is in the center
for (var i: uint = 0; i < numOfProducts; i++)
{
var imageLoader : Loader = new Loader();
var imageRequest : URLRequest = new URLRequest(pfad[i]);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); // change this to onTextLoad once method completed
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleXMLError);
imageLoader.load(imageRequest);
var myNewImage = e.target.loader; // necessary?
// Hold the images inside the Bitmap
img = e.target.content as Bitmap;
trace("onImageLoad Loop: " + i);
}
}
I also attached my LoadXML class and my XML file.