Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Monday, September 19, 2011

Flex AdvancedDatagrid, changing renderers

You can change columerenderer and the grouping colume renderer as following:
 
<components:CustomDataGrid variableRowHeight="true" folderClosedIcon="{null}" folderOpenIcon="{null}" groupItemRenderer="MyGroupingItemRenderer"  groupRowHeight="100">
        <components:dataProvider>
            <mx:GroupingCollection id="gc" source="{someArray/arrayCollection}" >
                <mx:grouping>
                    <mx:Grouping>
                        <mx:GroupingField id="groupingField" name="groupField" compareFunction="{MyCompareFunction()}" descending="true"/>
                    </mx:Grouping>
                </mx:grouping>
            </mx:GroupingCollection>
        </components:dataProvider>
        <components:columns >
            <mx:AdvancedDataGridColumn   itemRenderer="MyColumeRnnderer" />
        </components:columns>
    </components:CustomDataGrid>
                            
                            
                            
                            
 //Defining   
MyGroupingItemRenderer
    
    public class MyGroupingItemRenderer extends AdvancedDataGridGroupItemRenderer {
        .....
        ....
    }

Friday, September 9, 2011

Handeling text overflow in Flex Alert

//your code//
var a:Alert = Alert.show("..long..text....");
handelOverFlow(a,500);
private function handelOverFlow(alert:Alert,maxHeight:int):void {
   var array:Array = alert.getChildren();
   var uiCom:UIComponent = array[0];
   var txtField:UITextField = uiCom.getChildAt(0) as UITextField;
   var box:Box = new Box();
   //if AlertForm (uiCom) has more height then desired height
   if(uiCom.height>maxHeight) {
     uiCom.height = maxHeight;
     txtField.parent.removeChild(txtField);;
     box.width = uiCom.width;
     box.height = maxHeight - 50;
     box.addChild(txtField);
     uiCom.addChildAt(box,0);
  }
}

Red5 hello world [Java - flex communication] implementation


Requirement for gives example are: red5 server [i used : red5-0.9.1], Eclipse [example contains eclipse projects]
Note: before running example, unzip it and view read me
Download example here

adobe air :: File handling

  • The static properties included in File class :
File.applicationStorageDirectory  A unique storage directory unique for each installed AIR application
File.applicationDirectory  Directory where the application is installed and it is read only
File.desktopDirectory  Desktop directory of the User
File.documentsDirectory  Documents directory of the user
File.userDirectory  User Directory
  • saving file:
  1. var bytearray:ByteArray = new ByteArray();
  2. var fileToCopy:File = new File("url of file");
  3. var newFile:File = new File("url of file to be created");
  4. var fileStream:FileStream = new FileStream();
  5. fileStream.open(file,FileMode.READ);
  6. fileStream.readBytes(bytearray);//getting bytes
  7. var newFileStream :FileStream = new FileStream()
  8. newFileStream.openAsync( newFile, FileMode.WRITE );
  9. newFileStream.writeBytes(bytearray);//filling bytes
  10. newFileStream.close();
  • Updating file
public function update(value:String,url:String,startIndex:int = 0):void
{
   var file:File = new File(url);
   var fs:FileStream = new FileStream();
   fs.open(file,FileMode.UPDATE);
   fs.position = startIndex;
   fs.writeUTFBytes(value);
   fs.close();
}
  • Getting current directory in air:
  1. NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
  2. public function onInvokeEvent(invocation:InvokeEvent):void {
  3.         var currentDir:File = invocation.currentDirectory;
  4. }


  • File systems's tutorial:
http://labs.adobe.com/wiki/index.php/Apollo:Articles:Apollo_Local_File_System
http://www.flex888.com/296/9-flex-file-upload-examples-visited.html

Thursday, September 8, 2011

Amf (open amf) hello world [Flex - java communication] implementation

This example demonstrate the flex – java communication using open amf
Requirement:
1) openamf [i used openamf-1.0RC12]
2) eclipse [i used 3.4 (example contains eclipse project)]
3) tomcat server [i used 6.0]
Download example project amf helloworld.zip
Unzip the project, and view read me. There are 2 projects inside, one client and one server project.To run just import them in you eclipse and run it.