Note that there are some explanatory texts on larger screens.

plurals
  1. POJS callback that fires when JS exposed methods available on flash DOM object?
    primarykey
    data
    text
    <p>I have a flash object embedded into an Angular JS directive using the swf-object library. This is done in the link function. I am trying to develop a basic interface to the object via JavaScript so that I can change the position of some action-script Shape objects. I want to grab the initial position coordinates from the flash object within the link function so that I can initially populate local scope variables and bind to the view.</p> <pre><code>app.directive("flashTest", function() { return { restrict: "E", // add to a div scope: true, templateUrl: "flash/flash-test.html", link: function($scope, element) { /* Embed the swf */ var flashVars= {}, flashParams= { allowScriptAccess: "always", allowFullScreen: "true" }, attributes= {}; // embed swfobject.embedSWF( "/public/assets/flash/as-test/Main.swf", "flash", "550", "400", "11", "/public/assets/flash/expressInstall.swf", flashVars, flashParams, attributes ) var $elResetButton = element.find("button"), flashDOMObject = document.getElementById("flash"); // setup scoped variables $scope.j1x = flashDOMObject.j1x(); $scope.j1y = flashDOMObject.j1y(); $scope.j2x = flashDOMObject.j2x(); $scope.j2y = flashDOMObject.j2y(); $scope.j3x = flashDOMObject.j3x(); $scope.j3y = flashDOMObject.j3y(); // setup callbacks/watchers $scope.$watch("j1x", function() { flashDOMObject.setJ1x($scope.j1x) }); $elResetButton.bind("click", reset); function reset() { flashDOMObject.reset(); } } }; }); </code></pre> <p>However, <code>flashDOMObject</code> does not have the exposed (via ExternalInterface) method <code>j1x()</code> when I try to invoke it. I've debugged this and the reason is the browser has yet to make the http request for the SWF file (and therefore doesn't know about the javascript exposed api). Is there anyway to register a callback for the compilation and <strong>loading</strong> of the assets of the directive template so that I may populate the scope variables once the swf file is loaded?</p> <p><strong>UPDATE</strong> Current working solution making use of a timed delay of 50ms after the swf file loaded before using the externally exposed functions on the DOM element:</p> <pre><code>.directive("junctions", function($timeout) { return { restrict: "E", // add to a div scope: true, templateUrl: "flash/flash-test.html", link: function($scope, element) { /* Embed the swf */ var flashVars= {}, flashParams= { allowScriptAccess: "always", allowFullScreen: "true" }, attributes= {}; // embed swfobject.embedSWF( "/public/assets/flash/Junctions.swf", "flash", "550", "400", "11", "/public/assets/flash/expressInstall.swf", flashVars, flashParams, attributes, function() { $timeout(function() { // setup scoped variables $scope.j1x = flashDOMObject.j1x(); // setup callbacks/watchers $scope.$watch("j1x", function() { flashDOMObject.setJ1x($scope.j1x) }); }, 50) } ) var $elResetButton = element.find("button"), flashDOMObject = document.getElementById("flash"); $elResetButton.bind("click", reset); function reset() { flashDOMObject.reset(); $scope.j1x = flashDOMObject.j1x(); } } }; }); </code></pre> <p>Is there a more dependable way of detecting when action-script methods exposed via the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html" rel="nofollow">ExternalInterface</a> api are available to use?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload