• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

AS3Commons Introduction

on

  • 3,593 views

Slides from the Belgian Adobe Usergroup event from November 23rd, 2010.

Slides from the Belgian Adobe Usergroup event from November 23rd, 2010.

Statistics

Views

Total Views
3,593
Views on SlideShare
3,593
Embed Views
0

Actions

Likes
4
Downloads
16
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    AS3Commons Introduction AS3Commons Introduction Presentation Transcript

    • AS3 Commons Roland Zwaga Christophe Herreman Stack&Heap
    • What it AS3Commons?
      • Open source community project
      • Contains several ActionScript 3.0 libraries
      • Minimal dependencies between libraries: pick what you need
      • No Flex dependencies!
      • See Apache Commons
    • Why AS3Commons?
      • Central place for AS3 utility libraries
      • Assure quality of libraries
      • Unit tested
      • Started with core parts of the Spring ActionScript project
    • Libraries in AS3Commons?
      • Bytecode
      • Lang
      • Logging
      • Reflect
      • Collections
      • Concurrency
      • Serialization
      • AS3Parser , Async, EventBus (coming up)
    • AS3-commons-logging Logging API abstraction
    • AS3Commons Logging
      • Logging API abstraction over existing logging APIs
      • Wrappers for Flex logger, etc
      • Write your own logger/wrapper: SOS, De Monster Debugger, ...
    • AS3Commons Logging - Example
      • var logger:ILogger = LoggerFactory.getClassLogger(MyClass);
      • logger.debug(“A log statement: {0} {1}”, myVar, myVar2);
      • logger.info...
      • logger.warn...
      • logger.error...
      • logger.fatal...
      • Writes to standard ouput console using trace()
      • You can also log objects (Monster Debugger)
    • AS3Commons Logging - Example
      • // disable logging
      • LoggerFactory.loggerFactory = null;
      • OR
      • // redirect logging to Flex logger
      • LoggerFactory.loggerFactory = new FlexLoggerFactory();
      • var traceTarget:TraceTarget = new TraceTarget();
      • Log.addTarget(traceTarget);
    • AS3Commons Lang General AS3 utilities
    • AS3Commons Lang
      • ArrayUtils, ObjectUtils, StringUtils, ...
      • Basic support for missing AS3 concepts: equality, string builders, comparing, enums, assertions, etc
      • Enums: allows mapping to java enums through BlazeDS
      • Assertions: fail fast
    • AS3Commons Lang – Enum
      • public class Color extends Enum {
      • public static const RED:Color = new Color(“RED”);
      • public static const GREEN:Color = new Color(“GREEN”);
      • public static const BLUE:Color = new Color(“BLUE”);
      • public function Color(name:String) {
      • super(name);
      • }
      • }
    • AS3Commons Lang – Equals
      • public function equals(other:*):Boolean {
      • if (this === other) {
      • return true;
      • }
      • if (!(other is ThisClass)) {
      • return false;
      • }
      • var other:ThisClass = ThisClass(other);
      • return new EqualsBuilder()
      • .append(prop, other.prop)
      • .equals;
      • }
    • AS3Commons Reflect Introspection
    • AS3Commons Reflect
      • Get class/object information at runtime
      • Clear API on top of describeType, no XML
    • AS3Commons Reflect - Example
      • var type:Type = Type.forClass(String);
      • for each (var method:Method in type.methods) {
      • // do something really useful with method
      • // e.g. Invoke method dynamically
      • }
      • OR
      • var type:Type = Type.forInstance(myString);
      • var type:Type = Type.forName(“String”);
    • AS3Commons Collections Data structures
    • AS3Commons Collections
      • New data structures and iterators
      • Lists, maps, sets, linked collections, sorted collections
    • AS3Commons Concurrency Pseudo threading
    • AS3Commons Concurrency
      • Pseudo threading
      • Break up CPU intensive operations in “Runnables”
      • Execute these runnables without blocking the UI (or at least not completely)
      • Asynchronous
    • AS3Commons Serialization XML serialization
    • AS3Commons Serialization
      • XML serialization and deserialization
      • Based on XStream
      • Write custom node (de)serializers
    • AS3Commons Bytecode Ehmmm…. What?
    • What it is
      • Reads ABC bytecode and converts it into an object model
      • This object model can be queried for all sorts of interesting data
      • It can generate ABC bytecode and load it into the VM
    • How?
      • var ds:AbcDeserializer = new AbcDeserializer(byteStream);
      • var abcFile:AbcFile = ds.deserialize();
      • Boring…
    • Bytecode based reflection
      • ByteCodeType.fromLoader(Application.loaderInfo);
      • var typeCache:TypeCache = ByteCodeType.getTypeProvider().getTypeCache();
      • for each (var key:String in keys) {
      • var type:ByteCodeType = typeCache.get(key) as ByteCodeType;
      • /* ... do something... */
      • }
    • Class list
      • var definitionNames:Array = typeCache.definitionNames;
    • Metadata lookup
      • var metaDataLookup:Object = ByteCodeType.metaDataLookupFromLoader(loader);
      • var definitionNames:Array = metaDataLookup['Mixin'];
      • Spring ActionScript’s Class scanning system uses
      • this.
    • Class generation
      • var abcBuilder:IAbcBuilder = new AbcBuilder();
      • var packageBuilder:IPackageBuilder = abcBuilder.definePackage("com.classes.generated");
      • var classBuilder:IClassBuilder = packageBuilder.defineClass("RuntimeClass");
    • Adding properties
      • var propertyBuilder:IPropertyBuilder = classBuilder.defineProperty("name","String","defaultName");
    • Adding methods
      • var methodBuilder:IMethodBuilder = classBuilder.defineMethod("multiplyByHundred");
      • var argument:MethodArgument = methodBuilder.defineArgument("int");
      • methodBuilder.returnType = "int";
    • Adding opcodes
      • methodBuilder
      • .addOpcode(Opcode.getlocal_0) .addOpcode(Opcode.pushscope) .addOpcode(Opcode.getlocal_1) .addOpcode(Opcode.pushint, [100]) .addOpcode(Opcode.multiply) .addOpcode(Opcode.setlocal_1) .addOpcode(Opcode.getlocal_1) .addOpcode(Opcode.returnvalue);
    • Loading the class into the VM
      • abcBuilder.addEventListener(Event.COMPLETE, loadedHandler);
      • abcBuilder.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
      • abcBuilder.addEventListener(IOErrorEvent.VERIFY_ERROR, errorHandler);
      • abcBuilder.buildAndLoad();
    • Instantiating the class
      • var className:String = “ com.generated.RuntimeClass”;
      • var dom:ApplicationDomain = ApplicationDomain.currentDomain;
      • var clazz:Class = dom.getDefinition(className) as Class;
      • var instance:Object = new clazz();
      • var i:int = instance.multiplyByHundred(10);
      • // i == 1000
    • The road ahead…
      • Manipulation of existing classes
      • Foundation for AS3Commons Aspect
      • All sorts of other goodies
    • AS3Commons
      • www.as3commons.org
      • www.springactionscript.org
      • Feel free to join us!
      • @as3commons
      • @mechhead (Roland)
      • @herrodius (Christophe)