846 posts
  • Has referred 50+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 more
marcfolio says

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.

8291 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

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 :)

846 posts
  • Has referred 50+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 more
marcfolio says

Fantastic. I’ll give it a try. Thank you for coming to the rescue.

8291 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

you’re welcome :)

by
by
by
by
by
by