lame tweak to the code to get embedSWF to work

6 views
Skip to first unread message

troyvit

unread,
Oct 16, 2007, 12:30:21 PM10/16/07
to SWFObject
I'm calling embedSWF from a function called via prototype, something
like this:

function callChart() {
// holds a bunch of other functions

function genFlashChart() {

var params=null;
// var flashvars=null;
var attributes = {};
attributes.data='chart-data.php?d=platform,1,2,3,4,5,6,0-
time,sixmo';
var flashvars = {};
flashvars.data=data;

swfobject.embedSWF("open-flash-chart.swf", "crapola3", "700",
"420", "9.0.0", "20swfobject/expressInstall.swf", flashvars);

}

genFlashChart();

}

Then I have prototype's equivalent of an onLoad function to run
callChart.

Well it fails *unless* I change the following code in embedSWF:

addDomLoadEvent(function() {
createSWF(att, par,
document.getElementById(replaceElemIdStr));
createCSS("#" + replaceElemIdStr,
"visibility:visible");
});

to this:

createSWF(att, par,
document.getElementById(replaceElemIdStr));
createCSS("#" + replaceElemIdStr,
"visibility:visible");

... Then it works. This is in FireFox 2.0 Windows, using SWFObject
with open-flash-charts

Any help as to how to avoid this kludge would be greatly appreciated.
I'm sure it's not going to work across platforms, for instance.

troyvit

unread,
Oct 16, 2007, 7:30:17 PM10/16/07
to SWFObject
Well duh! the dom has already loaded so adding crap to addDomLoadEvent
won't do any good! Just doing it works of course. That's fine for me.
I can *sob* live with that. But what happens if you want, say, changes
to form fields to affect your flash file? I want to avoid reloading
the whole page each time. Can anybody point me in the right direction?

troyvit

unread,
Oct 16, 2007, 7:38:50 PM10/16/07
to SWFObject
To put it more succinctly, I want to change the nature of my flash
file using javaScript -- onClicks and such. I had it working in 1.5,
but a bug broke it for FireFox on OS X. Nothing would display --
probably due to a similar bug.

troyvit

unread,
Oct 17, 2007, 10:51:27 AM10/17/07
to SWFObject
Hopefully these notes help somebody else. I discovered createSWF and
am accessing it directly. The only problem is the
el.parentNode.replaceChild function at the end. Every time you make a
change that makes you want to reload your chart that child doesn't
exist anymore, so I have to re-create it. Of course, that leaves the
old chart to deal with. I take it there's a better way to dynamically
reload the swf using this javascript tool.

troyvit

unread,
Oct 17, 2007, 12:36:58 PM10/17/07
to SWFObject
I know I know you've been on the edge of your seats. Here's how to do
it. My javaScript is not the best, and this is somewhat pseudo code,
so clean up as you see fit:

function genFlashChart(width, height, chartid) {
// width is the width of the obj, height is the height,
chartid is the id of the element you want to replace.
// set up your objects
var flashvars = {};
var att = {};
var par = {};
// load up flashvars with data you want to pass to your flash
script
flashvars.data=data;
att.data="open-flash-chart.swf"; // there's the swf file
you're loading
att.width=width;
att.height=height;
att.id=chartid;
att.type="application/x-shockwave-flash"; // re-running this
script via javascript will lose this value unless you have it here
par.flashvars='data='+data;
par.wmode='transparent'; // if you want html to display over
your flash
el=$(chartid); // prototype shortcut
swfobject.createSWF(att, par, el);
// and there.
}

I have some problems getting this to preload in exploder but once the
user clicks a javascript-enabled form element that talks to the
function it loads.

Unknown if it solves the original OS X problem that sent me on this
ride.

On Oct 16, 5:38 pm, troyvit <t...@sphere.com> wrote:

troyvit

unread,
Oct 18, 2007, 11:13:19 AM10/18/07
to SWFObject
For what it's worth the problem with Firefox OS X and openSWF is a non-
issue. The real issue is that if you have an html element with an
opacity setting touching the .swf object, the object disappears in
firefox os x. No workaround that I could find. Sorry if this is OT.

[snip]

Reply all
Reply to author
Forward
0 new messages