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
/* 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
/* 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
/* 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
/* 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
// 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
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
/* The opacity: .5 CSS property will make the container and its | |
* children transparent. This LESS mixin can be used to set the | |
* background-color property with opacity resulting in a transparent | |
* background color with full opacity children. | |
*/ | |
.backgroundOpacityRGB(@red: 0, @green: 0, @blue: 0, @bgOpacity: 0.5) { | |
background: rgb(@red, @green, @blue); // Fallback to full opacity bg | |
background: rgba(@red, @green, @blue, @bgOpacity); // Alpha'd bg color for 'modern' browsers | |
} |
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
// In AngularJS 0.9.19 | |
// Dont do... | |
angular.service("CustomServiceOne", function($resource) { | |
return $resource("/path/to/api/:aParam", {}, { | |
getSomething: {method: "GET", params: {aParam: 0}, isArray: false} | |
}); | |
}); | |
// Instead do this... |
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 .config() part is the relevant part, 'SomeModule' is arbitrary name, | |
// but this config() call goes on your main ng-app="YourAppModule" | |
// The PHP $_POST expects data w/ a form content type, not a JSON payload | |
angular.module("YourAppModule", ["SomeModule"]).config(function($httpProvider) { | |
$httpProvider.defaults.headers.put['Content-Type'] = | |
'application/x-www-form-urlencoded'; | |
$httpProvider.defaults.headers.post['Content-Type'] = | |
'application/x-www-form-urlencoded'; | |
}); |