Domanda

i've searched all over the web, but i can't get the problem.

( adobe flash pro cs6 ) i've put a simple scrollpane on the stage and set a movieclip "pages" from the libary ( export for actionscript ) as the .source.

the "pages" movieclip has some keyframes and each of them represents a page. well, those pages are different in height and as i swich the pages, the scrollpane doesn't notice the changing height of the nested movieclip, so it stays on the scroll-bar-height of the first keyframe.

i've tryed .invalidate() and .refreshPane() but both of them work for me.

here is my code:

MAIN TIMELINE:

viewport.source = pages;
viewport.setSize( 990, 480 );
var pages_mc:MovieClip = viewport.content as MovieClip;

MENU TIMELINE

btn_a.buttonMode = true;
btn_a.addEventListener( MouseEvent.CLICK, btnClick );
btn_b.buttonMode = true;
btn_b.addEventListener( MouseEvent.CLICK, btnClick );

function btnClick( e:MouseEvent ):void {
    if( e.target.name == "btn_a" ) {
        MovieClip(root).pages_mc.gotoAndStop("pa");
        MovieClip(root).viewport.invalidate();
} else if( e.target.name == "btn_b" ) {
        MovieClip(root).pages_mc.gotoAndStop("pb");
        MovieClip(root).viewport.invalidate();
    }
}
È stato utile?

Soluzione

Try (assuming viewport is your ScrollPane) viewport.update().

I don't know where you've tried on the web, but the Adobe docs are actually pretty good on this. From the entry for refreshPane():

This method does not redraw the scroll bar. To reset the scroll bar, use the update() method.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/containers/ScrollPane.html#update%28%29

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/containers/ScrollPane.html#refreshPane%28%29

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top