Flex FlexSession사용

Flex 2009. 6. 1. 17:10
public static boolean sessionCheck() {
   FlexSession session = FlexContext.getFlexSession();
   if(session != null) {
      return true;
   } else {
      throw new NoSessionOnFlexException("no session object exist on this application.");
   }
}

public static void setSessionAttribute(String key, Object value) {
   if(sessionCheck()) {
      FlexContext.getFlexSession().setAttribute(key, value);
   }
}

public static Object getSessionAttribute(String key) {
   if(sessionCheck()) {
      return FlexContext.getFlexSession().getAttribute(key);
   }
   return null;
}
posted by 느릅나무™

Flex Array의 Filter Method 사용하기

Flex/Flex 2.* 2009. 6. 1. 16:55
□ Array Class - public Method
filter(callback:Function, thisObject:* = null) : Array
배열내의 각 아이템에 대해 테스트 함수를 실행해, 지정된 함수에 대해 true를 돌려주는 모든 아이템을 포함한 새로운
배열을 작성합니다.

○ 원하는 Box만 Array 형태로 수집하고 싶은 경우
<mx:VBox id="vbox">
   <mx:Vbox id="b1" name="BOX"/>
   <mx:Vbox id="b2" name="BOX"/>
   <mx:Vbox id="b3" name="HBOX"/>
   <mx:Vbox id="b4" name="BOX"/>
</mx:VBox>
private function text() : void {
   var arr : Array = vbox.getChildren().filter(isBox);   // getChildren()는 Box의 자식을 Array로 반환
}

private function isBox(item : *, index : int, arr : Array) : Boolean {
   if(item.name == "BOX") {
      return true;
   } else {
      return false;
   }
   return false;
}
posted by 느릅나무™
//로우 색처리 ===========================================================
private var _rowColorFunction : Function;

public function set rowColorFunction( f : Function ) : void {
   this._rowColorFunction = f;
}
public function get rowColorFunction() : Function {
   return this._rowColorFunction;
}

private var displayWidth : Number;

override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number) : void {
   super.updateDisplayList(unscaledWidth, unscaledHeight);
   if (displayWidth != unscaledWidth - viewMetrics.right - viewMetrics.left) {
      displayWidth = unscaledWidth - viewMetrics.right - viewMetrics.left;
   }
}

override protected function drawRowBackground(s : Sprite, rowIndex : int, y : Number, height : Number, color : uint, dataIndex : int) : void {
   if( this.rowColorFunction != null ) {
      if( dataIndex < (this.dataProvider as ArrayCollection).length ) {
         var item:Object = (this.dataProvider as ArrayCollection).getItemAt(dataIndex);
         color = this.rowColorFunction.call(this, item, color);
      }
   }
   super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
사용방법
private function selectTypeColor( item : Object, color : uint) : uint {
   if( item['컬렉션명'] == "값" )  {
      return 0xFFFF00;
   }
   return color;
}


   
      
         
         
      
   

posted by 느릅나무™