Recital

Login Register

HOWTO: Edit nodes in a Flex Tree control

When the node is clicked set editable to false. Set editable to true in the double-click event handler.
// the click event handler 
private function onclick_sourcetree(e:Event):void  {     
    yourTree.editable = false; 
}  

// the doubleclick event handler  
private function ondoubleclick_sourcetree(e:Event):void  {     
    yourTree.editable = true;    
    yourTree.editedItemPosition = {columnIndex:0, rowIndex:sourceTree.selectedIndex}; 
} 
Published in Blogs

The getUIComponentBitmapData method can create bitmapdata for a given IUIComponent. Pass any UIcomponent to get its respective bitmapdata.

public static function getUIComponentBitmapData(target:IUIComponent):BitmapData {      
    var resultBitmapData:BitmapData = new BitmapData(target.width, target.height);     
    var m:Matrix = new Matrix();     
    resultBitmapData.draw(target, m);     
    return resultBitmapData; 
}

Now convert the bitmapdata to a jpeg bytearray.

private static function encodeToJPEG(data:BitmapData, quality:Number = 75):ByteArray {     
    var encoder:JPGEncoder = new JPGEncoder(quality);     
    return encoder.encode(data); 
}

Now encode the ByteArray into Base64.

public static function base64Encode(data:ByteArray):String {     
    var encoder:Base64Encoder = new Base64Encoder();     
    encoder.encodeBytes(data);     
    return encoder.flush(); 
}

Upload the base64 encoded ByteArray to the server.

public static uploadData():void {     
    var url:String = "saveFile.php";     
    var urlRequest:URLRequest = new URLRequest(url);     
    urlRequest.method = URLRequestMethod.POST;     
    var urlLoader:URLLoader = new URLLoader();     
    var urlVariables:URLVariables = new URLVariables();     
    urlVariables.file = jpgEncodedFile;    // as returned from base64Encode()     
    urlLoader.data = urlVariables;     
    urlLoader.load(urlRequest); 
}

The saveFile.php file on the server.


Published in Blogs
Twitter

Copyright © 2024 Recital Software Inc.

Login

Register

User Registration
or Cancel