Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2005, 07:30 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default load swf file with JavaScript

Is there any way to load swf file with JavaScript? Has anyone got any code for this?

I have posted a message in the Flash forum, with a problem with viewing my SWF file in IE - no problem in FF though.

Cannot find a solution on Google, doesnt seem to have cropped up before???

i am using the <object> tag with the <embed> tag inside it.

Cheers.

Picco

www.crmpicco.co.uk
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old November 4th, 2005, 07:38 AM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is a Flash/Javascript integration kit developed by a couple of guys at Macromedia.

It may be a little overblown for what you need to do, but one of it's features is loading a Flash Movie into a page via JavaScript.

It's not an official Macromedia product, but it is free and I've never had any problems with it. If you're interested you can find it at http://www.macromedia.com/go/flashjavascript
 
Old November 4th, 2005, 08:02 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

cheers nmunky, i downloaded it.

but....not sure how to use it?? :-)

I read the readme file but its has no mention on what to run/execute??

Have you used it before?

Cheers Mate,

Picco

www.crmpicco.co.uk
 
Old November 4th, 2005, 09:26 AM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I've used it and it works fine for me. Here's what I did in my implementation:

1) copy the following files into your site directory from the zip file you downloaded:
JavaScriptFlashGateway.js
JavaScriptFlashGateway.swf
JavaScriptProxy.as
JavaScriptSerializer.as

2) reference the javascript file in your page <head> tag:
<script type="text/javascript" src="JavaScriptFlashGateway.js"></script>

3) set up the variables/objects in JavaScript to be used to create the Flash movie:
<script language="javascript">
var lcId = new Date().getTime();
var flashProxy = new FlashProxy(lcId, "JavaScriptFlashGateway.swf");
</script>

4) call the creation function in the relevant part of your page:
<script type="text/javascript">
var sample = new FlashTag("yourMovie.swf", 575, 800, "7,0,19,0");
sample.setFlashvars("lcId=" + lcId);
sample.write(document);
</script>

note: the 4 parameters of the FlashTag call are (in order) filename of your movie, width of your movie, height of your movie, version of flash that the movie is encoded in (if you're not sure about this, just check out a regular embedded flash movie, it's in the parameters)

Like I said, this may be a bit overblown for what you're attempting to do, but it works stably for me, and has the added bonus of passing data back and forth between Flash and JavaScript MUCH easier. If you're into that kind of thing ;)

Hope this helps
 
Old March 25th, 2010, 05:32 PM
Registered User
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default iPad SWF Swap Image with JavaScript

I found a fun piece of code for iPad. It is an example of how to swap a Flash SWF with an image if your user agent is an iPad.

<a href="http://www.combsconsulting.com/ipad-replace-flash-with-image-java-script-example/">http://www.combsconsulting.com/ipad-replace-flash-with-image-java-script-example/</a>





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Insert .swf file in asp.net [email protected] ASP.NET 1.0 and 1.1 Professional 1 October 30th, 2008 09:00 AM
LOAD A XML FILE FROM JAVASCRIPT nen Javascript How-To 1 December 20th, 2004 11:03 AM
swf file sentme_mail Flash (all versions) 1 November 27th, 2004 09:13 PM
SWF File Import Ben Horne Flash (all versions) 2 December 10th, 2003 04:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.