Skip to content

Instantly share code, notes, and snippets.

View s9tpepper's full-sized avatar

Omar Gonzalez s9tpepper

View GitHub Profile
@s9tpepper
s9tpepper / document.as
Created July 10, 2011 00:10
Document object
/* The Document object is used to represent BSON documents
and queries to perform mongodb operations. An empty BSON
document is just a blank Document instance */
var document:Document = new Document();
/* Documents whose properties are all String and number
type values can be created inline using the Document
constructor, {"hello":"world", "type":"message"} is
written inline as below */
@s9tpepper
s9tpepper / authenticating.as
Created July 10, 2011 00:01
Authenticating with a database
function onDBConnected(db:DB):void
{
/* First create a Credentials object using your username/password */
var dbCredentials:Credentials = new Credentials("db_user_name", "db_user_password");
/* Add callback handlers for authentication problems and authenticated
Signals objects */
mongo.db("myDatabase").authenticationProblem.add(onAuthenticationProblem);
mongo.db("myDatabase").authenticated.add(onDBAuthenticated);
@s9tpepper
s9tpepper / connecting.as
Created July 9, 2011 23:34
Connecting to mongodb
/* Add a handler to the connected Signal object to hook
in to when the database has established a connection */
mongo.db("myDatabase").connected.add(_onDBConnected);
/* Call connect() to try a connection with mongodb */
mongo.db("myDatabase").connect();
/* The Signal handler must accept a DB object, it is
a referece to the mongo.db("myDatabase") object. */
function onDBConnected(db:DB):void
@s9tpepper
s9tpepper / navigating.as
Created July 9, 2011 23:16
Navigating through databases and collections
/* Accessing a database is done using the db() method */
mongo.db("myDatabase")
/* A reference can be stored to the DB object. */
var myDatabase:DB = mongo.db("myDatabase");
/* Accessing a collection is using the collection() method,
@s9tpepper
s9tpepper / creatingAMongoObject.as
Created July 9, 2011 22:57
Creating a Mongo object
/* Creating a Mongo object requires you have the
domain to your mongodb server and the port number,
the default is 27017.*/
var mongo:Mongo = new Mongo("your.mongo.com", 27017);
This example shows how you would set the scroll position of a scrollable
component to the max scroll position in Flex 3 and how it is handled in Flex 4.
// Flex 4
// myView = Some view class.
// myScroller = s:Scroller
// myContentContainer = s:Group
var maxScrollPosition:Number = myView.myContentContainer.height - myView.myScroller.viewport.height;
myView.myScroller.viewport.verticalScrollPosition = maxScrollPosition;
The SkinnableItemRenderer is used exactly like s:ItemRenderer. The difference being SkinnableItemRenderer
allows you to use SkinPart metadata in your ItemRenderer definition. As a result of being able to skin the
item renderer, the autoDrawBackground capabilities are lost as the super class is no longer Group/GroupBase.
This is the only lost functionality in SkinnableItemRenderer. The example Flex project is in the repository,
which includes the examples below.
Example Application:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"