w11k-flash is an AngularJS module providing a directive to include flash movies and flex applications into your AngularJS application as well as a thin communication layer for Flash/Flex and AngularJS.
Integrating a Flex application into an AngularJS application is a common usecase of a step-by-step migration of a Flex application to AngularJS.
w11k-flash
and its dependencies via Bowerw11k-flash
and swfobject
)w11k.flash
and w11k.flash.template
to your AngularJS modulew11k-flash
stylesheetBasic usage means you include your Flex application and toggle its visibility but do not communicate with Flex from your AngularJS code nor vice versa.
angular.module('app').controller('DemoCtrl', function ($scope) {
$scope.flash = {
visible: false,
config: {
swfUrl: 'pathTo/your.swf',
width: 600,
height: 180
}
};
$scope.toggle = function () {
$scope.flash.visible = !$scope.flash.visible;
};
});
flash.config
via w11k-flash
attribute to the directive. This config object has to have a property `swfUrl` referencing the flash file to load. You can also pass properties flashvars
, params
, attributes
, width
and height
via the config object. These values are passed to swfobject. See https://code.google.com/p/swfobject for more information.w11k-flash-visible
attribute you can show and hide the Flash/Flex application. The Flash file is loaded lazy and once. If w11k-flash-visible
changes from true to false, the Flash object will be invisible but not removed. If w11k-flash-visible
evaluates to true later on, the Flash object will be visible again without reinitialization.
<div ng-controller="DemoCtrl">
<div w11k-flash="flash.config" w11k-flash-visible="flash.visible"></div>
</div>
In addition to steps described in Basic Usage:
AngularJSAdapter#fireFlashReady
(see next step). Save a reference to the promise in your scope or controller instance to be able to use it later on.
angular.module('app').controller('DemoCtrl', function ($scope) {
$scope.flash = {
config: {
callback: function(flashReadyPromise) {
$scope.flash.ready = flashReadyPromise;
}
}
};
});
AngularJSAdapter
for communication with the AngularJS application in your Flex code. During initialization expose functions you want to be able to call from your AngularJS code. Then call AngularJSAdapter#fireFlashReady
to inform AngularJS about finish of initialization.
private var angularjs :AngularJSAdapter;
protected function talkToFlex(text :String) :String {
// do something with text
return 'Hello! My name is Flex.';
}
protected function application_creationCompleteHandler(event :FlexEvent) :void {
// do all the initialization and then
angularjs = AngularJSAdapter.getInstance();
angularjs.expose("talkToFlex", talkToFlex);
angularjs.fireFlashReady();
}
angular.module('app').controller('DemoCtrl', function ($scope) {
$scope.talkToAngular = function (text) {
// do something with text
return 'Hello, my name is AngularJS';
}
});
AngularJSAdapter#call
. call
expect one mandatory and one optional parameter: the expression to evaluate and a map (locals) to resolve parameters within the expression.
angularjs.call('talkToAngular("Hello")');
angularjs.call('talkToAngular(text)', {text: 'Hello'});
angular.module('app').controller('DemoCtrl', function ($scope) {
$scope.talkToFlex = function (text) {
if (angular.isDefined($scope.flash.ready)) {
$scope.flash.ready.then(function (flashRef) {
$scope.responseFromFlex = flashRef.talkToFlex(text);
});
}
}
});
w11kFlashConfig
to share common configuration. Common configuration and instance configuration will be merged and instance configuration overrides common configuration.
angular.module('app').config(function (w11kFlashConfig) {
w11kFlashConfig.config.swfObject.minFlashVersion = '13.1.17';
});
w11kFlashConfig
can be used also to configure the path to the template the directive should use via templateUrl
. This is an alternative to define a dependency to the w11k.flash.template
module.
angular.module('app').config(function (w11kFlashConfig) {
w11kFlashConfig.templateUrl = 'pathTo/w11k-flash.tpl.html'
});
w11k-flash is licensed under MIT.
w11k-flash is developed and maintained by WeigleWilczek and Philipp Burgmer. All rights reserved.