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

goog.provide('org.apache.royale.html.MXMLBeadView');

goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.core.IParent');
goog.require('org.apache.royale.core.IStatesImpl');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.ValuesManager');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.ValueChangeEvent');
goog.require('org.apache.royale.html.beads.GroupView');
goog.require('org.apache.royale.states.State');
goog.require('org.apache.royale.utils.MXMLDataInterpreter');
goog.require('org.apache.royale.utils.loadBeadFromValuesManager');
goog.require('org.apache.royale.core.ILayoutHost');
goog.require('org.apache.royale.utils.Language');



/**
 *  Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @extends {org.apache.royale.html.beads.GroupView}
 * @implements {org.apache.royale.core.IStrand}
 * @implements {org.apache.royale.core.ILayoutHost}
 */
org.apache.royale.html.MXMLBeadView = function() {
  org.apache.royale.html.MXMLBeadView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.MXMLBeadView, org.apache.royale.html.beads.GroupView);


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


/**
 *  @copy org.apache.royale.core.Application#generateMXMLAttributes()
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {Array} data
 */
org.apache.royale.html.MXMLBeadView.prototype.generateMXMLAttributes = function(data) {
  org.apache.royale.utils.MXMLDataInterpreter.generateMXMLProperties(this, data);
};


/**
 * @export
 * @type {Array}
 */
org.apache.royale.html.MXMLBeadView.prototype.mxmlContent;


/**
 * @private
 * @type {Array}
 */
org.apache.royale.html.MXMLBeadView.prototype.org_apache_royale_html_MXMLBeadView__states;


/**
 *  <code>true</code> if the array of states
 *  contains a state with this name.
 *
 *  @asparam state The state namem.
 *  @asreturn True if state in state array
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {string} state
 * @return {boolean}
 */
org.apache.royale.html.MXMLBeadView.prototype.hasState = function(state) {
  var foreachiter0_target = this.org_apache_royale_html_MXMLBeadView__states;
  for (var foreachiter0 in foreachiter0_target) 
  {
  var s = foreachiter0_target[foreachiter0];
  {
    if (s.name == state)
      return true;
  }}
  
  return false;
};


/**
 * @private
 * @type {string}
 */
org.apache.royale.html.MXMLBeadView.prototype.org_apache_royale_html_MXMLBeadView__currentState;


/**
 * @private
 * @type {Array}
 */
org.apache.royale.html.MXMLBeadView.prototype.org_apache_royale_html_MXMLBeadView__transitions;


/**
 * @export
 * @type {Array}
 */
org.apache.royale.html.MXMLBeadView.prototype.beads;


/**
 * @private
 * @type {Array}
 */
org.apache.royale.html.MXMLBeadView.prototype.org_apache_royale_html_MXMLBeadView__beads;


/**
 *  @copy org.apache.royale.core.IStrand#addBead()
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {org.apache.royale.core.IBead} bead
 */
org.apache.royale.html.MXMLBeadView.prototype.addBead = function(bead) {
  if (!this.org_apache_royale_html_MXMLBeadView__beads)
    this.org_apache_royale_html_MXMLBeadView__beads = [];
  this.org_apache_royale_html_MXMLBeadView__beads.push(bead);
  bead.strand = this;
};


/**
 *  @copy org.apache.royale.core.IStrand#getBeadByType()
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {Object} classOrInterface
 * @return {org.apache.royale.core.IBead}
 */
org.apache.royale.html.MXMLBeadView.prototype.getBeadByType = function(classOrInterface) {
  var foreachiter1_target = this.org_apache_royale_html_MXMLBeadView__beads;
  for (var foreachiter1 in foreachiter1_target) 
  {
  var bead = foreachiter1_target[foreachiter1];
  {
    if (org.apache.royale.utils.Language.is(bead, classOrInterface))
      return bead;
  }}
  
  return null;
};


/**
 *  @copy org.apache.royale.core.IStrand#removeBead()
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @export
 * @param {org.apache.royale.core.IBead} value
 * @return {org.apache.royale.core.IBead}
 */
org.apache.royale.html.MXMLBeadView.prototype.removeBead = function(value) {
  var /** @type {number} */ n = this.org_apache_royale_html_MXMLBeadView__beads.length;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    var /** @type {org.apache.royale.core.IBead} */ bead = this.org_apache_royale_html_MXMLBeadView__beads[i];
    if (bead == value) {
      this.org_apache_royale_html_MXMLBeadView__beads.splice(i, 1);
      return bead;
    }
  }
  return null;
};


org.apache.royale.html.MXMLBeadView.prototype.set__strand = function(value) {
  org.apache.royale.html.MXMLBeadView.superClass_.set__strand.apply(this, [ value] );
  org.apache.royale.core.ValuesManager["valuesImpl"].init(this);
  this.dispatchEvent(new org.apache.royale.events.Event("strandChanged"));
  var foreachiter2_target = this.beads;
  for (var foreachiter2 in foreachiter2_target) 
  {
  var bead = foreachiter2_target[foreachiter2];
  
    this.addBead(bead);}
  
  this.dispatchEvent(new org.apache.royale.events.Event("beadsAdded"));
  org.apache.royale.utils.MXMLDataInterpreter.generateMXMLInstances(this, value, this.MXMLDescriptor);
  this.dispatchEvent(new org.apache.royale.events.Event("childrenAdded"));
  this.dispatchEvent(new org.apache.royale.events.Event("initBindings"));
  this.dispatchEvent(new org.apache.royale.events.Event("initComplete"));
};


org.apache.royale.html.MXMLBeadView.prototype.get__model = function() {
  return this._strand["model"];
};


org.apache.royale.html.MXMLBeadView.prototype.get__MXMLDescriptor = function() {
  return null;
};


org.apache.royale.html.MXMLBeadView.prototype.get__states = function() {
  return this.org_apache_royale_html_MXMLBeadView__states;
};


org.apache.royale.html.MXMLBeadView.prototype.set__states = function(value) {
  this.org_apache_royale_html_MXMLBeadView__states = value;
  this.org_apache_royale_html_MXMLBeadView__currentState = org.apache.royale.utils.Language.string(this.org_apache_royale_html_MXMLBeadView__states[0].name);
  try {
    org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.core.IStatesImpl, "iStatesImpl", this);
  } catch (e) {
    
  }
};


org.apache.royale.html.MXMLBeadView.prototype.get__currentState = function() {
  return this.org_apache_royale_html_MXMLBeadView__currentState;
};


org.apache.royale.html.MXMLBeadView.prototype.set__currentState = function(value) {
  var /** @type {org.apache.royale.events.ValueChangeEvent} */ event = new org.apache.royale.events.ValueChangeEvent("currentStateChange", false, false, this.org_apache_royale_html_MXMLBeadView__currentState, value);
  this.org_apache_royale_html_MXMLBeadView__currentState = value;
  this.dispatchEvent(event);
};


org.apache.royale.html.MXMLBeadView.prototype.get__transitions = function() {
  return this.org_apache_royale_html_MXMLBeadView__transitions;
};


org.apache.royale.html.MXMLBeadView.prototype.set__transitions = function(value) {
  this.org_apache_royale_html_MXMLBeadView__transitions = value;
};


Object.defineProperties(org.apache.royale.html.MXMLBeadView.prototype, /** @lends {org.apache.royale.html.MXMLBeadView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.MXMLBeadView.prototype.set__strand},
/**
  * @export
  * @type {Object} */
model: {
get: org.apache.royale.html.MXMLBeadView.prototype.get__model},
/**
  * @export
  * @type {Array} */
MXMLDescriptor: {
get: org.apache.royale.html.MXMLBeadView.prototype.get__MXMLDescriptor},
/**
  * @export
  * @type {Array} */
states: {
get: org.apache.royale.html.MXMLBeadView.prototype.get__states,
set: org.apache.royale.html.MXMLBeadView.prototype.set__states},
/**
  * @export
  * @type {string} */
currentState: {
get: org.apache.royale.html.MXMLBeadView.prototype.get__currentState,
set: org.apache.royale.html.MXMLBeadView.prototype.set__currentState},
/**
  * @export
  * @type {Array} */
transitions: {
get: org.apache.royale.html.MXMLBeadView.prototype.get__transitions,
set: org.apache.royale.html.MXMLBeadView.prototype.set__transitions}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.MXMLBeadView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {
      return {
        'mxmlContent': { type: 'Array'},
        'beads': { type: 'Array'}
      };
    },
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.MXMLBeadView', metadata: function () { return [ { name: 'Bindable', args: [ { key: '', value: 'strandChanged' } ] } ]; }},
        'model': { type: 'Object', access: 'readonly', declaredBy: 'org.apache.royale.html.MXMLBeadView', metadata: function () { return [ { name: 'Bindable', args: [ { key: '', value: '__NoChangeEvent__' } ] } ]; }},
        'MXMLDescriptor': { type: 'Array', access: 'readonly', declaredBy: 'org.apache.royale.html.MXMLBeadView'},
        'states': { type: 'Array', access: 'readwrite', declaredBy: 'org.apache.royale.html.MXMLBeadView'},
        'currentState': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.html.MXMLBeadView', metadata: function () { return [ { name: 'Bindable', args: [ { key: '', value: 'currentStateChange' } ] } ]; }},
        'transitions': { type: 'Array', access: 'readwrite', declaredBy: 'org.apache.royale.html.MXMLBeadView'}
      };
    },
    methods: function () {
      return {
        'MXMLBeadView': { type: '', declaredBy: 'org.apache.royale.html.MXMLBeadView'},
        'generateMXMLAttributes': { type: 'void', declaredBy: 'org.apache.royale.html.MXMLBeadView', parameters: function () { return [  { index: 1, type: 'Array', optional: false } ]; }},
        'hasState': { type: 'Boolean', declaredBy: 'org.apache.royale.html.MXMLBeadView', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
        'addBead': { type: 'void', declaredBy: 'org.apache.royale.html.MXMLBeadView', parameters: function () { return [  { index: 1, type: 'org.apache.royale.core.IBead', optional: false } ]; }},
        'getBeadByType': { type: 'org.apache.royale.core.IBead', declaredBy: 'org.apache.royale.html.MXMLBeadView', parameters: function () { return [  { index: 1, type: 'Class', optional: false } ]; }},
        'removeBead': { type: 'org.apache.royale.core.IBead', declaredBy: 'org.apache.royale.html.MXMLBeadView', parameters: function () { return [  { index: 1, type: 'org.apache.royale.core.IBead', optional: false } ]; }}
      };
    },
    metadata: function () { return [  ]; }
  };
};