2012-01-18 1 views
0

제가 해결하려고하는 기본 문제는 플렉스 & 플래시 구성 요소가 혼합되어 있으며 일반 함수가 있다는 것입니다. 구성 요소에 진행률 회 전자를 추가하는 경우. 따라서 구성 요소가 Container 인 경우 rawChildren에 추가하고, 그렇지 않으면 정상적으로 추가합니다.플렉스 3 : 컨테이너의 "rawChildren"에 스프라이트를 추가 할 때가 종종 콘텐츠 하위에 추가됩니다

그러나 VBox에서 상속 한 구성 요소에 문제가 있습니다. 나는

cont.rawChildren.addChildAt(spinner, cont.rawChildren.numChildren); 

를 호출하지만 아이들을 추적 할 때, 내 스피너는 cont.getChildren()에 표시하고, comp.numChildren 분명히 하나에 의해 증가한다. 그리고 다른 컨테이너는 제대로 작동하는 것처럼 보입니다. 심지어 다른 VBox 컨트롤도 있습니다.

나는 Flex 프레임 워크 코드를 살펴 봤으며 상속이나 타이밍을 통해 왜 이런 일이 일어날 지 설명 할 수는 없습니다.

아무도 비슷한 것을 보거나이 경우에 rawChildren이 예측할 수없는 이유를 설명 할 수 있습니까?

감사합니다.


기능 :

var bcu:Number = u.numChildren; 
var bce:Number = el.numChildren; 

el.addChildAt(s, ((pos > -1)?pos : el.numChildren)); 
trace("ADD NEW SPINNER", u, el, el.numChildren, u.numChildren, bce, bcu); 

el가 한 DisplayObject 또는 콘테이너의 rawChildren로 객체 중 하나이며, u가 스피너에 부착되는 원래 객체이다.

출력 : 다음

ADD NEW SPINNER BlockMovePopup1734 [object ContainerRawChildrenList] 6 5 5 4 

: 그리고

[Fault] exception, information=TypeError: Error #1034: Type Coercion 
failed: cannot convert com.misc::[email protected] to mx.core.IUIComponent. 

출력 el 올바르게 ContainerRawChildrenList합니다 (VBox 대한 rawChildren 개체)로 설정하고 numChildren 것을 [6,5][5,4] 종래에게 인 것을 보여준다 전화. 즉, Sprite이 rawChildren이 아닌 내용 하위에 추가되고 있음을 의미합니다.

+0

"콘텐츠 어린이"는 어떤 이야기를하고 있습니까? "하지만 VBox에서 상속 한 구성 요소에 문제가 있습니다."하지만 VBox에서 확장 한 클래스에 어떤 일이 발생하는지 정확하게 설명하지는 않습니다. –

+0

"내용 하위 항목"은 컨테이너의 일반 하위 항목이며 rawChildren에 추가 된 스킨 같은 것들은 포함하지 않습니다. 확장 된 VBox는 본질적으로 팝업/툴팁 유형이지만, 아이들에게는 특별한 것이 없습니다. 최대 4 개의 LinkButton을 포함합니다. – Glenn

답변

2

재미있었습니다. 기발한 걸 발견 했어. 아마도 rawChildren.addChildAt 함수가 약간 버그라고 생각합니다. 컨테이너 클래스에 텍스트 블록을 찾았

Container assumes that content children are contiguous, and that 
    non-content children come before or after the content children. 
    In order words, Container partitions DisplayObjectContainer's 
    index range into three parts: 

    A B C D E F G H I 
    0 1 2 3 4 5 6 7 8 <- index for all children 
      0 1 2 3  <- index for content children 

    The content partition contains the content children D E F G. 
    The pre-content partition contains the non-content children 
    A B C that always stay before the content children. 
    The post-content partition contains the non-content children 
    H I that always stay after the content children. 

내가 지금은 잘 작동 rawChildren.addChild을 사용합니다. 두 경우 모두 회 전자가 마지막 자식으로 추가되었지만 addChild가 올바르게 수행합니다.

+0

와우, 잘 알고 있습니다. 플랫폼에 따라 다소 엉망입니다. 요즘 Flex는 HTML5에 대한 관심을 끌고 있습니다. –

관련 문제