This file contains hidden or 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
var css:CSSStyleDeclaration = FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration('global'); | |
css.setStyle('modalTransparency', transparency); | |
css.setStyle('modalTransparencyColor', color); | |
css.setStyle('modalTransparencyBlur', blur); | |
css.setStyle('modalTransparencyDuration', duration); |
This file contains hidden or 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 is in an ActionScript Project in Flash Builder | |
// Inside FlexUnitApplication.as I added a UI testing environment | |
// In the builder I pass in a reference to the FlexUnitApplication instance | |
package | |
{ | |
import com.project.MyClassTests; | |
import flash.display.Sprite; | |
This file contains hidden or 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
/* Retrieve the _id property from a document returned by mongodb. */ | |
var objectId:ObjectID = documentRetrievedFromMongo._id; | |
/* Create a selector query using the Document object to specify by _id | |
which document to remove() */ | |
var selector:Document = new Document(); | |
selector.put("_id", objectId); | |
/* Call the remove function, there is no return. */ | |
mongo.db("myDatabase").collection("myCollection").remove(selector); |
This file contains hidden or 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
/* Use a Document object to build the BSON document to save into the database */ | |
const newDocument:Document = new Document(); | |
newDocument.put("name", "Hello from Flash sucka!"); | |
/* Use the insert() method to save. This method does not return anything */ | |
mongo.db("myDatabase").collection("myCollection").insert(newDocument); | |
/* Use a getLastError command to get the status of the last insert attempt. */ | |
mongo.db("myDatabase").runCommand(new Document("getLastError:")).addOnce(onLastError); |
This file contains hidden or 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 getMore() method can be used to load more documents from the database | |
if getNextDocument() returns null.*/ | |
function onCursorReady(cursor:Cursor):void | |
{ | |
/*...do stuff...*/ | |
// Before calling getMore() make sure hasMore() returns true. | |
if (cursor.hasMore()) | |
{ | |
cursor.getMore().add(onGotMore); |
This file contains hidden or 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
/* Alternatively, once the Cursor is returned to the callback the Cursor's | |
toArray() method can be used to retrieve an Array of all the documents that | |
the Cursor object has loaded. */ | |
function onCursorReady(cursor:Cursor):void | |
{ | |
// Get array of all documents | |
var documents:Array = cursor.toArray(); | |
// Do something, such as add it to a data provider |
This file contains hidden or 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
/* Once the Cursor is returned to the callback the Cursor's | |
getNextDocument() method can be used to handle each of | |
the documents returned */ | |
function onCursorReady(cursor:Cursor):void | |
{ | |
// Get the first document | |
var doc:Object = cursor.getNextDocument(); | |
// If there was a first document, do something and get next. |
This file contains hidden or 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); |
This file contains hidden or 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 hidden or 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. |