Archive

Posts Tagged ‘as3’

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

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 path
var myQuery:XPathQuery = new XPathQuery("path/to/evaluate");
// execute the statement on an XML object and get the result
var 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 statement
var 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 instance
var context:XPathContext = new XPathContext();
// declare a namespace
context
.namespaces["ns1"] = "http://domain.com/2006/ns1";
// define a custom variable
context
.variables["myCustomVar"] = true;
// Pass the context to the XPathQuery instance
var 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 objects
XPathQuery.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
Categories: Actionscript 3 Tags: , ,