2013-02-15 2 views
0

flex에서 swf 함수 (setPoints (nr : int) : void;)를 호출하려고합니다.Flex에서 MovieClip (외부 swf) 함수를 실행하는 방법

[Embed(source="img/anim/x2.swf")] 
[Bindable] 
public static var points:Class; 

public function strikeAnimation(area:SpriteVisualElement, strike:int):void{ 
    var mc:MovieClip = new points() as MovieClip; 
    area.addChild(mc); 
    //how to run? 
    area.mc.setpoints(strike); 
} 

아이디어가 있으십니까?

+0

문제가 있습니까? 그리고 만약 그렇다면; 문제가 무엇입니까? 왜이게 너를 위해 일하지 않니? – JeffryHouser

+0

나는이 같은 호출 함수를 시도했다 - area.getChildIndex (area.getChildIndex (mc)). setpoints (strike); 하지만 flex에서 오류가 표시되었습니다. 이 줄에 여러 마커가 있습니다. -area -area -1067 : int 유형의 값을 관련없는 유형의 암시 적 강제 변환입니다. flash.display : DisplayObject. -1061 : 정적 유형이 int 인 참조를 통해 가능한 정의되지 않은 메소드를 호출합니다. - 정의되지 않은 속성 설정 값의 액세스 – Oleg

답변

1

나는 노력이 같은 통화 기능 - area.getChildIndex (area.getChildIndex (MC)) 설정 값 (파업).;

위의 코드 줄에서 오류가 발생하는 이유는 getChildIndex이 DisplayObject를 필요로하고 정수를 반환하기 때문입니다.

그래서,이 아마 일 :

area.getChildIndex(mc) 

를, 그것은 정수 어린이와 동일하지 않기 때문에 다른 getChildIndex 호출에 입력으로 사용할 수있는 정수를 반환했습니다. 설정 점의 방법은 movieclip의 문서화 된 방법은 아닙니다, 그러나

var myChild :MovieClip = area.getChildAt(area.getChildIndex(mc)) 

,이 같은

무언가가 당신에게 자녀의 인스턴스를 얻어야한다 따라서 사용자 정의 무비 클립에서 setpoints 메서드를 실행하려면 사용자 정의 유형으로 변환해야합니다. 개념적으로는 다음과 같습니다.

(myChild as myCustomType).setpoints(strike); 
관련 문제