/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\beads\BinaryImageLoader.as
 * org.apache.royale.html.beads.BinaryImageLoader
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.beads.BinaryImageLoader');

goog.require('org.apache.royale.core.IBinaryImage');
goog.require('org.apache.royale.core.IBinaryImageModel');
goog.require('org.apache.royale.core.IImageView');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.utils.URLUtils');
goog.require('org.apache.royale.utils.loadBeadFromValuesManager');
goog.require('org.apache.royale.core.IBinaryImageLoader');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @implements {org.apache.royale.core.IBinaryImageLoader}
 */
org.apache.royale.html.beads.BinaryImageLoader = function() {
};


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.beads.BinaryImageLoader', org.apache.royale.html.beads.BinaryImageLoader);


/**
 * @private
 * @type {string}
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.org_apache_royale_html_beads_BinaryImageLoader__objectURL;


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.org_apache_royale_html_beads_BinaryImageLoader__strand;


/**
 * @private
 * @type {org.apache.royale.core.IBinaryImageModel}
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.org_apache_royale_html_beads_BinaryImageLoader__model;


/**
 * @asprivate
 * @royaleignorecoercion Object
 * @royaleignorecoercion UIBase
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.org_apache_royale_html_beads_BinaryImageLoader_handleBinaryChange = function(event) {
  var /** @type {org.apache.royale.core.IBinaryImageModel} */ m = this.org_apache_royale_html_beads_BinaryImageLoader_model;
  var /** @type {org.apache.royale.core.IImageView} */ imageView = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_BinaryImageLoader__strand.getBeadByType(org.apache.royale.core.IImageView), org.apache.royale.core.IImageView);
  
  if (m.binary) {
    imageView.setupLoader();
    if (this.org_apache_royale_html_beads_BinaryImageLoader__objectURL)
      org.apache.royale.utils.URLUtils.revokeObjectURL(this.org_apache_royale_html_beads_BinaryImageLoader__objectURL);
    var /** @type {Blob} */ blob = new Blob([m.binary.array]);
    this.org_apache_royale_html_beads_BinaryImageLoader__objectURL = org.apache.royale.utils.URLUtils.createObjectURL(blob);
    org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_BinaryImageLoader__strand, org.apache.royale.core.IBinaryImage).applyImageData(this.org_apache_royale_html_beads_BinaryImageLoader__objectURL);
  }
};


org.apache.royale.html.beads.BinaryImageLoader.prototype.get__org_apache_royale_html_beads_BinaryImageLoader_model = function() {
  if (!this.org_apache_royale_html_beads_BinaryImageLoader__model)
    this.org_apache_royale_html_beads_BinaryImageLoader__model = org.apache.royale.utils.Language.as(org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.core.IBinaryImageModel, "iBeadModel", this.org_apache_royale_html_beads_BinaryImageLoader__strand), org.apache.royale.core.IBinaryImageModel);
  return this.org_apache_royale_html_beads_BinaryImageLoader__model;
};


org.apache.royale.html.beads.BinaryImageLoader.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_BinaryImageLoader__strand = value;
  this.org_apache_royale_html_beads_BinaryImageLoader_model.addEventListener("binaryChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_BinaryImageLoader_handleBinaryChange, this, 'handleBinaryChange'));
};


Object.defineProperties(org.apache.royale.html.beads.BinaryImageLoader.prototype, /** @lends {org.apache.royale.html.beads.BinaryImageLoader.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IBinaryImageModel} */
org_apache_royale_html_beads_BinaryImageLoader_model: {
get: org.apache.royale.html.beads.BinaryImageLoader.prototype.get__org_apache_royale_html_beads_BinaryImageLoader_model},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.BinaryImageLoader.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'BinaryImageLoader', qName: 'org.apache.royale.html.beads.BinaryImageLoader', kind: 'class' }], interfaces: [org.apache.royale.core.IBinaryImageLoader] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.BinaryImageLoader.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.beads.BinaryImageLoader'}
      };
    },
    methods: function () {
      return {
        'BinaryImageLoader': { type: '', declaredBy: 'org.apache.royale.html.beads.BinaryImageLoader'}
      };
    }
  };
};