Re: [flexcoders] Is there a javascript flashObj.callFunction(), l ike setVariable?

2005-04-28 Thread John Dowdell
I think this is How can the various browsers talk to the Macromedia Flash 
Player?

Here's a weird URL with many screencaptures, but should list or link to the 
Player's inbound API:
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?event=viewid=KC.tn_15683extid=tn_15683dialogID=7481736iterationID=1sessionID=96301dc81d7227e49115stateID=0%200%207485611mode=simple#jtfc

(I don't recall whether these offer external access to root-level or targeted 
in-swf functions, and scanning these documents does not seem to quickly reveal 
the answer as previous versions of these documents did.)

Browsers vary in their support. Netscape and Mozilla browsers were the ones who 
*initiated* this kind of intercommunication. The material on the website 
doesn't 
seem as easy to navigate as in previous years, but current browser support 
should be listed at least in the Release Notes for each Player:
http://www.macromedia.com/support/documentation/en/flash/releasenotes.html

Summary: Browser/plugin intercommunication has been noble in theory since 1996, 
but still isn't really all that practical, unless you *know* your audience will 
be in standard configurations of IE/Win, or Java-enabled Firefox, or both. This 
may change in the future as new intercommunication APIs come on line:
http://www.mozillazine.org/talkback.html?article=4923

jd



-- 
John Dowdell . Macromedia Developer Support . San Francisco CA USA
Weblog: http://www.macromedia.com/go/blog_jd
Aggregator: http://www.macromedia.com/go/weblogs
Technotes: http://www.macromedia.com/support/
Spam killed my private email -- public record is best, thanks.


 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Is there a javascript flashObj.callFunction(), l ike setVariable?

2005-04-27 Thread Matt Chotin
Title: Is there a javascript flashObj.callFunction(), like setVariable?










I believe youre only allowed to
call setVariable. And yes you can create a setter and do it that way.



Matt











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] 
Sent: Wednesday, April 27, 2005
9:26 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Is there a
_javascript_ flashObj.callFunction(), like setVariable?





Using
javasript in a custom HTML wrapper, Is there flashObj.callFunction(),
like there is a setVariable() method?

Or
will
setVariable() work with a setter method? (Hmm, surely I
can
create
a setter in mxml, right?)

Tracy












Yahoo! Groups Links

To visit your group on the web, go to:http://groups.yahoo.com/group/flexcoders/
To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.












RE: [flexcoders] Is there a javascript flashObj.callFunction(), l ike setVariable?

2005-04-27 Thread Abdul Qabiz
Hi Tracy,
 
There is no callFunction(..) like method for flash activeX or plugin. But
there is setVariable(..) method. 
 
Yes, you can set a variable or setter from Javascript using setVariable
function. I have create a example, it allows you to execute flex function
from javascript...

It's very basic example but you can adopt similar approach and do it more OO
way by creating classes in JS and AS...

 
1) FlexJSExample.jsp
 
%@ taglib uri=FlexTagLib prefix=mm %
HTML
HEAD
meta http-equiv=Content-Type content=text/html;  charset=ISO-8859-1
TITLEFlex-JS Communication Demo/TITLE
 

script language=javascript
   
 
//this function return to Flash ActiveX Object or Plugin depending upon
browser
//it takes care for browser type and returns the proper reference.
//Accepts the id or name of OBJECT or EMBED tag respectively
function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  
  if (navigator.appName.indexOf (Microsoft) !=-1) {
return window[movieName];
 
  } else {
   return window.document[movieName];
  }
}
 

/**###**/
//success flag, set by flash/flex app
var bFunctionCallFinished = true;
//param delimiter, kind of unique string
var paramDelimiter =  --$$###$$##$$--;
 
//this function would call a flash/flex function.
function callFlashFunction(functionName, paramsArray)
{
if(bFunctionCallFinished) 
{
//Get the reference so activeX or Plugin.
 var flashObject  = thisMovie(flexApp);
 
bFunctionCallFinished = false;
flashObject.SetVariable(functionName, functionName);
flashObject.SetVariable(functionParams,
paramsArray.join(paramDelimiter));
flashObject.SetVariable(commitFunctionCall, true);
}
else
{
//if previous function call is still being run, you can use
setTimeOut etc to call it little later...
}

}
 
/**###**/
 
/script
/HEAD
BODY bgcolor=#FF
 
!-- look at flexApp id/name, thats being used(in JS) to get the reference
of Flash Player in browser. --
 
mm:mxml border=1 id=flexApp name=flexApp
 
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; width=600
height=600 backgroundColor=#FF 
 mx:Script
 ![CDATA[
 
 
 /****/
 
 //the name of the function to be called.
  var functionName:String;
  //the params delimited by paramDelimiter
  var functionParams:String;
  //param delemiter, kind of unique string 
  var paramDelimiter =  --$$###$$##$$--;
  
  //setter, which executes the function and send the success flag back to
javascript
  public function set commitFunctionCall(flag:Boolean):Void
  {
  var func:Function = this[functionName];
  
  func.apply(this, functionParams.split(paramDelimiter));
  getURL(javascript:bFunctionCallFinished=true;void(0));
  
 }
 
 /****/
 
 
 function sayHi(name:String)
 {
 alert(Hi  + name);
 _ta.text += name + newline;
 }
 
 
 function setNum()
 {
 var n = arguments.length;
 for(var i=0;in;i++) 
 {
 _ta.text += arguments[i] + newline;
 }
 } 
 
  
  
 ]]
 
 
 /mx:Script
 mx:TextArea id=_ta width=200 height=200/
  
/mx:Application
/mm:mxml
 
input type=button value=Say Hi onclick=callFlashFunction('sayHi',
['Abdul']);/
input type=button value=Send Number
onclick=callFlashFunction('setNum', [1,2,3]);/
/BODY
 
/HTML
 
 
 
 
BTW! Based on above principle, I made a JS-Flash libarary long back. Take a
look at it for an idea...

http://www.abdulqabiz.com/files/JSFC/JSFCommunicator%20Library.htm


Hope that helps

-abdul
 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 28, 2005 9:56 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Is there a javascript flashObj.callFunction(), like
setVariable?



Using javasript in a custom HTML wrapper, Is there flashObj.callFunction(),
like there is a setVariable() method?

Or will setVariable() work with a setter method? (Hmm, surely I can create a
setter in mxml, right?)

Tracy




Yahoo! Groups Links


*   To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
  
*   To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 
  
*   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
http://docs.yahoo.com/info/terms/ . 






 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL