- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
First I need to say thank you to the great community we have here. We have some smart actionscripting cookies here.
Now on to my question: So I’ve been able to load a swf into my parent swf and pass some flashvars via the query string. Genius. So for example:
var video:Loader=new Loader();
video.load(new URLRequest("local_video.swf?v=movie.mp4"));
video.contentLoaderInfo.addEventListener(Event.COMPLETE, videoloaded);
function videoloaded(e:Event):void {
addChild(video);
}
It works great. But I’m afraid that if I use the method multiple times each time because the variables will be different it’ll cause the viewers browser to download new version of the same swf file each time verses using the cached version like it would if there was no query string.
So I’m wondering is there’s another way to pass the flashvars to the subloaded swf.
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
you can cast the loaded swf as a movieclip and then access its public variables and functions in the same way you’d access those within a class…
So, for example:
var loader:Loader = new Loader();
... code for loading...
function loaded(e:Event):void
{
// cast loaded swf to movieclip
var swfAsMovieClip:MovieClip = MovieClip(e.currentTarget.content);
// access variable and functions
swfAsMovieClip.variableName = "whatever you want";
swfAsMovieClip.functionName("with parameter");
// add to the display list
addChild(swfAsMovieClip);
}
So in the above your loaded swf has a variable called ‘variableName’ and a function with one parameter called ‘functionName’ both of which you can read and write 
Hope that helps 
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Referred between 50 and 99 users
Fantastic. I’ll give it a try. Thank you for coming to the rescue.
