Demo Site

Thursday, May 27, 2010

As3 Crypto

from http://code.google.com/p/as3crypto/

Tags: , ,

As3 Crypto is a cryptography library written in Actionscript 3 that provides several common algorithms. This version also introduces a TLS engine (TLS is commonly known as SSL.)

  • Protocols: TLS 1.0 support (partial)
  • Certificates: X.509 Certificate parsing and validation, built-in Root CAs.
  • Public Key Encryption: RSA (encrypt/decrypt, sign/verify)
  • Secret Key Encryption: AES, DES, 3DES, BlowFish, XTEA, RC4
  • Confidentiality Modes: ECB, CBC, CFB, CFB8, OFB, CTR
  • Hashing Algorithms: MD2, MD5, SHA-1, SHA-224, SHA-256
  • Paddings available: PKCS#5, PKCS#1 type 1 and 2
  • Other Useful Stuff: HMAC, Random, TLS-PRF, some ASN-1/DER parsing

The library is offered under the BSD license, and include several derivative works from Java, C and javascript sources. Check the LICENSE.txt file for a list of contributors.

You can look at a demo of the functionality of the library. It’s built with Flex 2. It includes a unit test tab, and a benchmark tab.

This is what the benchmark tab outputs on my computer (Athlon64 2Ghz):

The 'numbers' are in 1000s of bytes per second processed.type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
md2
1.01k 3.64k 15.08k 53.89k 171.76kmd5 221.85k 447.32k 739.54k 893.72k 905.82ksha1 82.28k 184.78k 286.76k 336.03k 345.41ksha224 60.84k 125.67k 200.27k 234.28k 247.58ksha256 60.52k 126.30k 199.19k 234.04k 246.01khmac-md5 48.37k 159.37k 282.87k 295.15k 341.21khmac-sha1 18.29k 64.82k 165.72k 277.60k 342.52khmac-sha224 5.75k 24.84k 125.71k 204.35k 256.36khmac-sha256 15.10k 49.33k 123.71k 206.17k 249.08krc4 117.24k 381.34k 878.93k 1315.01k 1539.44kxtea-cbc 2.49k 6.48k 12.80k 33.00k 44.48kaes128-cbc 1.61k 4.01k 22.97k 78.55k 205.01kaes192-cbc 1.34k 5.13k 20.91k 69.45k 172.43kaes256-cbc 1.48k 5.63k 18.87k 63.45k 150.39kblowfish-cbc 2.77k 10.81k 42.28k 140.27k 343.05kdes-cbc 2.53k 9.73k 35.20k 124.84k 624.88k3des-cbc 2.50k 9.72k 35.61k 115.21k 253.42k

The library has not been optimized for speed, and those numbers could probably be improved.

You can browse the source, download the source or download the SWC binary

Check out the release notes for a bit more details.

Things that should make it in the next release:

  • better ASN-1 parsing
  • SSL 3.0 support
  • various bugfixes (Socket, BigInteger)

http://code.google.com/p/as3crypto/downloads/detail?name=Crypto.zip

http://code.google.com/p/as3crypto/downloads/detail?name=as3crypto.swc

SVN Location

The AS3Commons project

from http://code.google.com/p/as3-commons/

Tags: , is dedicated to one principal goal: creating and maintaining reusable ActionScript 3.0 components. This is a place for collaboration and sharing, where developers from throughout the community can work together on projects to be shared.

AS3Commons developers will make an effort to ensure that their components have minimal dependencies on other libraries, so that these components can be deployed easily. In addition, AS3Commons components will keep their interfaces as stable as possible, so that users (including other AS3Commons projects) can implement these components without having to worry about changes in the future.

We welcome participation from all that are interested, at all skill levels. Coding, documentation and testing are all critical parts of the software development process. If you are interested in participating in any of these aspects, please join us!

AS3Commons Libraries

Collections Collection framework formerly know as Lite Collections Fx 1.0 download docs
Concurrency Pseudo-threading support 1.0-RC1 download

Lang Language utilites and extensions 0.2.1 download

Logging An abstraction over logging framework implementations. Being a pure actionscript library it can be used for any Flash/Flex/AIR project. Its use is recommended for use with other libraries/framework trying to be logging framework agnostic. 1.1.1 download docs API
Reflect A reflection API for ActionScript 3.0. Being a pure actionscript library it can be used for any Flash/Flex/AIR project. 1.3 download docs API

Maven

All libraries are also available in the Maven repository at http://projects.yoolab.org/maven/content/repositories/releases/org/as3commons

Facebook-actionscript-api

Tags: , ,

The new ActionScript 3.0 Client Library for Facebook Platform API, fully supported by Facebook and Adobe, makes it easy to build applications that combine the strengths of the Flash Platform and Facebook Platform.

The Adobe Flash Platform and Facebook Platform provide the ideal solution for building rich, social experiences on the web. Flash is available on more than 98% of Internet-connected PCs, so people can immediately access the applications, content, and video that enable social interactions. The Facebook Platform is used by millions of people everyday to connect and share with the people in their lives. Together, both platforms allow you to:

  • Share: Create rich interactions for users to share with friends.
  • Have fun: Make games social; let users compete against their friends.
  • Connect: Let users connect to your RIAs with Facebook Connect.
  • Solve problems: Build RIAs that harness the power of community.
  • Reach people: Reach millions of Facebook users through social distribution.

Getting Started

For tutorials, articles, and videos on using the new API, visit the Facebook page on the Adobe Developer Center. You can also see the docs for the most recent and stable build.

Project History

The API was originally developed by Jason Crist and authored under the direction of Terralever, an online marketing firm with strength in Flash-based media. Although Adobe has taken over day-to-day management of the project, Jason still maintains a consulting role. Under the direction of Adobe, the highly experienced team of Flash and Flex experts from gskinner.com have developed and architected the latest iteration of the API.

If you are looking for the deprecated code and samples, see the ‘tag/version2′ directory in the repository or search for files with the ‘Deprecated’ tag in the downloads section.

For questions and inquiries about this library, please contact Daniel Dura at Adobe Systems via email at ddura@adobe.com. Submit bug reports, patches, or feature requests via the issue tracker.

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_with_AIRConnect_v3.4_flex.swc

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_with_AIRConnect_v3.4_flash.swc

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_v3.4_source.zip

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_v3.4_flex.swc

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_v3.4_flash.swc

http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_v3.4_examples.zip

SVN Location

Combine PV3D & Webcam Motion Tracking

GA for Flash

from http://code.google.com/p/gaforflash/

Overview

This is an ActionScript 3 API for Google Analytics data collection.

Getting started

Discussion

Data Limitations

Google Analytics is a free service in which Google covers all the bandwidth and processing costs. If your tracking implementation generates more than 5 Million requests (events/pageviews) per day, please seek approval first at: ga-events-feedback AT google DOT com

Contributors

Google Analytics Tracking For Adobe Flash is an open source project under the Apache 2.0 license. If you are interested in understanding the internals of the tracking code, building from source, or contributing to the project, check out the contributors page and subscribe to the project group

Google Analytics Reference Docs

gaforflash-1.0.1.319.zip

SVN Location

An XPath implementation for ActionScript 3.0.

From http://code.google.com/p/xpath-as3/

An XPath implementation for ActionScript 3.0.

Platforms

XPath-AS3 can be used in any AS3 project, including:

GettingStarted

Basic overview of how to use the XPath library

Executing XPath Statements

XPath queries are evaluated using the XPathQuery object.

// create the XPathQuery instance and parse the pathvar myQuery:XPathQuery = new XPathQuery("path/to/evaluate");// execute the statement on an XML object and get the resultvar result:XMLList = myQuery.exec(myXML);

Using namespaces

To use namespaces, you need to register namespace prefixes with the corresponding URI. This prefix does not need to match the prefix used in the XML document, but must match the prefix that you use in your XPath statements.

var myQuery:XPathQuery = new XPathQuery("ns1:path/to/ns2:evaluate");myQuery.context.namespaces["ns1"] = "http://domain.com/2006/ns1";myQuery.context.namespaces["ns2"] = "http://domain.com/2007/ns2";

Short-hand Namespace handling

There are two more convenient ways of adding the namespaces, by either opening all the namespaces, or automatically declaring the same prefixes as the document.

By setting ‘useSourceNamespacePrefixes’ to true, any namespace declarations in you the XML document will be automatically declared for the XPath expression, using the same prefixes:

var myQuery:XPathQuery = new XPathQuery("ns1:path/to/ns2:evaluate");myQuery.context.useSourceNamespacePrefixes = true;

The easiest (although perhaps least safe) way is with the openAllNamespaces property. Although, if there are several namespaces used in the document, there is a chance of name conflicts:

// no need for prefixes in this statementvar myQuery:XPathQuery = new XPathQuery("path/to/evaluate");myQuery.context.openAllNamespaces = true;

The XPathContext object

The XPathContext object is how you can specify namespaces, variables and custom functions to use in your XPath statements. By creating an instance of XPathContext, you can pass it as an argument to the constructor all of your XPathQueries, so you do not have to set them all up individually.

// create the context instancevar context:XPathContext = new XPathContext();// declare a namespacecontext.namespaces["ns1"] = "http://domain.com/2006/ns1";// define a custom variablecontext.variables["myCustomVar"] = true;// Pass the context to the XPathQuery instancevar myQuery:XPathQuery = new XPathQuery("path/to/evaluate", context);

Alternatively, you can customise the default XPathContext, which will then apply to all XPathQueries, as long as you don’t also pass one as an argument.

// this namespace will be available to all XPathQuery objectsXPathQuery.defaultContext.namespaces["ns1"] = "http://domain.com/2006/ns1";

Extending XPathContext

Sometimes it is more convenient to extend XPathContext and use instances of the subclass in your expressions. If you do this, it is important to override the copy() method, which is used internally in sub-expressions.

public class MyContext extends XPathContext {  public function MyContext(){    // add the custom functions to the functions table    functions['custom-function'] = customXPathFunction;  }

// custom XPath functions must receive a reference to the // context as their first argument. You may have any number of other // arguments of any type, and the return value can be any type. private function customXPathFunction( context:MyContext, arg1, arg2.. ):String { // add code here }

// extensions to MyContext must implement copy() public override function copy():XPathContext { var clone:MyContext = new MyContext(); // use the utility method to make sure that all the built-in and // internal properties are copied copyProperties( clone, this ); return clone; }}

var path:String = "path/to/evaluate[@att = custom-function(1,2)]";var myQuery:XPathQuery = new XPathQuery(path, new MyContext());
xpath-as3-1.0.0.zip
SVN location

AS3 Webcam Motion Tracking

AS3 Motion Tracking and Detection

Detecting & Tracking Objects movement in Flash

Here’s how it works

  • After the camera object is set up, it is passed to a MotionTracker class I wrote, which extends the Point object. The MotionTracker class contains two BitmapData objects; one representing the current data from the webcam, the other is used to store the previous frame.
  • When the update method is called, the new frame is drawn on top of the previous using the difference filter.
  • The result then has a ColorMatrixFilter applied to it, increasing the contrast of the image and dropping the darker areas (with less movement) further into the background.
  • A blur filter is then applied in order to further reduce noise and to form blobs from areas where more movement is occurring.
  • The threshold method is then called in the resulting BitmapData, effectively causing all near black pixels to be ignored and all light pixels (where movement has been detected) to be set to a certain colour.

So that takes care of the motion detection, but what about the tracking?

  • First we call the getColorBoundsRect method on the BitmapData object, which gives us a Rectangle object representing the area occupied by pixels of the colour we used when applying the threshold filter.
  • If the rectangle has an area larger than a specified constant, then sufficient movement is occurring and it can be tracked (choosing to ignore small areas of movement helps to eradicate noise caused by background and other interferences).
  • We then find the centre point of this rectangle, and then move the x and y position of the MotionTracker instance to these coordinates, applying some gentle easing to give more continuity to the movement


AS3 Motion Tracking from Justin Windle on Vimeo.


MotionTracker.zip

from blog.soulwire.co.uk