Solved

FSCommand in innerHTML

Posted on 2002-07-24
3
678 Views
Last Modified: 2007-12-19
I am trying to interface Flash with an nTier application that dynamically creates the web pages. These pages are created by Java Servlets generating JavaScript which writes the HTML to the innerHTML property of the layers. There is NO hard coded content at this level in the DOM.

JavaScript functions are no problem and when the VBSCript is Hard Coded, all is OK, but as innerHTML, the VBScript function that is called by the FSCommand just does not seem to exist at runtime (or if it does, Flash can't find it !)

I include a test page which illustrates the problem.

this uses the standard flash sample 'flash_to_javascript.swf'

I can't change the structure of our software so a solution must work with what we've got..


<HTML>
<BODY bgcolor="#FFFFFF">

<div id=component></div>
<div id=vbcode></div>
<script>

var sFlash = '<div id="test1" style="position: absolute; left: 226; top: 281; width: 390; height: 234; clip:rect(0px 390px 234px 0px);"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width=300 height=200 name="myFlash" id="myFlash"><param name=movie value="flash_to_javascript.swf"><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src="flash_to_javascript.swf" quality=high bgcolor=#FFFFFF  width=400 height=250 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="myFlash"></embed></object></div>';
var sVBCode = '<SCRIPT LANGUAGE=VBScript\>\nSub myFlash_FSCommand(ByVal command, ByVal args)\ncall myFlash_DoFSCommand(command, args)\nend sub\n<\/SCRIPT\\>';


document.all.component.innerHTML = sFlash;
document.all.vbcode.innerHTML = sVBCode;

</script>


<!--div id="test1" style="position: absolute; left: 226; top: 281; width: 390; height: 234; clip:rect(0px 390px 234px 0px);"><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width=300 height=200 name='myFlash' id='myFlash'><param name=movie value='flash_to_javascript.swf'><param name=quality value=high><param name=bgcolor value=#FFFFFF><embed src="flash_to_javascript.swf" quality=high bgcolor=#FFFFFF  width=400 height=250 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="myFlash"></embed></object></div>
<div id="test1" style="position: absolute; left: 226; top: 281; width: 390; height: 234; clip:rect(0px 390px 234px 0px);"><SCRIPT LANGUAGE=JavaScript>var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;function myFlash_DoFSCommand(command, args) {var myFlashObj = InternetExplorer ? myFlash : document.myFlash;alert("You entered: " + args);}if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {document.write('<SCRIPT LANGUAGE=VBScript\> \n');document.write('on error resume next \n');document.write('Sub myFlash_FSCommand(ByVal command, ByVal args)\n');document.write(' call myFlash_DoFSCommand(command, args)\n');document.write('end sub\n');document.write('</SCRIPT\> \n');}</SCRIPT></div-->


</BODY>
</HTML>

0
Comment
Question by:chrishorne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:fragalot657
ID: 8401322
Hi Chris,

Very probably by this time you've already found out the solution, or don't need it anymore :) But unfortunately I only just found your question, and since information on this topic is so scarce, I thought I'd share my methods anyway.

The thing is, contrary to what the Macromedia documentation would have you believe, there really is no need for VBScript at all in coupling an FSCommand event to browser scripting. The following construct:

<SCRIPT for=.. event=FSCommand(command, args)>

does exactly the same thing, except that it can also handle Javascript, and has no problems with being softcoded through, for example, innerHTML. Of course it also saves the memory used for running the VBScript environment.

The following code illustrates this:

<HTML><BODY>
<SCRIPT language=JavaScript>
function DoFSCommand(command,args){
     alert(command+','+args);
}
function createflash(){
     flash_frame.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id=flashplayer1 style="width: 400; height: 300">'+
     '<param name="movie" value="fscommand.swf"></object>'+
     '<SCRIPT event=FSCommand(command,args) for=flashplayer1>DoFSCommand(command,args);<\/SCRIPT>';
}
</SCRIPT>
<BUTTON onclick="createflash();">create flash instance</BUTTON>
<div id=flash_frame></div>
</BODY></HTML>

fscommand.swf is simply a flash clip with a random fscommand (in a button event here).

Hope you still have use for it! I didn't do any cross-platform/browser checks yet. But it should at the very least be fine on MS IE 5.0 and up, on windows platforms.

Cheers
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 11298020
PAQed - no points refunded (of 500)

GhostMod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash doesn't load in Iphone and Ipad 22 497
playing flash video on kiosk at startup 6 415
Removing Flash from Website 6 71
HTML 5 video and audio or Flash 1 66
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question