Reputation: 7490
Firstly Id like to say thanks to everyone who has helped me this week with some flash problems Iv had. Its been a great help.
Now to what I hope if my final problem
I have a object, called friends, It contains the url to facebook profile picture, ie
friends.friend1 = "http:// etc";
I have a swf file called, master.swf, which is passed the information to create the object through flashvars.
I need to get the object OR the flashvars info to the externally loaded swf, called pageOne.swf.
I have seen and tried several different methods, but now seem to give me what I need.
The important thing is that the pageOne.swf has access to the flashvars/object BEFORE it is rendered to the screen, as the info in the object/flashvars are used to construct it.
I am using the loader class to load the swf, castin it as a movieClip
Anyone have any ideas how to to the above?
CODE EXAMPLES:
master.swf
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
I need to either pass this to the pageOne.swf, OR make it available to it
How Im loading the external swf
function getFirstLevel()
{
my_Loader = new Loader();
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading2);
my_Loader.load(new URLRequest("pageOne.swf"));
function finishLoading2(loadEvent:Event) {
my_loadedSwf = loadEvent.currentTarget.content as MovieClip;
addChild(my_loadedSwf);
stage.addEventListener(Event.ENTER_FRAME, my_loadedSwf.enterFrameHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, my_loadedSwf.myOnPress);
stage.addEventListener(KeyboardEvent.KEY_UP, my_loadedSwf.myOnRelease);
stage.focus = my_loadedSwf;
}
}
Thanks
Upvotes: 0
Views: 990
Reputation: 81988
Either append it to the url and then access it through LoaderInfo.parameters, or have both swf's share access to the same class definition and store it there.
The first example:
my_Loader.load(new URLRequest("pageOne.swf?friend1=..."));
Then, inside of pageOne.swf access it through loaderInfo.parameters:
this.loaderInfo.parameters.friend1
For the second case (and I actually prefer this one), in main.swf:
import shared.Model; // have a class which has a public static facebook url
// property, or have it be a Singleton with that property
// Obviously, the class name is only an example.
/* ... */
shared.Model.facebookURL = "..."
Then, in the loaded swf:
import shared.Model;
/* ... */
var url:String = shared.Model.facebookURL
Upvotes: 1