Resize flash object from the browser without flick

2019-09-04 12:58发布

I was wondering how to achieve the native scrollbar effect which TheFWA (thefwa.com) has managed to do pretty well (I am not a fan of Flex scrollbars).

I found this post (http://stackoverflow.com/questions/318675/how-can-i-create-a-flex-application-with-dynamic-height), and implemented the technique, as I am calling a JS function through ExternalInterface every time, when the flash object changes size. This JS function simply resizes the div which holds the flash object, which creates the native bars.

Unfortunately, when I resize quite rapidly (from 800 to 1800 height, for instance) the flash object simply gets warped for several milliseconds (as if it hasn't changed its size, but simply got pulled in all directions). After these milliseconds, things get back to normal, but the whole situation is really visually annoying.

Originally I thought that it's simply a timing issue, but after a bunch of attempts to set a delay, the effect was the same ... just delayed.

How can I resolve that? I know it's technically possible. Just take a look at TheFWA, and see how smoothly flash and the browser are communicating with each other to make the native scroll bars work, without any flickering, or mismeasurement

3条回答
啃猪蹄的小仙女
2楼-- · 2019-09-04 13:35

The flash content on that site has fixed size. What they did is to put the swf file in a centered div. Something like this:

...header stuff...
<body>
    <div id="flashContent" style="width:960px; margin:0 auto;">
        ...the flash content goes here...
    </div>
</body>

The width of the div container should be the width of your flash movie.

If you want to resize the flash movie then take a look at swffit

查看更多
聊天终结者
3楼-- · 2019-09-04 13:42

This is an issue that appeared since Flash Player 10 and is still happening up to FP 11 beta.

When you resize the DIV that contains the SWF, the SWF itself is resized, therefore you "ask" the player to redraw the content. But the thing is that this redraw creates this ugly flicker.

The workaround it to not resize the SWF DIV at all and to resize another empty DIV, so you force the browser to update the scrollbar.

At this point when you use the scrollbar it won't move the SWF DIV (as it is probably often a position absolute full-size flash site) but then you create a simple JS callback to send the scroll values to your application.

It may sound as a much greater effort but it is not much actually, and at the end you will create a more flexible way to manage your application.

You can check that in use here http://www.andrefelipe.com/

And the source code is at my framework https://github.com/andrefelipe/fabricaframework/blob/master/src/fabrica/external/Browser.as

查看更多
叛逆
4楼-- · 2019-09-04 13:47

That site isn't doing anything special, simply setting the height and width of the application and slapping it on the page - no resize is happening. If you simply employ the same technique (specifying a height for the app) then you will get the same results.

Am I missing something?

查看更多
登录 后发表回答