Guest User

keystr0k

a guest
Mar 28th, 2009
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Add the image to the Matte (by adding it to the shape object)
  3.  */
  4. public function addImageToMatte():void{
  5.     var base64Enc:Base64Encoder = new Base64Encoder;
  6.     base64Enc.encodeBytes(fileRef.data);
  7.    
  8.     var photoBase64:Object = {
  9.         file:base64Enc.flush(),
  10.         fid:"",
  11.         filepath:"sites/default/files/photos/photo.jpg", //should be dynamic & variable-driven!
  12.         filesize: ""
  13.     };
  14.    
  15.     drupal.savePhotoToDrupal(photoBase64,savePhotoToDrupalHandler,null,true);
  16.    
  17.     //chosenShape.savePhoto("uploads/" + fileRef.name);
  18.     killPopup();
  19.  }
  20.  
  21. // Handles the result of the savePhotoToDrupal Drupal services call
  22. private function savePhotoToDrupalHandler(data:Object, fid:int):void{
  23.     trace("file id: " + fid);
  24.     if(fid > 0){
  25.         writePhotoNode(fid);
  26.     }
  27. }
  28.  
  29. /**
  30.  * Writes a new node containing the photo from the savePhotoToDrupal Drupal services call
  31.  */
  32. private function writePhotoNode(fid:int):void{
  33.     var newNode:Object = new Object();
  34.     newNode.type = "photo";
  35.     newNode.title = "test title";
  36.     newNode.field_photo = new Array({ fid:fid });
  37.                    
  38.     var today:Date = new Date();
  39.     if(newNode.nid == 0){
  40.         newNode.created = today.getTime();
  41.     }else{
  42.         newNode.changed = today.getTime();
  43.     }
  44.    
  45.     drupal.nodeSave(newNode,writePhotoNodeCallback,null);
  46. }
  47.  
  48. /**
  49.  * Handles the result of the writePhotoNode Drupal services call
  50.  */
  51. private function writePhotoNodeCallback(data:Object,nid:int):void{
  52.     trace("node id: " + nid);
  53.     if(nid > 0){
  54.         //it worked!
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment