Jump to content
GreenSock

Genis200

LoaderMax SWF Loader - Accessing variables

Recommended Posts

Hi there! I am using the GreenSock LoaderMax in order to load a SWF. My dilemma is that I'd like to be able to get a variable defined in the Main class of the SWF file. The problem is, this variable is a private variable. I have tried setting the variable by doing loader.rawContent.variable, but I am unable to get or set this variable. Is there a way to do this without changing the variable to public, etc? I'm sorry if this is a noobish question, I'm not very familiar with ActionScript 3.

 

My code:

 

My loader class:

 

package {
import flash.display.*;
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.events.Event;
public class AS3Loader extends Sprite {
var cpLoader;
var Content;
var mainContext;
public function AS3Loader() {
this.cpLoader = new SWFLoader("http://mywebsite.com/mySWF.swf", {onComplete:onfinish});
addChild(this.cpLoader.content);
this.cpLoader.load();
}
function onfinish(event:LoaderEvent):void
{
Content = this.cpLoader.rawContent;
mainContext = Content.mainContext
}

}

}

 

And the source of the class that I want to load:

 

package com.swf.main
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.StageScaleMode;
import com.swf.check;

public class Main extends MovieClip
{

 private var mainContext:MainContext;

 public function Main()
 {
	 addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
 }

 private function onAddedToStageHandler(_arg1:Event):void
 {
	 if (_arg1.target == this)
	 {
		 removeEventListener(Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
		 this.init();
	 };
 }

 private function init():void
 {
	 stage.scaleMode = StageScaleMode.SHOW_ALL;
	 check.ALLOW_DOMAINS();
	 this.mainContext = new MainContext(this);
 }

 public function setWrapperView(_arg1):void
 {
	 this.mainContext.setWrapperView(_arg1);
 }


}
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×