ActionScript 3 博客v0.2

package
{
	dynamic public class Blog extends ActiveRecord
	{
		staticInitializer(prototype.constructor);		
		public function Blog()
		{
		}

	}
}

ActionScript 3 外部文件的加载方法

package {
	import flash.display.Sprite;
	import flash.display.Loader;//Allows you to load an external file
	import flash.net.URLRequest;//This is used to reference the external file
	import flash.filters.DropShadowFilter;
	
	public class LoadingMethods extends Sprite {		
		public function LoadingMethods(){
			init();
		}
		private function init():void {
			/**
			Loading
			*/
			var loader:Loader = new Loader();
			loader.load(new URLRequest("kitten.jpg"));
			addChild(loader);
			loader.x = 150;
			loader.y = 150;
			//For the loaded
			var ds2:DropShadowFilter = new DropShadowFilter(10, 45, 0x00ff00,1,3,2);
			var filterArray2:Array = [ds2];
			loader.filters = filterArray2;
			
			/**
			Embedding
			**/
			//This is from importing the image into the lib and exporting for AS.
			var myImage:Kitten = new Kitten();
			addChild(myImage);
			
			//For the embed
			var ds:DropShadowFilter = new DropShadowFilter(10, 45, 0xff0000,1,3,2);
			var filterArray:Array = [ds];
			myImage.filters = filterArray;
		}
	}
}

ActionScript 3 ActiveRecord v0.2

package
{
	import flash.utils.Proxy;
	import flash.utils.describeType;
	import flash.utils.getDefinitionByName;
	import flash.utils.getQualifiedClassName;
	import flash.utils.flash_proxy;

//	import flash.utils.flash_proxy;
	
	public dynamic class ActiveRecord extends Proxy
	{
		private static var functionsToAdd:Array = ["find_by_name","find_by_id","find_all"];
		protected static var methodFactory:DynamicMethodFactory;
		public function ActiveRecord()
		{
			
		}
		public static function staticInitializer(klass:Class):void{
			var typeInfo:XML = describeType(klass);		
			for each(var s:String in functionsToAdd){
				klass[s] = getMethod(typeInfo.@name,s);
			}
		}
		public static function getMethod(objectName:String,methodName:String):Function{
			return function(...args):Object{return endPoint(objectName,methodName,args);};
		}
		public static function endPoint(objectName:String,methodName:String,...args):Object{
			trace("You called: " + objectName + "." + methodName + "(" + args + ")");
			var klass:Class = getDefinitionByName(objectName) as Class;
			var o:ActiveRecord = new klass();
			return o;
		}
		flash_proxy override function callProperty(method: *, ...args): * {
			try { 		 
				var clazz : Class = getDefinitionByName(getQualifiedClassName(this)) as Class;
				return clazz.prototype[method].apply(method, args);
			}
			catch (e : Error) {
				return methodMissing (method, args);
			}
		}
 		protected function methodMissing(method : *, args : Array) : Object{
			throw( new Error("Method Missing"));
			return null;
		}
	}
}

ActionScript 3 Oman3D - 简单的gotoAndStop按钮功能

function functionName (e:MouseEvent):void{
gotoAndStop("lableName");
}
instanceName.addEventListener(MouseEvent.CLICK, functionName);

ActionScript 3 教程1,Het formulier in mxml

<!-- formulier -->
	<mx:Panel x="10" y="10" width="340" height="254" layout="absolute" id="panReg" title="Registreer">
		<mx:Form x="0" y="0" width="310" height="168">
			<mx:FormItem label="Gebruikersnaam:" >
				<mx:TextInput id="iGebruikersnaam" />
			</mx:FormItem>
			<mx:FormItem label="Wachtwoord:" >
				<mx:TextInput id="iWachtwoord"  displayAsPassword="true"/>
			</mx:FormItem>
		
			<mx:FormItem label="Voornaam:" >
				<mx:TextInput id="iVoornaam" />
			</mx:FormItem>
			<mx:FormItem label="Achternaam:" >
				<mx:TextInput id="iAchternaam" />
			</mx:FormItem>
			<mx:FormItem label="Emailadres:" >
				<mx:TextInput id="iEmailadres" />
			</mx:FormItem>
		</mx:Form>
		<mx:ControlBar>
			<mx:Spacer width="113"/>
			<mx:Button label="Velden legen" click="leegVelden()"/>
			<mx:Button label="Aanmelden" click="voegGebruikerToe( iGebruikersnaam.text, iVoornaam.text, iAchternaam.text, iEmailadres.text, iWachtwoord.text )"/>
		</mx:ControlBar>
	</mx:Panel>
	
	<!-- Datagrid om gebruikers weer te geven -->
	<mx:DataGrid x="10" y="283" 
				width="340" height="299"
				id="dgGebruikers">
		<mx:columns>
			<mx:DataGridColumn headerText="Gebruikersnaam" dataField="Gebruikersnaam"/>
			<mx:DataGridColumn headerText="Voornaam" dataField="Voornaam"/>
			<mx:DataGridColumn headerText="Achternaam" dataField="Achternaam"/>
			<mx:DataGridColumn headerText="Emailadres" dataField="Emailadres"/>
		</mx:columns>
	</mx:DataGrid>

ActionScript 3 AIR ActiveRecord是开源的

1.
      var employee = new Employee();
   2.
      employee.loadBy("username = ?", "bobTheBuilder");
   3.
       
   4.
      // accessing tasks will autoload them from the database
   5.
      for each (var task:Task in employee.tasks)
   6.
          trace(task);
   7.
       
   8.
      task = new Task("Call your mother");
   9.
      employee.task.push(task);
  10.
      employee.saveTasks();
  11.
       
  12.
      employee.firstName = "Bobby";
  13.
      employee.save();
  14.
       
  15.
      var employee2:Employee = new Employee();
  16.
      employee2.firstName = "Sue";
  17.
      ....
  18.
      employee2.save();
  19.
      trace(employee2.id); // new id

ActionScript 3 获取BitmapData的高度和宽度

var img = new Logo(0,0);
trace(img.height);//40;
trace(img.width);//100

ActionScript 3 最基本皓flvæ'放器

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

var vid:Video = new Video(320, 240);
this.addChild(vid);

vid.attachNetStream(ns);

ns.play("http://www.linkmobile.net/yf/Wanted_T4.flv");

ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);

function netstat(stats:NetStatusEvent)
{
        //trace(stats.info.code);
}

var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object)
{
        trace(meta.width);
};

ns.client = netClient;

ActionScript 3 定义存在冲突

//

ActionScript 3 AS3å©©è> <é“®ç>~äº<件

//color egg
function colorEgg() 
{
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
    stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
    stage.addEventListener(Event.DEACTIVATE, clearKeys);
}

colorEgg();

var keyDowns = '';
function keyPressed(evt)
{
	//Tracer.debug(evt.keyCode);
	keyDowns += evt.keyCode.toString();
}

function keyReleased(evt)
{
	if(keyDowns == '76908989')
	{
		var txt:TextField = new TextField();
		txt.htmlText = '&lt;font color=&quot;#ff6600&quot; size=&quot;20&quot; face=&quot;verdana&quot;&gt;&lt;b&gt;YY , Have a Nice day :) - From LZ&lt;/b&gt;&lt;/font&gt;';
		txt.x = stage.stageWidth - txt.textWidth;
		txt.y = stage.stageHeight - txt.textHeight;
		txt.width = txt.textWidth+10;
		txt.selectable = false;
		addChild(txt);
	}
}

function clearKeys(evt)
{
	keyDowns = '';
}