Flash播放器自從升級到Flash Player 9,0,28,0,也可以使網頁中的Flash通過一個簡單的按鈕實現全屏顯示,和一些視頻網站中的效果基本相同,但是在這個教程里是沒有使用Javascript腳本的啊!
需要我們在網頁中插入Flash代碼時,必須加上下面的代碼:
<param name="allowFullScreen" value="true" />
實現網頁中的Flash動畫全屏顯示源代碼
啟動Flash,制作一個按鈕元件,然后把按鈕放到主場景中,為按鈕添加代碼:
on(press){ toggleFullScreen();}
函數toggleFullScreen()是主要來控制窗口,函數定義如下。
//Don't scale the movie when the stage size changesStage.scaleMode="noScale";//Align the stage to the top leftStage.align = "TL";//Function to toggle between fullscreen and normal size//the toggle fullscreen button calls this function when pressedfunction toggleFullScreen(){ //if normal size, go to fullscreen, else go to normal size if(Stage["displayState"]=="normal"){ Stage["displayState"]="fullScreen"; }else{ Stage["displayState"]="normal"; }}//Create a listener for each time the Stage is resizedvar resizeListener:Object = new Object();//Called each time the stage is resizedresizeListener.onResize = function () { //Move the button to the center of the screen toggleFullScreenButton._x=Stage.width/2; toggleFullScreenButton._y=Stage.height/2;}//Add the listener to StageStage.addListener(resizeListener);
這樣就制作好了!
當我們把上面制作的Flash插入到網頁中時,具體代碼如下:
<object data="http://www.companysz.com/upfiles/20071018/20071018224608_fullscreen.swf"type="application/x-shockwave-flash" width="400" height="200" ><param name="movie" value="http://www.companysz.com/upfiles/20071018/20071018224608_fullscreen.swf" /><param name="allowFullScreen" value="true" /></object>
就可以看到前面的全屏和收縮效果了!
新聞熱點
疑難解答