Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getVariable() stopped working

Explorer ,
Mar 22, 2017 Mar 22, 2017

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.

795
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

GetVariable != getVariable

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

GetVariable is correct:

TypeError: flashMovie.getVariable is not a function

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

actually, i don't see either one as part of the javascript spec, JavaScript methods index - JavaScript | MDN

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2017 Mar 22, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2017 Mar 22, 2017

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.

Adobe Flash Platform * External API example: Communicating between ActionScript and JavaScript in a ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

thanks.

are those methods case-insensitive?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

use externalinterface to access variables/methods inside the swf, ExternalInterface - Adobe ActionScript® 3 (AS3 ) API Reference

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

Could anybody write code snippet ? Thank you in advance.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2017 Mar 22, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines