---
title: "flex中的创建StringBuffer"
author: "demojava"
date: "2010-09-21T09:36:43Z"
tags: []
categories: ["Web前端"]
slug: "flex-stringbuffer"
draft: false
lastmod: "2010-09-21T09:37:23Z"
id: 768755
url: "https://demojava.iteye.com/blog/768755"
---

import mx.collections.ArrayCollection;  
   
 public class StringBuffer  
 {  
   
  public function StringBuffer()  
  {  
  }       
     /\**  
     * @private  
     * \*/  
     private var source:ArrayCollection=new ArrayCollection();  
      
  public function get data():ArrayCollection  
  {  
   return source;  
  }  
    
  /\**  
     * @private  
     * \*/  
  public function set data(value:ArrayCollection):void  
  {  
   source.removeAll();  
   source=value;  
  }  
      /\**  
     * @private  
     * \*/  
  public function append(s:String):StringBuffer  
  {  
   source.addItem(s);  
   return this;  
  }  
    
  /\**  
     * @private  
     * \*/  
  public function insert(i:int,s:String):StringBuffer  
  {  
   source.addItemAt(s,i);  
   return this;  
  }  
    
  /\**  
     * @private  
     * \*/  
  public function remove(i:int):StringBuffer  
  {  
   source.removeItemAt(i);  
   return this;  
  }  
    
  /\**  
     * @private  
     * \*/  
  public function clear():void  
  {  
   source.removeAll();  
  }  
    
  /\**  
     * @private  
     * \*/  
  public function toString():String  
  {  
   var result:String="";  
   for each(var s:String in source)  
    result+=s+"\\n";  
   return result;  
  }  
    
 }