Google Answers Logo
View Question
 
Q: Flash using fscommand to call a JavaScript method ( No Answer,   3 Comments )
Question  
Subject: Flash using fscommand to call a JavaScript method
Category: Computers > Graphics
Asked by: kite4hi-ga
List Price: $100.00
Posted: 08 Apr 2005 12:10 PDT
Expires: 08 Apr 2005 15:31 PDT
Question ID: 506864
I want a detailed explanation and a working example of a Flash animation that
using an fscommand to execute a JavaScirpt method in the html page
where the Flash is originating from. This call should be made when user
clicks anywhere on th Flash object.

Explanation would be step by step and simple (assuming person reading
knows how to build flash and how to program in JavaScript).
Example should be be a simple flash object file(openable by Flash
pro), swf file, html source including all JavaScipt code. Basically,
by looking at the examples I should able to recreate it with my live
project.  The examples can be provided via attachments or downloadable
from a provided link.

The JavaScript function that this example Flash should call need be:
function IwillBeCalledFromFlash(arg)
{
   alert('I was called from flash ' + arg);
}

Please do not give us the MacroMedia help files, we already tried that
and did not work. This should be a 10 minute problem to solve who
already did this in past, and I'm looking for such person to answer
this question. If answer and example does not work on our live project
which is a very simple Flash ad, then we may ask the researcher again.
I am looking for answers today.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Flash using fscommand to call a JavaScript method
From: willcodeforfood-ga on 08 Apr 2005 13:00 PDT
 
Here is your sample function in ActionScript:

function sendMessage(msg)
{
	getURL("javascript:flashmsg('" add msg add "')");
}


And on the HTML page here is the corresponding JavaScript function:

function flashmsg(msg) { window.status = msg }

or in your case you need:

function flashmsg(msg) { alert(msg) }
Subject: Re: Flash using fscommand to call a JavaScript method
From: willcodeforfood-ga on 08 Apr 2005 13:04 PDT
 
Put this function in your ActionScript to detect a mouseclick anywhere
on the FLash object:

_root.onClick = function()
{
	sendMessage("You just clicked on me");
}

Note this calls sendMessage() which I defined in the previous comment.
Subject: Re: Flash using fscommand to call a JavaScript method
From: willcodeforfood-ga on 08 Apr 2005 13:30 PDT
 
I double-checked what you asked and I see you are trying to use
fscommand.  I haven't ever been able to get that to work calling
JavaScript.  I did want to make a slight correction to my last post. 
The proper way to trap a mouse click on your Flash object is like
this:

Key.addListener(_root);
_root.onMouseDown = function()
{
	sendMessage("You just clicked on me");
}

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy