Hi Guys
I just can’t seem to solve this problem!!! :puzzled:
I have a random class that generates a random image and an id number from an xml file and a main class that reads information from an xml file according to the id number.
I’m having trouble assigning my random id number from my class to the _root.id variable on the main timeline for my other class to read. I keep getting undefined???
Random Class Code:
import mx.utils.Delegate;
class randomClass {
public var target_mc:MovieClip;
private var _xml:XML;
private var myTotal:Number;
private var random_number:Number;
public var myFid:Number;
private var myPic:String;
private var myTitle:String;
private var myImages:Array = new Array();
private var myTitles:Array = new Array();
private var myFids:Array = new Array();
function randomClass([url:String](String), target:MovieClip)
{
target_mc = target;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = Delegate.create(this, onLoadEvent);
_xml.load(url);
}
function onLoadEvent(success:Boolean):Void
{
if (success)
{
var i:Number;
myTotal=_xml.firstChild.childNodes.length;
for(i=0; i<=myTotal-1; i++)
{
myImages*=_xml.firstChild.childNodes*.firstChild.firstChild;
myTitles*=_xml.firstChild.childNodes*.firstChild.nextSibling.firstChild;
myFids*=_xml.firstChild.childNodes*.firstChild.nextSibling.nextSibling.firstChild;
}
random_number=random(myTotal);
myPic="<A href="http://www.mydomain/images/"+myImages[random_number">http://www.mydomain/images/"+myImages[random_number];
myTitle=myTitles[random_number];
myFid=myFids[random_number];
target_mc.title.text=myTitle;
var TheMovieLoader = new MovieClipLoader();
TheMovieLoader.loadClip(myPic, target_mc.new_mc);
var pictureLoaderListener = new Object();
pictureLoaderListener = TheMovieLoader.onLoadComplete()
{
target_mc.new_mc._x=-9;
target_mc.new_mc._y=-5;
target_mc.new_mc._xscale=40;
target_mc.new_mc._yscale=40;
}
TheMovieLoader.addListener(pictureLoaderListener);
target_mc.random_id.onPress = Delegate.create(this, onPressEvent);
}
}
public function onPressEvent() {
_root.id=myFid; //Undefined
trace(myFid); //ok
}
}
Main Movie Code:
on (press) {
var Obj:myClass=new myClass("<A href="http://mydomain/fanbase.xml",_root.viewer">http://mydomain/fanbase.xml",_root.viewer, _root.id);
}
It just keeps saying undefined but yet i seem to be able to trace myFid
Any ideas???
Thanks in advance