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

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

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.EventDispatcher');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @extends {org.apache.royale.events.EventDispatcher}
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.html.beads.ThrottleBead = function() {
  org.apache.royale.html.beads.ThrottleBead.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.ThrottleBead, org.apache.royale.events.EventDispatcher);


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


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


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


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.ThrottleBead.prototype.org_apache_royale_html_beads_ThrottleBead__interval = 500;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.ThrottleBead.prototype.org_apache_royale_html_beads_ThrottleBead_timeoutId = NaN;


/**
 * @private
 */
org.apache.royale.html.beads.ThrottleBead.prototype.org_apache_royale_html_beads_ThrottleBead_originalEventDispatched = function() {
  if (isNaN(this.org_apache_royale_html_beads_ThrottleBead_timeoutId)) {
    this.org_apache_royale_html_beads_ThrottleBead_timeoutId = setTimeout(org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_ThrottleBead_throwEventWhenFinished, this, 'throwEventWhenFinished'), this.interval);
    this.dispatchEvent(new org.apache.royale.events.Event("startingThrottle"));
  } else {
    clearTimeout(this.org_apache_royale_html_beads_ThrottleBead_timeoutId);
    this.org_apache_royale_html_beads_ThrottleBead_timeoutId = setTimeout(org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_ThrottleBead_throwEventWhenFinished, this, 'throwEventWhenFinished'), this.interval);
  }
};


/**
 * @private
 */
org.apache.royale.html.beads.ThrottleBead.prototype.org_apache_royale_html_beads_ThrottleBead_throwEventWhenFinished = function() {
  clearTimeout(this.org_apache_royale_html_beads_ThrottleBead_timeoutId);
  this.org_apache_royale_html_beads_ThrottleBead_timeoutId = NaN;
  this.dispatchEvent(new org.apache.royale.events.Event("finishedThrottle"));
};


org.apache.royale.html.beads.ThrottleBead.prototype.get__event = function() {
  return this.org_apache_royale_html_beads_ThrottleBead__event;
};


org.apache.royale.html.beads.ThrottleBead.prototype.set__event = function(value) {
  this.org_apache_royale_html_beads_ThrottleBead__event = value;
};


org.apache.royale.html.beads.ThrottleBead.prototype.get__interval = function() {
  return this.org_apache_royale_html_beads_ThrottleBead__interval;
};


org.apache.royale.html.beads.ThrottleBead.prototype.set__interval = function(value) {
  this.org_apache_royale_html_beads_ThrottleBead__interval = value;
};


org.apache.royale.html.beads.ThrottleBead.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_ThrottleBead__strand = value;
  this.org_apache_royale_html_beads_ThrottleBead_host.addEventListener(this.event, org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_ThrottleBead_originalEventDispatched, this, 'originalEventDispatched'));
};


org.apache.royale.html.beads.ThrottleBead.prototype.get__org_apache_royale_html_beads_ThrottleBead_host = function() {
  return org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_ThrottleBead__strand, org.apache.royale.events.IEventDispatcher);
};


Object.defineProperties(org.apache.royale.html.beads.ThrottleBead.prototype, /** @lends {org.apache.royale.html.beads.ThrottleBead.prototype} */ {
/**
  * @export
  * @type {string} */
event: {
get: org.apache.royale.html.beads.ThrottleBead.prototype.get__event,
set: org.apache.royale.html.beads.ThrottleBead.prototype.set__event},
/**
  * @export
  * @type {number} */
interval: {
get: org.apache.royale.html.beads.ThrottleBead.prototype.get__interval,
set: org.apache.royale.html.beads.ThrottleBead.prototype.set__interval},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.ThrottleBead.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.events.IEventDispatcher} */
org_apache_royale_html_beads_ThrottleBead_host: {
get: org.apache.royale.html.beads.ThrottleBead.prototype.get__org_apache_royale_html_beads_ThrottleBead_host}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.ThrottleBead.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'event': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.ThrottleBead'},
        'interval': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.ThrottleBead'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.beads.ThrottleBead'}
      };
    },
    methods: function () {
      return {
        'ThrottleBead': { type: '', declaredBy: 'org.apache.royale.html.beads.ThrottleBead'}
      };
    },
    metadata: function () { return [  ]; }
  };
};