2009년 8월 28일 금요일

Snow Leopard Java 관련 문제들..



1.6 10432A 업데이트 후

MyEclipse 에서 Tomcat 설정 후

톰캣이 JDK 관련 오류를 내뱉고 있었다.

원인이 무언고 하니..


1.6 으로 넘어가면서 64비트가 기본으로 잡혀있어서 발생한 문제?

32비트로 전환해주니 아주 잘된다 흠..


2009년 8월 25일 화요일

HttpAnalyzer V5.0.1

onitor HTTP, Trace HTTP, Debug HTTP, Capture HTTP, Track HTTP and Analyze HTTP/HTTPS!

Build:5.0.1  New:  Integrate with Firefox, Deserialize Flash Remoting, JSON, SOAP
 
Stand-alone Edition, Firefox Add-on and IE Add-on (Click for larger image)
 
Need a tool which can serve as HTTP monitor, HTTP sniffer and HTTP Tracer?
IEInspector HTTP Analyzer is such a handy tool that allows you to monitor, trace, debug and analyze HTTP/HTTPS traffic in real-time. It is used by industry-leading companies including Microsoft, Cisco, AOL and Google.
HTTP Analyzer includes two Editions---Stand-alone Edition and Add-on Edition.

Stand-alone Edition : Window stand-alone EXE application. It allows you to capture and view HTTP/HTTPS traffic from a specific process or user/session/system wide. Support IE, Safari, Chrome, Firefox and other win32 web application.

Add-on Edition: An add-on that integrates into the lower part of your IE  or Firefox window and can be opened/closed from the IE or Firefox toolbar. It can only capture and view HTTP/HTTPS traffic of current IE or Firefox process.

Main Features

    * Integrate with Internet Explorer and Firefox, No more switching between windows. HTTP Analyzer Shows HTTP/HTTPS traffic and web page in the same window. 
    * Support HTTPS, show you unencrypted data sent over HTTPS / SSL connections as the same level of detail as HTTP.
    * See wide range data, including Header, Request ,Network Timing, Content,  Cookies, Caching, Query Strings, Post data, Request and Response Stream, redirection URLs, DOMReadyTime, PageLoadTime and more.
    * Real-time Page and Request Level Time Chart, The colored time chart is used to express the relative time between a single network level timing (i.e. , DNS lookup, TCP connects) and other timing segments in the same request.
    * Native support for Flash Remoting , HTTP Analyzer is especially useful for Adobe Flash developers as you can view the request and response of LoadVariables, LoadMovie and XML loads. It can also deserialize and display all Flash Remoting or AMF (AMF0 and AMF3) traffic in a easy-to-use AMF object tree. 
    * JSON , SOAP and .NET ViewState Viewer , HTTP Analyzer can deserialize SOAP and JSON traffic into the easy-to-use object tree. It can also read and decode the hidden ViewState on an ASP.NET Page.
    * Request builder, Users can handcraft an HTTP request by using the HTTP Request Builder, or use a drag-and-drop operation to move an existing request from the session grid to the Request Builder to execute it again. 
    * Automation interface, The HTTP Analyzer automation library is packaged as COM components. both Stand-alone and Add-on can be fully controlled by using OLE Automation. It can be used by most programming languages (e.g. C#, VC, Delphi & JavaScript).



2009년 8월 17일 월요일

Custom Event 작성시 알아야 할 기본사항 (퍼옴)






Flex Application은 모두 알고 있다시피 Event Driven 방식이다.
Application 기동부터 종료까지 event로 시작해서 event로 끝난다..

event를 왜 사용하는가.를 포함, event에 대한 모든 제반사항에 대해서 지돌스타님 블로그에 정리가 잘 되어 있다.
여기를 클릭
참고하길 바라며, 나 또한 이글을 포스팅한 후 제반사항에 대해 예제위주로 정리해서 올려야겠다.(ㅋㅋ 대체언제..)

암튼 각설하고,

보통 개발자가 원하는 방식으로 event 처리를 할 때, event object에 개발자가 원하는 정보를 추가 및 보내기 위해 custom event를 만들어 사용하며, 보통 flash.events.Event 클래스를 상속받아서 custom event class를 작성한다.
또는, event type만을 정의해 다음과 같이 custom event 객체를 생성할 수도 있다.
==> this.dispatchEvent(new Event("myCustomEvent")) 

(주의사항 : 반드시 flash.events.Event 클래스를 상속받아서 만들 필요는 없다. 필요에 따라 다른 Event클래스를 상속 받아서 써도 된다. 상황에 맞게, 입맞에 맞게 상속받아서 사용하길 바란다.)

전자(Event클래스의 Sub Class 작성)는 event object 정보 외에 부가적으로 필요한 정보들을 event object에 추가 및 사용하기위해서 사용되고 후자(event type정의)는 단순히 event object 정보만 필요로 할때 사용한다.

여기서는 Event클래스의 Sub Class로 Custom Event를 작성할 때 기본적으로 알아야 할 사항을 정리해보았다.

일단 하나의 Custom Event를 만들어 보자.

package events
{
   import flash.events.Event;

   public class MyCustomEvent extends Event
   {
       public static const MY_EVENT:String = "myEvent";
      
       private var _strMyName:String;
      
       public function MyCustomEvent(type:String,strName:String,bubbles:Boolean=false,cancelable:Boolean=false)
       {
           super(type,bubbles,cancelable);
          
           _strMyName = strName;
       }
      
       public function get strMyName():String
       {
           return _strMyName;
       }
      
       public override function clone():Event
       {
           return new MyCustomEvent(type,strMyName,bubbles,cancelable);
       }
      
       public override function toString():String
       {
           return formatToString("MyCustomEvent", "type", "bubbles", "cancelable", "eventPhase", "strMyName", "target", "currentTarget");
       }
      
   }
}


flash.events.Event를 상속한 "myEvent" 타입의 MyCustomEvent 클래스를 작성했다.
(주의사항 : 이 Custom event 클래스는 event type과 사용자정보-strMyName- 및 bubbles 옵션,cancelable옵션을 event 객체를 생성할때 사용자가 원하는대로 설정할 수 있게끔 만든 것이다. 꼭 저렇게 만들어야 한다는 게 아니란 걸 말하고 싶다.)

보시는 바와 같이 아주 간단하게 Custom Event를 작성할 수 있는데 다음과 같은 사항을 고려해서 작성해야 한다.
==================================(Must가 아니라 Recommend사항)========================================

1. Custom Event Class의 Super Class 생성자 argument인 'type' 속성값은 static constant로 지정한다.

Event Class 생성자의 필수 argument인 'type' 속성의 데이터 타입은 string이다.
보통 다음과 같이 쓸 수 있다.

var strMyName:String = "게릴라";
          
dispatchEvent(new MyCustomEvent("myEvent",strMyName));

위의 예제에서 "myEvent" 라고 정확히 입력하면 문제가 되지 않겠지만 실수로 "myEvvent"라든가 "myEvents"등 오타를 입력하게되면 어떻게 될까?
플렉스 컴파일러는 생성자의 type 속성에 전달된 string값을 체크하지 않는다. 고로 컴파일 에러없이 컴파일이 수행된다.
(어플리케이션 어딘가에 저런 이벤트가 있겠지 하고 마는 것이다.)
런타임에 에러가 발생하지만 런타임 이전엔 에러를 찾기가 힘들다. 이 말은 프로그램을 돌려봐야 에러를 발견할 수 있단 얘기다.

이러한 문제를 미연에 방지하기 위해 즉, 컴파일 타임에 valid체크가 가능하도록 하기 위해  Event Class에 type 속성을
static constant로 정의한다.

var strMyName:String = "게릴라";
          
dispatchEvent(new MyCustomEvent(MyCustomEvent.MY_EVENT,strMyName));

만약 생성자의 type 속성에 잘못된 constant를 지정하게되면 컴파일러는 컴파일 타임에 친절하게
Syntax Error(구문 오류)를 날려주신다. (후훗~ 쌩유~)

흠..저런 고민을 덜고자, 오타를 아예 방지하고자 한다면 다음과 같은 방식으로 Custom event를 만들 수도 있겠다.

package events
{
   import flash.events.Event;

   public class MyCustomEvent extends Event
   {
       public static const MY_EVENT:String = "myEvent";
      
       private var _strMyName:String;
      
       public function MyCustomEvent(strName:String)
       {
           super(MyCustomEvent.MY_EVENT);
          
           _strMyName = strName;
       }
      
       public function get strMyName():String
       {
           return _strMyName;
       }
      
       public override function clone():Event
       {
           return new MyCustomEvent(strMyName);
       }
      
       public override function toString():String
       {
           return formatToString("MyCustomEvent", "type", "bubbles", "cancelable", "eventPhase", "strMyName", "target", "currentTarget");
       }
      
   }
}

이 event를 사용하고자 한다면 생성자에 type속성 값을 박아넣고, 아예 필요한 정보만 받도록 만든 것이다.
서두에 작성된 Custom event 클래스와는 달리 type 속성 및 bubbles , cancelable 값을 사용자가
제어하지 못하게 만든 Custom event 클래스이다.

이 event 클래스의 객체를 생성하고 dispatch한다고 할때, 다음과 같이 사용자 정보만 넘기면 된다.

var strMyName:String = "게릴라";
          
dispatchEvent(new MyCustomEvent(strMyName));



2. clone()메소드를 Override한다.

event클래스의 clone메소드는 event 객체의 복사본을 생성하여 되돌려준다.(참조복사-Shallow Copy-가 아닌 Deep Copy 객체)

flex엔 java의 clone() 메소드나 Cloneable같은 Interface가 존재하지 않기 때문에 각각의 event클래스 마다 각각
clone메소드를 override해야 한다.(아래 예제참조)

flex sdk의 소스를 까보면 mx.events패키지에 여러 이벤트들이 존재하는데 몇개만 들여다 보자.

-mx.events.CloseEvent

override public function clone():Event
{
   return new CloseEvent(type, bubbles, cancelable, detail);
}

-mx.events.ItemClickEvent


override public function clone():Event
{
   return new ItemClickEvent(type, bubbles, cancelable, label, index, relatedObject, item);
}


우리가 Custom Event를 만들때 clone 메소드를 override하는 것은 무조건 강제하는 사항은 아니다.
일반적으로 이 clone 메소드를 override하지 않아도 사용이 가능하다.

하지만 이 clone 메소드를 override하지 않은 Custom event는 Application내에서 언제 런타임 에러를 내뱉을지 모를
위험한 놈이 될 수도 있음을 알아야 한다.
그럼 왜 clone 메소드를 override 해야하는가?

이를 설명하기 전, EventDispatcher 클래스의 dispatchEvent() 메소드를 통해 event가 발생하는 내부로직부터 이해하고 넘어가야겠다. 거창할거 없다. 모두 알고 있는 단순한 사실을 짚고 넘어가 보자. event는 어떻게 발생하는가?
일단 dispatch하고자하는 새로운 event instance를 생성한다. 새로 생성된 event 객체의 target 속성값은 현재 null값이다.
EventDispatcher 클래스의 dispatchEvent() 메소드를 통해 새로운 event객체를 dispatch한다.
dispatchEvent() 메소드는 event객체의 target 속성값을 event를 발생시킨 객체(보통 컴포넌트) 레퍼런스, 즉 event를 최초 발생시킨 객체 참조값으로 초기화한다. 이 target 속성값은 바뀌지 않는다.(event flow(Capture-at Target-Bubbling)에서 등록된 eventListener에 따라 currentTarget값은 바뀌지만 target값은 바뀌지 않는다.)

자, 이렇게 이 event를 dispatch한 후 target속성값은 event를 최초 발생시킨 객체 참조값으로 정해졌다.

만약, 같은 Application에 addChild되어 있지만 dispatch된 이 event를 listening할 수 없는 컴포넌트에서 이 event를 똑같이 그대
로 받아서 쓰고 싶다면 어떻게 해야 될까?

Application에 서로 상관관계가(부모자식관계 or Hierachy관계)없는 A,B라는 컴포넌트가 있다 가정하고, A에서 발생한 event를
B에서도 받아서 쓰고 싶을 땐 A에서 발생한 event를 B에서 그대로 dispatch하면 된다.(event Re-Dispatch)
추가:event를 Re-Dispatch한다는 것이 말하고자 하는 요점이지 꼭 저런상황에서 필요하단 얘기가 아니다.
Application의 (A와 B를 포함하는) event listener에서 B의 메소드를 호출하든, B에서 event를 dispatch하든 그건 방법론적 차이이다.
Application의 listener가 appListener라고 가정하면,

appListener(cutomEvent:MyCustomEvent):void
{
//B의 메소드를 호출해서 일을 시킨다.
B.excuteMymethod(cutomEvent);

//B에서 event를 dispatch시킨다. B에 eventListener를 등록, eventListener에 등록된 이벤트 핸들러에서 일을 시킨다.
//B.dispatchEvent(cutomEvent);  // clone메소드 자동호출하도록 하기 위한 예.
}
말 그대로 두 방법 다 loose coupling이 아닌 tight coupling이 되는 구조다. 객체참조값을 통해 접근하기 때문이다.
B라는 컴포넌트가 없으면 에러가 발생할테니까..

가정상황이 두 컴포넌트는 따로 따로 있어야 하는 상황이고, 똑같은 event값을 받아 쓰려고 하는 상황이다. 말그대로 가정상황이다. clone메소드 자동호출하는 상황을 만들어내기 위한 가정상황이란 것이다. loose coupling을 염두에 둔다면 그냥 A와 B 각각 따로 event를 발생시켜서 쓰든가 observer패턴같은 디자인패턴을 적용해서 쓰든가 캔곰의 controller, command구조로 구성하든가 해야 할 듯하다. .다시 말하지만 event를 Re-Dispatch한다는 것이 말하고자 하는 요점이 지 방법론적 문제는 좀 더 연구해봐야 할 듯 하다.  예제가 적절치 못했음을 인정한다. event를 re-dispatch하는 상황이 언제 어디서 왜 필요한지 아직 정확히 몰라서 깊이 생각치 못하고 이런 가정상황을  만든 것이다. event를 re-dispatch해서 쓰는 상황에 대한 적절한 예가 필요하다^^;; 적절한 예를 들어주실 분! 손!

이때 dispatchEvent()메소드가 무슨 짓을 하는지 살펴보면..

dispatchEvent () method  
public function dispatchEvent(event:Event):Boolean
Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

Parameters


event:Event — The Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically.  After an event is dispatched, its target property cannot be changed, so you must create a new copy of the event for redispatching to work.
Returns

Boolean — A value of true if the event was successfully dispatched. A value of false indicates failure or that preventDefault() was called on the event.

Throws

Error — The event dispatch recursion limit has been reached.


빨간색으로 밑줄 친 부분은 If the event is being redispatched, a clone of the event is created automatically.
event가 다시 dispatch되면 자동으로 그 event의 복제본이 생성된다라고 말하고 있다.

이는 clone 메소드를 자동으로 호출한다는 것을 의미한다. dispatchEvent메소드를 호출하면(targeted Event를 파라미터로 받을경우) 자동으로 clone 메소드를 호출하기 때문에 사용자가 eventObject.clone() 할 일은 없을 것이다.(일반적으로 clone메소드는 사용자가 직접 호출해서 쓰지 않는다. 물론 직접 호출해서 써도 무방하다. 동일하게 작동하지만 자동으로 처리해주는 것을 굳이 사용자가 호출할 필요가 없지 않은가. flex sdk소스를 보다 보면 가끔 dispatchEvent(event.clone()); 처럼 처리하는 경우도 볼 수도 있다. )

쉽게 말하려 하는데, 한마디로 정리하자면!
target 속성값이 이미 할당된 event(이미 dispatch된 event)를 dispatchEvent()메소드를 통해 다시 dispatch하면 자동으로 그 event의 clone메소드를 호출한다는 것이다.

clone () method
public function clone():Event
Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9

Duplicates an instance of an Event subclass.

Returns a new Event object that is a copy of the original instance of the Event object. You do not normally call clone(); the EventDispatcher class calls it automatically when you redispatch an event—that is, when you call dispatchEvent(event) from a handler that is handling event.

The new Event object includes all the properties of the original.

When creating your own custom Event class, you must override the inherited Event.clone() method in order for it to duplicate the properties of your custom class. If you do not set all the properties that you add in your event subclass, those properties will not have the correct values when listeners handle the redispatched event.



자, 다음과 같은 구조의 화면이 있다고 가정하자.
Application에 A-B-C-D구조로 된 부모/자식관계의 컴포넌트(Visual DiplayObject)들이 있고
A-B-C-D구조와는 상관없이 Application에 add된, A와 Depth가 같은 E라는 컴포넌트(Visual DiplayObject)가 있다고 하자.
현재 이 event를 Application 및 A-B-C-D구조로 된 부모/자식관계의 컴포넌트들과 E라는 컴포넌트가  모두 listening하고 있다. event는 D에서 발생했다. 위에서 설명한대로 D에서 발생한 event객체의 target은 D의 객체 참조값이 할당된다.
Application 및 A-B-C-D에선 이 event를 listening할 수 있지만 E에서도 listening이 가능한가? 현재구조로선 불가능하다.
등록된 eventListener에서 D에서 발생한 event객체를 받아서 다음과 같이 Re-Dispatch 해줘야한다.
(굳이 D에서 발생한 event를 사용하지 않고 , D에서 발생한 event와 똑같은 event를 새로 생성해서 E에서 dispatch할 수도 있다.
event를 Re-Dispatch한다는 것이 말하고자 하는 요점이지 꼭 저런상황에서 필요하단 얘기가 아니다.
물론 나라면 내부적으로 clone 메소드를 호출하도록 해서 똑같은 event객체를 쓸 것이다.
상황에 따라 얼마든지 event는 Re-Dispatch될 수 있다.)

등록된 eventListener가 myEventListener라면

myEventListener(cuctomEvent:MyCustomEvent):void
{
   E.dispatchEvent(cuctomEvent); // Re-Dispatch    
}


이미 target 속성값이 지정된(이미 dispatch된) event객체를 그대로 다시 dispatch하면 E에서도 D에서 발생한 event를 그대로 받아서 쓸 수 있다.

여기서 짚고 넘어갈 부분이 생겼다.위에서 언급했었지만 target 속성값은 바뀌지 않는다 라고 했었다...
하지만 이미 dispatch된 event객체를 다시 dispatch하면 clone메소드에 의해 생성된 새로운 복사본의 event target 속성 값은
어떻게 될까? 당연히 Re-Dispatch한 곳의 객체 참조값이 다시 할당되서 event target 속성값이 변경될 것이다.
(clone메소드에 의해 새로운 복사본 객체가 생성되면 새로 생성된 event 객체의 target 속성값은 null값이 되고 이를 dispatchEvent()메소드로 dispatch하면 새로운 target 속성값이 할당된다.)

D에서 발생한 event의 target 속성값은 D가 되고 E에서 Re-Dispatch한 event의 target 속성값은 E가 될 것이다.
이미 dispatch된 event객체를 Re-Dispatch하면 target 속성값이 변한다는 사실을 잊지 않길 바란다.

정말 뒤죽박죽 장황하게 떠들어댔다.. clone메소드를 왜 override해야 하는건지 말하려다보니 관련된 사항에 대해
말이 길어졌는데, 결국 저런 경우에 Custom Event에서 clone 메소드를 override하지 않은 채로 사용한다면 다음과 같은
런타임 에러가 발생한다.

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@...... to MyCustomEvent.

TypeError: Error #1034: 유형 강제 변환에 실패했습니다. flash.events::Event@......을(를) MyCustomEvent(으)로 변환할 수 없습니다.

왜 Type Conversion Error가 나지? 하고 의아해하는 사람도 있을 것이다.
Override하지 않은 clone 메소드는 내가 만든 MyCustomEvent 타입의 객체를 반환하지 않고 flash.events.Event 타입의 객체를 반환하기 때문에 Type Conversion Error가 나는 것이다.

주의사항 :
clone 메소드를 overriding할땐 flash.events.Event 클래스에 정의된 메소드 시그니처(Method Signature)에
맞게 작성해야 한다. override 한 clone 메소드의 리턴 값이 자신이 정의한 Custom Class 타입이 아닌 flash.events.Event 타입이어야 한다는 것이다. Event클래스를 상속한  자신의 Custom Event의 타입은 flash.events.Event 타입이지만 실제로
리턴되는 인스턴스는 Event클래스의 인스턴스가 아닌 자신이 작성한 Custom Event의 인스턴스가 된다는 것을 의미한다.

clone 메소드를 overriding해야 하는 첫번째 이유는 바로 저런 문제가 발생하기 때문이다.
그럼 다른 또 이유가 있을까? 있단다...이 부분은 사실 나도 잘 모르겠다...(사실 지금 찾아보다 포기했다.ㅋㅋㅋ)

clone 메소드를 overriding해야 하는 두번째 이유는
'clone 메소드는 내부적으로 event bubbling을 위해서 overriding해야 한다'고 한다.

Foundation Flex for Developer 58페이지에 언급된 내용을 보고 정신이 혼미하다...^^;;

We also need to call the clone method to support event bubbling.
By using this method, the event can bubble to any parent containers. This is necessary to inform any other components that are listening for this event.If you don’t override the clone method, the event can’t bubble.
->
event bubbling을 지원하기 위해 clone 메소드를 호출할 필요가 있다.
이 메소드를 사용해서 event는 어떤 부모 컨테이너에든 bubbling할 수 있다.
이 event를 linstening하고 있는 여느 다른 컴포넌트에 통지하기 위해 필요하다.
clone 메소드를 override하지 않으면 이 event는 bubbling할 수 없다.

flex bloger(farata) 에도 다음과 같이 언급되어 있다.

This class has to extend flash.events.Event, override its method clone to support event bubbling.

역시나 event bubbling을 위해선 clone 메소드를 override해야 한다고 한다.
하지만 실제로 저 블로그 링크의 예제를 따라해보면 clone 메소드를 override하지 않아도 custom event의 bubbles 속성값만 true로 하면 이상없이 bubbling된다는 것을 알 수 있을 것이다.

흠...일반적으로 clone 메소드를 override하지 않은 채로, custom event를 만들고 bubbles 속성값을 true로 해서
event 객체를 생성하고 hierachy구조(부모-자식관계)의 DisplayObject상에서 이 event객체를 dispatch하면 이상없이 event flow를 따라 bubbling되는 것을 알 수 있다.  

즉, Visual DisplayList에 addChild되어 있는 displayObject에서
실제 event가 bubbling될 때 새로운 event 객체가 복제되지 않고 event가 dispatch된 최초 발생지점(target)에서부터,
처음 생성된 event 객체가 stage까지 bubbling되면서 올라간다. bubbling되는 event 객체의 target 속성값은 변함 없지만 currentTarget 속성값은 현재 bubbling되면서 지나치는 displayObject 객체 참조값으로 계속 변경된다. 한마디로 뭐..event를 bubbling할때 event를 복제하지 않고 처음 생성된 event 객체를 그대로 쓴다는 얘기를 하려는 것이다.(일반적인 경우)

하지만 실제로 특별한 상황의 어플리케이션에선 내부적으로  clone 메소드를 호출해서 event bubbling을 한다고 한다.
clone 메소드를  overriding 하지않으면 event bubbling을 할 수 없는 경우가 있다고 하는데....정말 모르겠다..이부분은...
이 부분은 누가 좀 알려주면 정말 좋겠는데...^^; (트랙백 굽신굽신 ㅋㅋ)

3. toString()메소드를 Override한다.

이 메소드를 override하면 디버깅용으로 좋다. custom event의 클래스명부터 사용자가 정의한 모든 속성 및 상속받은 부모 event 클래스의 모든 속성까지 한번에 볼 수 있다. (type,bubbles,cancelable,eventPhase,target,currentTarget등)

override하지 않은 메소드를 호출하게 되면 상속받은 부모 클래스(일반적으로 Event클래스)의 toString 메소드를 호출하게 되고
사용자가 추가한 custom data는 보여주지 않고 다음과 같이 기본속성만 보여준다.

[Event type="myEvent" bubbles=true cancelable=false eventPhase=2]

type, bubbles, cancelable, eventPhase 속성값만 확인이 가능하다. 다른 속성값(target,currentTarget)이나 자신이 추가한
정보를 보고자 한다면 이 메소드를 override해야 한다.

그래서 기본적으로 제공되는 utility 메소드가 있는데 바로 Event 클래스의 formatToString 메소드이다.

formatToString () method  
public function formatToString(className:String, ... arguments):String
Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9

A utility function for implementing the toString() method in custom ActionScript 3.0 Event classes. Overriding the toString() method is recommended, but not required.

  class PingEvent extends Event {


var URL:String;


public override function toString():String {


return formatToString("PingEvent", "type", "bubbles", "cancelable", "eventPhase", "URL");


}


}



친절하게도 custom event클래스의 toString 메소드를 구현하기 위한 utility function이라고 딱 정해놨다.
서두에도 말했듯, 1,2,3번 사항 전부 강제사항이 아닌 recommended 사항임을 알아두길...(권고사항은 왠만하면 지켜주는게
개발자 정신건강에 좋은 듯~ㅋㅋ 뭐 귀찮다면 할 수 없지만...)

자, formatToString 메소드에 전달되야 하는 값을 살펴보자.

formatToString(className:String, ... arguments):String

첫번째 값은 Custom event 클래스명을 String 타입의 값으로 받는다.
꼭 자신이 만든 Custom event 클래스명이 아니어도 에러는 발생하지 않는다. String값이면 된다.
두번째 값은 현재 자신이 만든 Custom event 클래스에서 사용할 수 있는 속성값들이다.
자신이 보고싶은 속성값들만 String값으로 연속해서 넣어주면 된다.
(주의사항 :  Custom event 클래스에서 사용할 수 없는 속성값을 넣으면 에러가 발생한다.)

본문 서두에 만들어 놓은 Custom event 클래스의 toString 메소드를 보자.

public override function toString():String
{
      return formatToString("MyCustomEvent", "type", "bubbles", "cancelable", "eventPhase",
                                     "strMyName", "target", "currentTarget");
}

"MyCustomEvent"가 className에 전달되는 string값이고 이후 "type"부터 rest parameter이다.


꼭 저렇게 하지 않아도 된다.
formatToString 메소드를 쓰지 않고 다음과 같이 자신이 원하는 대로 할 수도 있다.
단, Custom event 클래스에서 사용할 수 있는 속성값이어야 한다.

public override function toString():String
{
            return "[MyCustomEvent type=" + this.type + " MyName=" + this.strMyName + " bubbles=" + this.bubbles + " cancelable=" + this.cancelable + " eventPhase=" + this.eventPhase + " target=" + this.target + " currentTarget=" + this.currentTarget + "]";
}

입맛에 맞게 overriding하면 될 듯...


P.S. 1: 제가 위에서 언급한 부분(알아내지 못한 clone 메소드를 overriding해야 하는 두번째 이유) 함께 토의해봐요~^^
P.S. 2: 대체 어떤 상황에서 한번 dispatch된 event를 re-dispatch하는게 좋을까요? 함께 토의해봐요~^^

사실 위에 내용 중 긴가민가하는 부분이 간혹 있었다.

모르는 부분도 있고...누군가 잘못된 부분이나 내가 알아내지 못한 부분에 대해서 트랙백을 걸어주길 바라며

글을 정리한다.

오랫만에 글을 썼는데 날림으로 쓰느라 syntaxhightlighter도 사용하지 않고 막 써버렸다..

앞으로 모든 글들은 내 귀차니즘으로 인해...syntaxhightlighter를 쓰지 않는 형태가 될 것 같다..ㅋㅋㅋㅋㅋ

프로젝트 핑계로 정말 너무 게으르게 살았던 듯...

자~ 다시 열공모드로 진입합시다!!!

ㅋㅋㅋㅋ

2009년 8월 14일 금요일

Flex 에서 Fla Compile 할시 유용한 팁




원 소스 출처 : http://cafe.naver.com/flashover.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=387

Flex에서는 Fla 관리시에 좀 불편한점이 있었는데,

Fla 를 관리하며, 컴파일 할때, 컴파일 하기가 조금 번거롭다는 것인데,

위의 주소에서 jsfl 이라는 배치 스크립트 파일을 받았는데, 오류가 나면서 동작하지 않았다.

맥이라서 그런가?

그래서 아래와 같이 수정하였다.



for(var i=0; i<executableFileName.length; i++){
    fl.openDocument( currentPath+executableFileName[i] );
    fl.getDocumentDOM( ).exportSWF(currentPath+executableFileName[i], true );
}


맨 아래 두줄을 for로 묶고, 배열에 따라 swf 로 컴파일 하는...

현재 테스트 해보았는데 잘된다. :)

2009년 8월 12일 수요일

AS3 AVM1Movie 제어하기



원문 : http://alaguvel.wordpress.com/2008/09/06/avm1-swf-to-as3-swf-forcibleloader/

ForcibleLoader.as http://snippets.libspark.org/svn/as3/ForcibleLoader/src/org/libspark/utils/ForcibleLoader.as

 private function init():void{
  var loader:Loader = new Loader();
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfComplete);
  var fLoader:ForcibleLoader = new ForcibleLoader(loader);
  fLoader.load(new URLRequest(swfURL));
  fxStage.addChild(loader);
  pptContainer.addChild(fxStage);
 }
 private function swfComplete(event:Event):void{
   libMC =  event.currentTarget.content as MovieClip;
   for(var i:int = 1;i<Math.ceil(libMC.totalFrames/2);i++){    
    totalSlides.addItem(i);
   }
   slides = Math.ceil(libMC.totalFrames/2);
   libMC.gotoAndStop(1);
 }



위 클래시를 이용해서, 위와 같이 제어 할수 있다.
 
진작 찾았으면 좋았을껄~

2009년 8월 11일 화요일

FDT Flash Compile Key Setting.


참고 : http://labs.mstudio.com/?p=174

Preferences -> Run/Debug -> Launching ->

Launching Operation
      Always launch the previously launched applications


Preferences -> General -> Keys

Search : Run Last Launched
Binding Key.

:)

ActionScript Debugger - Arthropod


Arthropod

http://arthropod.stopp.se/index2.php/


Download : http://arthropod.stopp.se/index2.php/?page_id=3
Download Direct Link :
                                    AIR : http://arthropod.stopp.se/downloads/Arthropod.air
                                    CLASS : http://arthropod.stopp.se/downloads/Debug.as

How to use

Arthropod is really easy to use. Basically the only thing you need to do is import the Debug class, write a log message with the log function, start Arthropod and publish your site / AIR application.

To hide the Bitmap window, Array window and clear the output field, just click on the main area and press Backspace (<–).

Step-by-step:

  1. Download Arthropod
  2. Install Arthropod
  3. Add the Debug.as file to your Actionscript 3 library under com/carlcalderon/arthropod/
  4. Import the Debug class by inserting import com.carlcalderon.arthropod.Debug;
  5. Place a Debug.log method execution where ever you want to make a trace, like this; Debug.log("my message");
  6. Start Arthropod
  7. Publish your site/ AIR application.
  8. The message “my message” will be displayed in Arthropod.

Available methods:
Check out the “Documentation” section for further explanation.

  • log
  • warning
  • error
  • object
  • memory
  • array
  • bitmap
  • snapshot
  • clear

Support:
Arthropod currently supports the following.

  • All characters (should include asian characters, not tested)
  • OSX and Windows (Tested on some Linux dists.)
  • AIR Runtime 1.0 and above
  • All major browsers (Internet Explorer, Firefox 2.0 and above, Safari)
  • SWFObject 1.5 and above
  • Optional ProFont

2009년 8월 9일 일요일

Licensing for this product has expired 문제

삭제

MAC : 라이브러리\Application Support\Adobe\Adobe PCD\cache\cache.db
WIN : C:\Program Files\Common Files\Adobe\Adobe PCD\cache\cache.db


hosts 설정

127.0.0.1 activate.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com