Won't show swf file using dynamic swfobject.embedSWF and fscommand

38 views
Skip to first unread message

Jwos

unread,
Jul 20, 2008, 6:14:27 PM7/20/08
to SWFObject
Using SwfObject 2.1
Html file fs1a.html displays fs1a.swf
dashbroute.js actually displays the fs1a.swf file.
There is a list box where the user can select one of three companies.
When the fscommand button is clicked, "company" is passed with the
company number.
It appears that the javascript is processed, but I never see the
fs1b.swf file displayed.
Any help would be appreciated.

FS1A.HTML
-----------------
<html>
<head>
<title>Dashboard</title>

<script language="JavaScript" src="swfobject.js"></script>
<script language="JavaScript" src="dashbroute.js"></script>
<script type="text/javascript">
if (!window.swfobject_js) { alert('File swfobject.js not found') }
if (!window.dashbroute_js) { alert('File dashbroute.js not found') }
</script>

<!--[if IE]>
<script type="text/javascript" event="FSCommand(command,args)"
for="picMenu">
alert('IE');
// navigator.appName == Microsoft Internet Explorer
picMenu_DoFSCommand(command, args);
</script>
<![endif]-->

<script language="JavaScript">
function openWindow(URL, windowName, windowProperties) {
newWindow = window.open(URL, windowName, windowProperties);
}
function picMenu_DoFSCommand(command, args) {

alert('command:' + command + ', args:' + args);

if (command == 'company')
{
// These parms are currently empty.
var flashvars = {};
var params = {};
var attributes = {
name: "picMenu",
id: "picMenu"
};

var flashfile = 'fs1b.swf';

alert('Flashfile:' + flashfile);

alert('Start flash');

// Start flash.
startflash = swfobject.embedSWF(flashfile, "myContent", "50%", "50%",
"6","", flashvars, params, attributes);
return;

//openWindow('fs1b.swf?company=1', 'newWindow', 'scrollbars=no,
status=yes, toolbar=no, resizable=yes, width=660, height=572, left='+
(screen.width/2 - 660/2)+', top='+(screen.height/2 - 572/2));

// alert('Flash started?');

}
}
</script>

</head>
<body>
<div id="myContent">
<p>Alternative content</p>
</div>
</body>
</html>

DASHBROUTE.JS
--------------------------
// Start the flash file.

alert('dashbroute');

// Variable marker.
var dashbroute_js = 'here';

// Get the value of a specific cookie.
function getCookie(cookie_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(cookie_name + "=");
if (c_start!=-1)
{
c_start=c_start + cookie_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}

// The flash file name is extracted from the current file name.
var filename_ext =
document.location.pathname.substring(document.location.pathname.lastIndexOf('\
\/')+1);
var flashfile = filename_ext.replace(".html", ".swf");
//alert('filename_ext:' + filename_ext);
alert('flashfile:' + flashfile);

userid = getCookie("ngsvli");
//alert('userid:' + userid);

// Set up userid as flash variable. Case sensitive.
var flashvars = {
userid: userid
};

var attributes = {
name: "picMenu",
id: "picMenu"
};

// These parms are currently empty.
var params = {};

// Start flash.
startflash = swfobject.embedSWF(flashfile, "myContent", "100%",
"100%", "6","", flashvars, params, attributes);


John

Bobby

unread,
Jul 21, 2008, 5:08:13 AM7/21/08
to SWFObject

Jwos

unread,
Aug 18, 2008, 7:59:52 PM8/18/08
to SWFObject
I already had that code in my example.

For some reason, the startflash does not work for IQ or FF.

John

Aran Rhee

unread,
Aug 18, 2008, 9:04:33 PM8/18/08
to swfo...@googlegroups.com
@John

"For some reason, the startflash does not work for IQ or FF."

Are you trying to reference the var "startflash"? Because
swfobject.embedSWF() does not return a reference to the swf by calling the
function.

This means startflash = swfobject.embedSWF(....) will always = undefined


Or do you mean the alert('Start flash') line in function
picMenu_DoFSCommand() is never called?


Aran

Jwos

unread,
Aug 28, 2008, 8:14:23 PM8/28/08
to SWFObject
Actually what I'm trying to do is when this page is displayed for the
first time, it will display fs1a.swf.

Then the user will select a company from the list, click the fscommand
button, and display fs1b.swf passing the args parameter.

www.ngsi.com/testflash/test1.html

John

<html>
<head>
<title>Dashboard - 1</title>

<script language="JavaScript" src="swfobject.js"></script>

<!--[if IE]>
<script type="text/javascript" event="FSCommand(command,args)"
for="picMenu">
alert('IE');
// navigator.appName == Microsoft Internet Explorer
picMenu_DoFSCommand(command, args);
</script>
<![endif]-->

<script language="JavaScript">
////////////////////////////////////////////////////////////
// Start flash, not from fscommand.
var flashvars = {};
var params = {};
var attributes = {
name: "picMenu",
id: "picMenu"}
swfobject.embedSWF('fs1a.swf', "myContent", "200%", "200%", "6","",
flashvars, params, attributes);
////////////////////////////////////////////////////////////

function openWindow(URL, windowName, windowProperties) {
newWindow = window.open(URL, windowName, windowProperties);
}

////////////////////////////////////////////////////////////
function picMenu_DoFSCommand(command, args) {

if (command == 'company') {
var flashvars1 = {
company: args
};
var params1 = {};
var attributes1 = {
name: "picMenu1",
id: "picMenu1"}

var flashfile = 'fs1b.swf?company=' + args;

// Start flash from fscommand.
swfobject.embedSWF('fs1b.swf', "myContent1", "200%", "200%", "6","",
flashvars1, params1, attributes1);

}; // End to if (command == 'company')
} // End to function picMenu_DoFSCommand
////////////////////////////////////////////////////////////
</script>

</head>
<body>
<div id="myContent">
<p>Alternative content</p>
</div>
<div id="myContent1">
<p>Alternative content1</p>
</div>

</body>
</html>

Aran Rhee

unread,
Aug 28, 2008, 11:16:15 PM8/28/08
to swfo...@googlegroups.com
Yeah, I understood what you were trying to use on the user side of things. I
was trying to work out where the error was actually occurring.

Here is a fully working version of your code:
http://www.misterhee.com/tests/ngsi3.html

I had to add Philip's nice replace code so that after you clicked on one
company, and his the FS_command button, and then made a new selection, that
it would successfully overwrite the old movie.


Aran

-----Original Message-----
From: swfo...@googlegroups.com [mailto:swfo...@googlegroups.com] On
Behalf Of Jwos
Sent: Friday, 29 August 2008 10:14 AM
To: SWFObject
Subject: Re: Won't show swf file using dynamic swfobject.embedSWF and
fscommand

Jwos

unread,
Sep 3, 2008, 6:18:54 PM9/3/08
to SWFObject
Very nice! I appreciate the effort.
One question: When you click the fs button, how can I replace the fs1a
swf with fs1b swf ?

John

Aran Rhee

unread,
Sep 3, 2008, 7:16:58 PM9/3/08
to swfo...@googlegroups.com
You should be ab le to just change the line:
loadSWF("http://www.ngsi.com/testflash/fs1b.swf", "picMenu1", fv);
 
to:
loadSWF("http://www.ngsi.com/testflash/fs1b.swf", "picMenu", fv);

and in the loadSWF function change the line:
var attributes = { data: url, width:"200%", height:"200%", name: "picMenu1", id: "picMenu1"};
 
to:
var attributes = { data: url, width:"200%", height:"200%", name: "picMenu", id: "picMenu"};
 
 
Aran

Jwos

unread,
Sep 4, 2008, 7:43:13 PM9/4/08
to SWFObject
I tried the changes, but no luck.
If I use FF, I get an error and FF closes.
If I use IE, it doesn't show the other swf.

www.ngsi.com/testflash/fs1anew.html

John

On Sep 3, 4:16 pm, "Aran Rhee" <aran.r...@gmail.com> wrote:
> You should be ab le to just change the line:
> loadSWF("http://www.ngsi.com/testflash/fs1b.swf", "picMenu1", fv);
>
> to:
> loadSWF("http://www.ngsi.com/testflash/fs1b.swf", "picMenu", fv);
>
> and in the loadSWF function change the line:
> var attributes = { data: url, width:"200%", height:"200%", name: "picMenu1",
> id: "picMenu1"};
>
> to:
> var attributes = { data: url, width:"200%", height:"200%", name: "picMenu",
> id: "picMenu"};
>
> Aran
>

Aran Rhee

unread,
Sep 4, 2008, 9:32:07 PM9/4/08
to swfo...@googlegroups.com
For some reason the picMenu div was getting visibility set to hidden. After
talking to Geoff / Bobby I'm sure there is a reason / logic to what is
happening, but I don;t have time to follow up on this myself.

I added swfobject.createCSS("#picMenu", "visibility:visible;"); after the
createSWF() call and all is well.

You can see an example here:
http://www.misterhee.com/tests/ngsi4a.html

Jwos

unread,
Sep 16, 2008, 7:21:42 PM9/16/08
to SWFObject
Tried in FF 2.0.0.16 and got an error from FF. One of those generic
errors.

Aran Rhee

unread,
Sep 17, 2008, 7:18:07 AM9/17/08
to swfo...@googlegroups.com
I don't get any errors in FF myself. You are getting the error in my test
page, or yours?

Jwos

unread,
Sep 17, 2008, 11:59:21 AM9/17/08
to SWFObject
I click on the link http://www.misterhee.com/tests/ngsi4a.html
When the page is displayed, I click on the fs command button and get
the error.
"Error encountered, do you want to report..." That wonderful general
error message box.
IE seems to work ok.

John

Aran Rhee

unread,
Sep 17, 2008, 10:17:07 PM9/17/08
to swfo...@googlegroups.com
Are you running any extensions in FF etc?

I can however crash Safari (PC) with this method.

Realistically, I have spent all the time I can to get this FS_command system
working. It is a really antiquated method of browser < > flash communication
which is not recommended to use any more. For two major flash player
versions, the recommended method is to use ExternalInterface. I would
suggest you implement ExternalInterface for your files, and I think these
issues will go away.

Reply all
Reply to author
Forward
0 new messages