Hi,
I’m pretty new to as3, and i’m having problems converting a xml gallery that used timeline actionscript, to a xml gallery that’s being controlled by a class file. Here is my code for the attempted class file version;
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import caurina.transitions.Tweener;
public class Gallery extends MovieClip {
var xmlLoader:XML;
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
public function Main() {
xmlLoader.load(new URLRequest("images.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
}
function xmlLoaded(event:Event):void {
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int = 0; i < xmlList.length(); i++) {
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList*.attribute("thumb")));
imageLoader.x = 25;
imageLoader.y = i * 150 + 25;
imageLoader.name = xmlList*.attribute("source");
addChild(imageLoader);
imageLoader.addEventListener(MouseEvent.MOUSE_OVER, showPicture);
trace("working");
}
}
function showPicture(event:MouseEvent):void {
imageLoader = new Loader();
imageLoader.load(new URLRequest(event.target.name));
imageLoader.alpha = 0;
imageLoader.x = 400;
addChild(imageLoader);
Tweener.addTween(imageLoader,{alpha:1,time:36,delay:2,transition:"easeOutBack",useFrames:true});
}
}
}
But when I run the file, the following errors are displayed;
Warning: 3594: load is not a recognized method of the dynamic class XML.
Warning: 3594: addEventListener is not a recognized method of the dynamic class XML.
here is the code for the xml gallery using the as3 on the timeline;
import caurina.transitions.Tweener;
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("images.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void {
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int = 0; i < xmlList.length(); i++) {
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList*.attribute("thumb")));
imageLoader.x = 25;
imageLoader.y = i * 150 + 25;
imageLoader.name = xmlList*.attribute("source");
addChild(imageLoader);
imageLoader.addEventListener(MouseEvent.MOUSE_OVER, showPicture);
trace("working");
}
}
function showPicture(event:MouseEvent):void {
imageLoader = new Loader();
imageLoader.load(new URLRequest(event.target.name));
imageLoader.alpha = 0;
imageLoader.x = 400;
addChild(imageLoader);
Tweener.addTween(imageLoader,{alpha:1,time:36,delay:2,transition:"easeOutBack",useFrames:true});
}
Sorry if my explanation was vague.
Thanks
Benny