This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* All the commands can be executing with the Document object. Simple | |
commands such as "getLastError" are run as below. The Document requires | |
a colon in all entries using shorthand, thus "getLastError:" */ | |
mongo.db("myDatabase").runCommand(new Document("getLastError:")).addOnce(onLastError); | |
function onLastError(opReply:OpReply):void | |
{ | |
// The command response document will be in the first element | |
// of the documents Array in the OpReply object. The structure | |
// of the document will depend on the command executed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The findOne() method will take a query and return a single document. The | |
query is built using the Document class. If no second argument is used in | |
the find() one method all fields are returned for the document. */ | |
var query:Document = new Document("fieldName:searchValue"); | |
mongo.db("myDatabase").collection("myCollection").findOne(query).addOnce(findOneReply); | |
/* Returned fields can be limited by using the return fields document. */ | |
var returnFields:Document = new Document("fieldName:1"); | |
var query:Document = new Document("fieldName:searchValue"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* To specify how many documents to return at a time as well as other find() options | |
use a FindOptions object. */ | |
const findOptions:FindOptions = new FindOptions(); | |
findOptions.numberToSkip = 0; | |
findOptions.numberToReturn = 10; | |
/* Query is handled the same as findOne(), but the handler callback signature | |
is different for a find() */ | |
const query:Document = new Document("name:Hello from Flash sucka!"); | |
mongo.db("myDatabase").collection("myCollection").find(query, findOptions).add(onCursorReady); |
OlderNewer