Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add the image to the Matte (by adding it to the shape object)
- */
- public function addImageToMatte():void{
- var base64Enc:Base64Encoder = new Base64Encoder;
- base64Enc.encodeBytes(fileRef.data);
- var photoBase64:Object = {
- file:base64Enc.flush(),
- fid:"",
- filepath:"sites/default/files/photos/photo.jpg", //should be dynamic & variable-driven!
- filesize: ""
- };
- drupal.savePhotoToDrupal(photoBase64,savePhotoToDrupalHandler,null,true);
- //chosenShape.savePhoto("uploads/" + fileRef.name);
- killPopup();
- }
- // Handles the result of the savePhotoToDrupal Drupal services call
- private function savePhotoToDrupalHandler(data:Object, fid:int):void{
- trace("file id: " + fid);
- if(fid > 0){
- writePhotoNode(fid);
- }
- }
- /**
- * Writes a new node containing the photo from the savePhotoToDrupal Drupal services call
- */
- private function writePhotoNode(fid:int):void{
- var newNode:Object = new Object();
- newNode.type = "photo";
- newNode.title = "test title";
- newNode.field_photo = new Array({ fid:fid });
- var today:Date = new Date();
- if(newNode.nid == 0){
- newNode.created = today.getTime();
- }else{
- newNode.changed = today.getTime();
- }
- drupal.nodeSave(newNode,writePhotoNodeCallback,null);
- }
- /**
- * Handles the result of the writePhotoNode Drupal services call
- */
- private function writePhotoNodeCallback(data:Object,nid:int):void{
- trace("node id: " + nid);
- if(nid > 0){
- //it worked!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment