Copy link to clipboard
Copied
JavaScript in a HTML file:
<script type="text/javascript">
<!--
var flashMovie;
var movieID = 'movie_name';
flashMovie = document.getElementById(movieID);
var p = flashMovie.GetVariable("/:p");
//-->
</script>
HTML:
<embed src="movie_name.swf" quality="high" style="width: 625px; height: 416px; background-color: #999999; vertical-align: middle;" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" id="movie_name" />
This stopped working after replacing previous swf file (Action Script 1) by new one (Action Script 3). Replacing "/:p" by "p" or "movie_name.p" doesn't help.
Variables are declared in:
Windows - Actions
in:
Scene1 - Actions: Frame 2
for example:
var p:Number = 1;
The javascript alert() function returns Null or NaN Instead of values of variables. And the variables don't work obviously in the javascript code.
Copy link to clipboard
Copied
GetVariable != getVariable
Copy link to clipboard
Copied
GetVariable is correct:
TypeError: flashMovie.getVariable is not a function
Copy link to clipboard
Copied
actually, i don't see either one as part of the javascript spec, JavaScript methods index - JavaScript | MDN
Copy link to clipboard
Copied
It works still for previous version of my file and can be find in many websites (i.e. Adobe Director * getVariable() ), forums. If you don't know what it is, do not answer.
Copy link to clipboard
Copied
I know what Director is. getVariable is a Lingo command, and when Macromedia added JavaScript support for Director they had to give a JavaScript syntax variation of all Lingo commands and functions. That didn't mean that the JavaScript language gained all of Director's abilities, it was just a matter of syntax.
Copy link to clipboard
Copied
Darius, trying to order other forum members what to do never ends well, and makes you look childish.
Kglad, getVariable is a method of the Flash plugin. It's been there for a very, very long time.
However, it's also been deprecated for a very long time. The correct approach for communication between the web page and the Flash plugin is to use externalInterface.
Copy link to clipboard
Copied
thanks.
are those methods case-insensitive?
Copy link to clipboard
Copied
Thank you for the url. But could anyone write JavaScript code getting variable value from a swf file ?
Or maybe it needs very severe programming inside .fla and html file ?
That was so simple but programmers spoiled everything. Not everything what is newer is better. This is not only this method but also many other computer software having nothing to do with Adobe flash. Everything is getting more and more complex and slower.
Copy link to clipboard
Copied
use externalinterface to access variables/methods inside the swf, ExternalInterface - Adobe ActionScript® 3 (AS3 ) API Reference
Copy link to clipboard
Copied
Could anybody write code snippet ? Thank you in advance.
Copy link to clipboard
Copied
There are many code snippets in both of the links you've been provided. Just write an AS function that returns the value you need, then call it from JS.
Copy link to clipboard
Copied
Could anybody write an example simple function returning example variable (with explanation where to put such function) and simple javascript code, instead of sending me to urls ? Thank you in advance.