Hi, i have a class pageLoader.as and a sub class s2.as, I am trying to access the variables within pageLoader from s2. I have a function in pageLoader that I want to update the initial variables value and access this from s2, but s2 is not recognizing the updated value…
see highlighted code…
pageLoader.as
package pages
{
import flash.display.;
import flash.events.;
import flash.media.;
import flash.net.;
import flash.text.;
import flash.utils.;
public class pageLoader extends flash.display.MovieClip
{
public function pageLoader()
{
super();
return;
}
//Function to load external page
public function loadSWF(_swfURL):*
{
pgLoader = new Loader();
pgLoader.load(new URLRequest(_swfURL));
addChild(pgLoader);
pgLoader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
return;
}
//On Complete handler for page load
[COLOR=Red] public function handleInit(arg1:flash.events.Event):*
{
mc = MovieClip(pgLoader.content);
testVar = "123";
trace("parent:" +testVar); [/COLOR][COLOR=Blue]<- this traces [/COLOR][COLOR=Blue]123[/COLOR]
[COLOR=Red] return;
}[/COLOR]
//Send XML data to individual page classes
public function setTexts():void
{
return;
}
//Function to load XML file
public function loadXML(_xmlURL):void
{
myXML = new XML();
myXMLURL = new URLRequest(_xmlURL);
myXLoader = new URLLoader(myXMLURL);
myXLoader.addEventListener(Event.COMPLETE, completeHandler);
myXLoader.addEventListener(IOErrorEvent.IO_ERROR, handleError);
function completeHandler(event:Event):void {
myXML = XML(event.target.data);
dispatchEvent(event);
//function to set texts from xml file -> function defined in indiviual page classes
setTexts();
return;
}
function handleError(event:IOErrorEvent):void {
throw new Error("There was an IOerror accessing the XML file: " + event);
}
return;
}
//Set up variables
public var mc:MovieClip = new MovieClip();
public var _swfURL:String;
public var pgLoader:flash.display.Loader;
public var _xmlURL:String;
public var myXML:XML;
public var myXLoader:URLLoader;
public var myXMLURL:URLRequest;
[COLOR=Red]public static var testVar = "asdsa";[/COLOR]
}
}
s2.as
package pages
{
import flash.display.;
import flash.events.;
import flash.media.;
import flash.net.;
import flash.text.*;
public class s2 extends pages.pageLoader
{
public function s2()
{
super();
return;
}
//loads page
public function loadPage():void
{
_swfURL = "./swf/300_S2.swf";
_xmlURL = "./xml/S2.xml";
//function loads external swf file
loadSWF(_swfURL);
//function loads xml file
loadXML(_xmlURL);
//nextBtn = new ClipButton(this, this.btn_next, "NEXT", true);
//btn_next.addEventListener(MouseEvent.CLICK, nextPage);
//TabManager.setTabbingList([btn_next]);
//stage.focus = btn_next;
return;
}
//Sets text from XML file
public override function setTexts():void
{
var intro:String= myXML.s2_intro.text();
var buttonOne:String= myXML.buttonLabels.buttonOne.text();
var buttonTwo:String= myXML.buttonLabels.buttonTwo.text();
[COLOR=Red]trace("sub:"+testVar);[/COLOR] [COLOR=Blue]<- this traces [/COLOR][COLOR=Blue]asdsa but should be 123[/COLOR]
return;
}
public var btn_next:flash.display.MovieClip;
}
}