Skip to main content
Participating Frequently
July 20, 2007
Question

Can HTML affect embeded FLASH

  • July 20, 2007
  • 5 replies
  • 371 views
I am trying to find out if there is any way to have the HTML send informaion to the embedded FLASH file. I need to change 2 peices of information on the FLASH file when it loads on the page (based on the page it comes up on.) Is there a way to have the HTML send a message to FLASH that says use "pic_2.jpg" or a way for Flash to look into the HTML to find its directive. Better yet, is there a way to let flash know what file it is within, and search the XML file based on the parameter of location? Please help.
This topic has been closed for replies.

5 replies

Inspiring
July 20, 2007
Are you saying that your actual command is
empty.loadMovie(imageFilename);? If so, is there a reason why you
included the quotes in your reproduction below?

Also, you seem to have omitted the _level0 reference. It should be:
_level0.imageFilename. This is where the variable is stored and if this
command is being called from within a movie clip or some other object,
it's very likely that that object doesn't have this variable.

As a test, try the following:

Create a dynamic text field on your _root timeline named "myField"
(instance name). When you're at the point where you're trying to load
the image, add the following like of code (and don't forget the _root!):
_root.myField.text='local imageFilename='+imageFilename+' --
_level0.imageFilename='+_level0.imageFilename;

This should show you if it's simply that you're forgetting the _level0
or if the variable isn't being passed in.

What do you see?

Patrick

adjourney wrote:
> I found a link on FlashVars - and followed it to
> http://www.permadi.com/tutorial/flashVars/ - which shows how to do basically
> what I am after. The code they reference says:
>
> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
> codebase="" http://macromedia.com/cabs/swflash.cab#version=6,0,0,0""
> WIDTH="250" HEIGHT="250" id="flaMovie1" ALIGN="CENTER">
> <PARAM NAME=movie VALUE="flaMovie1.swf">
> <PARAM NAME=FlashVars VALUE="imageFilename=images%2Fimage1%2Ejpg">
> <PARAM NAME=quality VALUE=high>
> <PARAM NAME=bgcolor VALUE=#FFFFFF>
> <embed src="flaMovie1.swf" FlashVars="imageFilename=images%2Fimage1%2Ejpg"
> quality="high" bgcolor="#FFFFFF" WIDTH="250" HEIGHT="250"
> NAME="flaMovie1" ALIGN TYPE="application/x-shockwave-flash"
> PLUGINSPAGE=" http://www.macromedia.com/go/getflashplayer">
> </OBJECT>
>
> Question though - I created an empty MC and have script tht simply reads:
> empty.loadMovie("imageFilename");
> >> and I have tried it without the "" - what am I missing - cause I can't get
> it to work. (I have the images in a folder byt the requested name. . . )
>

--
http://www.baynewmedia.com
Faster, easier, better...ActionScript development taken to new heights.
Download the BNMAPI today. You'll wonder how you ever did without it!
Available for ActionScript 2.0/3.0.
adjourneyAuthor
Participating Frequently
July 20, 2007
I found a link on FlashVars - and followed it to http://www.permadi.com/tutorial/flashVars/ - which shows how to do basically what I am after. The code they reference says:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="" http://macromedia.com/cabs/swflash.cab#version=6,0,0,0""
WIDTH="250" HEIGHT="250" id="flaMovie1" ALIGN="CENTER">
<PARAM NAME=movie VALUE="flaMovie1.swf">
<PARAM NAME=FlashVars VALUE="imageFilename=images%2Fimage1%2Ejpg">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<embed src="flaMovie1.swf" FlashVars="imageFilename=images%2Fimage1%2Ejpg"
quality="high" bgcolor="#FFFFFF" WIDTH="250" HEIGHT="250"
NAME="flaMovie1" ALIGN TYPE="application/x-shockwave-flash"
PLUGINSPAGE=" http://www.macromedia.com/go/getflashplayer">
</OBJECT>

Question though - I created an empty MC and have script tht simply reads:
empty.loadMovie("imageFilename");
>> and I have tried it without the "" - what am I missing - cause I can't get it to work. (I have the images in a folder byt the requested name. . . )
Inspiring
July 20, 2007
Hi adjourney,

External images should work in the same way (via flashvars). You can do
this in a two step process as you suggested, or directly via the
embedding variables. I'll assume you want the simpler of the two so you
would do something like this:

The HTML embedding code would look like this:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
width="354" height="63" id="myFlashThing" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="flashvars" value="imageFile=myImage.jpg" />
<param name="movie" value="flashFile.swf" /><param name="quality"
value="high" /><param name="bgcolor" value="#cccccc" /> <embed
src="flashFile.swf" quality="high" bgcolor="#cccccc" width="354"
height="63" name="forumLogo" align="middle"
allowScriptAccess="sameDomain" allowFullScreen="false"
flashvars="imageFile=myImage.jpg" type="application/x-shockwave-flash"
pluginspage=" http://www.macromedia.com/go/getflashplayer" />

Notice that you need to include the file name two...once as a "param"
and then again in the "embed" tag. This is done to compensate for
differences between FireFox/Mozilla browsers and InternetExplorer-style
browsers.

In Flash, getting the image file name couldn't be easier. In
ActionScript 2.0, this is simply available as: _level0.imageFile
In ActionScript 3.0, this is available as:
this.loaderInfo.parameters.imageFile from the class that's associated
with the main movie clip (the Document class).

Now you simply take this value and use a loadMovie or Loader instance to
get your image.

If you wanted to specify an XML file and then some identified within it,
the flashvar would look something like this:

xmlFile=data.xml&offset=5

And this would be received as two separate values in Flash:
_level0.xmlFile and _level0.offset (and the associated ones for AS 3).

Of course this is a bit of overkill...if you're specifying a file and
then hardcoding a link within that file...you might as well specify the
file right off the top. But I guess that's up to you.

Good luck,
Patrick


adjourney wrote:
> It seems that through this I can change the text contents, but what if I wish
> to point to an external image, and want to load that jpg into an empty movie
> clip within Flash. How do I do that? I suppose I could assign a value to a
> variable (say "image" = 5) and then look up the XML to pull the variable (grabs
> image definition 5, and pulls the referenced image). Am I on the right track,
> or am I shooting beyond capability (of my own I am sure - but what of Flash)?
>

--
http://www.baynewmedia.com
Faster, easier, better...ActionScript development taken to new heights.
Download the BNMAPI today. You'll wonder how you ever did without it!
Available for ActionScript 2.0/3.0.
adjourneyAuthor
Participating Frequently
July 20, 2007
It seems that through this I can change the text contents, but what if I wish to point to an external image, and want to load that jpg into an empty movie clip within Flash. How do I do that? I suppose I could assign a value to a variable (say "image" = 5) and then look up the XML to pull the variable (grabs image definition 5, and pulls the referenced image). Am I on the right track, or am I shooting beyond capability (of my own I am sure - but what of Flash)?
kglad
Community Expert
Community Expert
July 20, 2007