core_setup.as

来自「这是《Flash MX编程与创意实现》的源代码」· AS 代码 · 共 52 行

AS
52
字号
/*
  Core Setup v1.1
  Oct. 29, 2002
  (c) 2002 Robert Penner
  
	  Object.superCon()
	  Function.extend()
	  MovieClip.addListener()
	  onEnterFrame event broadcasting
  
  Dependencies: 
  - ASBroadcaster (undocumented feature of Flash MX)
  - ASSetPropFlags (undocumented feature of Flash 5+)
  
  Discussed in Chapters 2 and 6 of 
  Robert Penner's Programming Macromedia Flash MX
  Used by Motion, Tween, PhysicsParticle, ElasticForce, and other classes
  
  http://www.robertpenner.com/profmx
  http://www.amazon.com/exec/obidos/ASIN/0072223561/robertpennerc-20
*/



// call superclass constructor
// usage: function Child () { this.superCon (arg1, arg2...); }
Object.prototype.superCon = function () {
	arguments.caller.prototype.__proto__.constructor.apply (this, arguments);
};
ASSetPropFlags (Object.prototype, null, 1);


// inherit from a superclass
// usage: Child.extend (Parent);
Function.prototype.extend = function (superclass) {
	this.prototype.__proto__ = superclass.prototype;
};
ASSetPropFlags (Function.prototype, null, 1);


// set up MovieClip.addListener() if it doesn't exist
// and create an empty clip to broadcast onEnterFrame events
if (typeof MovieClip.addListener != 'function') {
	ASBroadcaster.initialize (MovieClip);
	var mc = _level0.createEmptyMovieClip ("$enterframe_source", 9876);
	mc.onEnterFrame = function () { MovieClip.broadcastMessage ("onEnterFrame") };
	delete mc;
}

trace (">> core setup loaded");

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?