2008-09-11 6 views
0

XML이로드 된 후 만들어진 클래스 인스턴스 내부의 동적 텍스트 필드에 UIScrollbar 구성 요소의 인스턴스를 연결하려고합니다. 슬라이더의 크기가 텍스트 필드의 내용에 따라 달라 지므로 스크롤 막대 구성 요소가 제대로 첨부되고 있지만 스크롤되지는 않습니다.클래스 내의 UIScrollBar 구성 요소를 스크롤하는 데 문제가 발생했습니다.

여기에 코드입니다 :

function xmlLoaded(evt:Event):void 
{ 
    //do some stuff 

    for(var i:int = 0; i < numProfiles; i++) 
    { 
     var thisProfile:profile = new profile(); 

     thisProfile.alpha = 0; 
     thisProfile.x = 0; 
     thisProfile.y = 0; 
     thisProfile.name = "profile" + i; 

     profilecontainer.addChild(thisProfile); 

     thisProfile.profiletextholder.profilename.htmlText = profiles[i].attribute("name"); 
     thisProfile.profiletextholder.profiletext.htmlText = profiles[i].profiletext; 

     //add scroll bar 
     var vScrollBar:UIScrollBar = new UIScrollBar(); 
     vScrollBar.direction = ScrollBarDirection.VERTICAL; 
     vScrollBar.move(thisProfile.profiletextholder.profiletext.x + thisProfile.profiletextholder.profiletext.width, thisProfile.profiletextholder.profiletext.y); 
     vScrollBar.height = thisProfile.profiletextholder.profiletext.height; 
     vScrollBar.scrollTarget = thisProfile.profiletextholder.profiletext; 
     vScrollBar.name = "scrollbar"; 
     vScrollBar.update(); 
     vScrollBar.visible = (thisProfile.profiletextholder.profiletext.maxScrollV > 1); 

     thisProfile.profiletextholder.addChild(vScrollBar); 

     //do some more stuff 
    } 
} 

나는 또한 동영상 클립/클래스 자체 내에서 UIScrollBar 구성 요소와 그것을 시도했습니다, 그리고 그것은 여전히 ​​작동하지 않습니다. 어떤 아이디어?

답변

0

UI 스크롤바를 스테이지에 놓고 디자인 타임에 텍스트 필드에 바인딩 한 다음로드 된 이벤트 중에 update()를 호출 해 보았습니까?

런타임에 동적으로 UIScrollbars를 생성하여 개의 흥미로운 경험이 과거에있었습니다. 첫 번째 예에서

0

addChild(vScollbar);vScrollBar.update();을 퍼팅 시도가?

2

당신은 당신의 텍스트 필드가 이와 유사한 별도의 함수에서 초기화되면 스크롤바를 추가하려고 할 수 있습니다 나는 현재 그 일을 어떻게

private function assignScrollBar(tf:TextField, sb:UIScrollBar):void { 
    trace("assigning scrollbar"); 
    sb.move(tf.x + tf.width, tf.y); 
    sb.setSize(15, tf.height); 
    sb.direction = ScrollBarDirection.VERTICAL; 
    sb.scrollTarget = tf; 
    addChild(sb); 
    sb.update();   
} 

입니다.