Pass a File Name as a Variable in to a Flash Object

I have a simple flash object that has an image (let's say a simple jpg file) and buttons to move, zoom in and zoom out.  I would like this object to be the basis for a web-based image viewing system, but in order to do this, I want to be able to pass in an variable that contains a filename that then this file is loaded into my flash "movie".  Is this possible?  If so, how do you structure the Flash movie and create the HTML code?  I would expect the HTML code would look something like:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,29,0" width="320" height="320">
  <param name="movie" value="myFlashMovie.fla">
      <param name="myFileNameVariable" value="/images/somefile.jpg">
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I bleieve it goes like you have but:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=",0,0,0" width="544" height="249" id=" helloWorld " align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="helloWorld.swf" />
<PARAM NAME=FlashVars VALUE="var1=Hello%20World">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="helloWorld.swf" quality="high" bgcolor="#ffffff" width="544" height="249" name=" helloWorld " flashvars="var1=Hello%20World" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="" />

notice how:
<PARAM NAME=FlashVars VALUE="var1=Hello%20World">

the name=FlashVars gets it into the flash movie. When u access var1 from within the actionscript you should get a "Hello World"


The structure of Flash simply will be using the loader component

You are using at least MX version, right?

If it is then do use the following to make the image put inside your movie

First of all, from the component window, drag the Loader to the stage, name it as jpeg_loader

Second, apply the following code to the frame 1 main movie

jpeg_loader.autoLoad = false;
jpeg_loader.contentPath = myFileNameVariable;
jpeg_loader.load ();

Vicker :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
<PARAM NAME=movie VALUE=movie.swf?image=MyImage.jpg> <PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=><EMBED src=movie.swf?image=MyImage.jpg quality=high bgcolor=...... etc etc

Notice: the above is not supported by all browsers!
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

This article gives in-depth description of getting variables in/out of flash. If you need to pass in a list of files, you might want to consider using an XML file. I have done similar things using ASP that, for example, dynamically generates an XML file containing the list of files in a folder on the server, then parsing that XML in flash, but anyway, here's the article:
bmcclearyAuthor Commented:
I have Flash MX Version 6.0, but when ti look at the components section, there is no option for a Loader component.  Do I need Flash MX 2004 or am I missing something?  Can I use something other than a loader control?
bmcclearyAuthor Commented:
Thanks for the info... it did require Flash MX 2004
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.