0

I have a swf embedded in another application (Articulate Storyline), and I am using ExternalInterface to retrieve values from this application like so:

stop();

import flash.external.ExternalInterface;

var myFlashVar:Number = ExternalInterface.call('GetPlayer().GetVar',"myStorylineVar");

if (myFlashVar == 1) {
    play();
}

This all works fine, but I would like to know how I continuously listen to the value of "myStorylineVar" so that when it changes, I can perform my actions.

Thanks a lot!

Bolu
  • 8,696
  • 4
  • 38
  • 70
user1525612
  • 1,864
  • 1
  • 21
  • 33

1 Answers1

0

Using ExternalInterface you can also call AS functions from JS code. I think it helps you. Some example:

// as3
ExternalInterface.addCallback("myFunction", myFunctionCallback);

function myFunctionCallback(someArg:String):void {
    doStuff();
}

// js
<script language="JavaScript"> 
    var callResult = flashObject.myFunction("someValue"); 
</script>

Documentation.

So, in your case, when value in js changed you can just call some as3 function and perform actions that you need.

Crabar
  • 1,829
  • 1
  • 14
  • 26
  • Thanks Crabar, but the application in which my swf sits is fairly limited, its a bit like PowerPoint. – user1525612 Nov 25 '14 at 16:09
  • I can but I'm not sure its going to work. Is there any way I can make a continuous loop in actionscript that runs like every tenth of a second or sthing to check if the value of the var has changed? – user1525612 Nov 25 '14 at 16:13
  • You can use Timer for it - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html. But in my opinion, the solution in the answer is better. – Crabar Nov 25 '14 at 16:32