Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="320" height="320">
  <param name="movie" value="myFlashMovie.fla">
      <param name="myFileNameVariable" value="/images/somefile.jpg">
</object>
0
bmccleary
Asked:
bmccleary
2 Solutions
 
DrakkonCommented:
I bleieve it goes like you have but:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,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="http://www.macromedia.com/go/getflashplayer" />
</object>

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"


0
 
vickerleungCommented:
bmccleary,

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 :)
0
 
dutchfoxerCommented:
Simple:
<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!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

http://www.macromedia.com/support/flash/ts/documents/java_script_comm.htm
0
 
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?
0
 
bmcclearyAuthor Commented:
Thanks for the info... it did require Flash MX 2004
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now