FLEX2009. 8. 24. 11:00

오늘 HDividedBox 를 이용해서 마우스 드래그시 이동하는 작업을 하였다

하지만! 전혀 동작 하지 않았다

이유는

내가 써준 변수 위에 [Bindable]을 쓰지 않아서이다.

Bindable은 변수의 값이 변경될시에, 그 값을 참조하는 객체들에게 Event형식으로 값을 전달한다.
(UIComponent 참조)

아주 중요하니 참고 하자


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Script>
  <![CDATA[
   import mx.events.DividerEvent;
   private function moveChart(event:MouseEvent):void
   {
    trace("start : " + leftBoundary + " /  " + rightBoundary );
    leftBoundary +=10;
    rightBoundary +=-10;
    trace("end : " + leftBoundary + " /  " + rightBoundary );
   }
   [Bindable]
   public var leftBoundary:Number = 100;
   [Bindable]
   public var rightBoundary:Number = 100;
   
   private var staticLeftBoundary:Number;
   private var staticRightBoundary:Number;
   public var mouseXRef:Number;
   
   private function setMouseDown(e:Event):void
   {
    this.systemManager.addEventListener(MouseEvent.MOUSE_MOVE, moveChart);
    this.systemManager.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
   }
   
   private function stopDragging(event:MouseEvent):void
   {
    this.systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, moveChart);
    this.systemManager.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);
   }
   
   private function updateBoundariesFromDivider(event:DividerEvent):void{
    leftBoundary +=10;
    rightBoundary +=-10;
    trace("drag : "  + leftBoundary + " /  " + rightBoundary );
   }
  ]]>
 </mx:Script>
  <mx:HDividedBox id="hdivided" width="100%" height="30%"
  alpha="1"
  borderThickness="1" borderColor="#999999" borderStyle="solid"
  dividerAffordance="5" liveDragging="true"
  horizontalGap="10" verticalGap="0"
  horizontalScrollPolicy="off"
   >
   <mx:Canvas id="leftBox" height="100%" backgroundAlpha="0.5" backgroundColor="#808080"
      borderThickness="1" borderColor="#999999" borderStyle="solid"
    width="{leftBoundary}">
   </mx:Canvas>   
   <mx:Canvas id="visibleBox" height="100%" mouseDown="setMouseDown(event)" width="100%" buttonMode="true" >
   </mx:Canvas>   
   <mx:Canvas id="rightBox" height="100%" backgroundAlpha="0.5" backgroundColor="#808080"
      borderThickness="1" borderColor="#999999" borderStyle="solid"
    width="{rightBoundary}">
   </mx:Canvas>   
  </mx:HDividedBox> 
</mx:Application>
Posted by lahuman
FLEX2009. 7. 28. 17:35

Flex에서 클릭시에 다른 주소를 링크 할때는 navigateURL()을 사용한다.


The navigateToURL() method syntax

GET 이나 POST 정보를 정해서 사용할때는 아래처럼 method 부분에 설정해서 사용.

import flash.net.*;
public var url:URLRequest = new URLRequest("http://mysite.com/index.jsp");
var uv:URLVariables = new URLVariables();
url.method = "GET";
uv.name = "fred";
url.data = uv;
navigateToURL(url);


GET, POST를 사용하지 않을때 간단히 하고자 할 때
위의 링크의 처럼 문장을 더하는게 아니면
"http://www.google.com/search?hl=en&q=" + ta1.text

함수 안에서 new로 바로 생성해서 사용 가능함.
navigateToURL(new URLRequest("http://www.google.com/"), "_blank");
Posted by lahuman
FLEX2009. 7. 23. 17:38

Link와 같은 hand cursor 로 형태를 변경해야 할 경우가 있다.

그럴 경우 



[Embed(source="/image/handCursor.png")]
   private var hadnCursor:Class;
//설정
//-9,-9 를 주는 이유는, mouse좌표에서 그정도 pix를 움직여야 이미지가 중심에 온다
 CursorUtils.changeCursor(hadnCursor, -9, -9); 

//해제
 CursorUtils.changeCursor(null, 0, 0); 

SOURCE CODE :


package sjd.utils
{
 import mx.managers.CursorManager;
 import mx.managers.CursorManagerPriority;
 
 /**
  * @class CursorUtil
  * @brief Set the cursor image
  * @author Jove
  * @version 1.2
  */
 public class CursorUtils{
  private static var currentType:Class = null;
    
  /**
   * Remove the current cursor and set an image.
   * @param type The image class
   * @param xOffset The xOffset of the cursorimage
   * @param yOffset The yOffset of the cursor image
   */
  public static function changeCursor(type:Class, xOffset:Number = 0, yOffset:Number = 0):void{
   if(currentType != type){
    currentType = type;
    CursorManager.removeCursor(CursorManager.currentCursorID);
    if(type != null){
     CursorManager.setCursor(type, CursorManagerPriority.MEDIUM, xOffset, yOffset);
    }
   }
  }
 }
}
Posted by lahuman