`
it_liuyong
  • 浏览: 97755 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flex修改application加载进度条preloader的位置

    博客分类:
  • flex
 
阅读更多
flex修改application加载进度条preloader的位置 博客分类: flex
FlexAdobeFlash. 哎查点资料还要科学上网。。。




如果flex页面的高度超过屏幕默认高度的话,有可能application初始化进度条看不到,




因为preloader的位置始终是居中的,虽然它事实上是存在的,但是很可能需要将滚动条下拉




才能看见,不知情的可能以为页面假死了。下面就介绍如何修改preloader的位置。




来源:http://www.mehtanirav.com/2010/03/19/showing-flex-preloader-near-the-top-of-your-application







    自定义进度条:
Java代码 
1.package com.components  
2.{  
3.  import flash.events.ProgressEvent;  
4.  import mx.preloaders.DownloadProgressBar;  
5. 
6.  public class MyDownloadProgressBar extends DownloadProgressBar  
7.  {  
8.    public function MyDownloadProgressBar()  
9.    {  
10.      super();  
11.      // Set the download label.  
12.      downloadingLabel="Downloading..." 
13.      // Set the initialization label.  
14.      initializingLabel="Initializing..." 
15.    }  
16. 
17.    // Override to return true so progress bar appears during initialization.  
18.    override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean {  
19.      return true;  
20.    }  
21. 
22.    // Override to return true so progress bar appears during download.  
23.    override protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean {  
24.      return true;  
25.    }  
26. 
27.    // Override initialize so that we can position the loader  
28.    override public function initialize():void {  
29.      super.initialize();  
30.      center(stageWidth, (stageHeight > 250) ? 250 : stageHeight);  
31.    }  
32.  }  
33.} 
package com.components
{
  import flash.events.ProgressEvent;
  import mx.preloaders.DownloadProgressBar;

  public class MyDownloadProgressBar extends DownloadProgressBar
  {
    public function MyDownloadProgressBar()
    {
      super();
      // Set the download label.
      downloadingLabel="Downloading..."
      // Set the initialization label.
      initializingLabel="Initializing..."
    }

    // Override to return true so progress bar appears during initialization.
    override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean {
      return true;
    }

    // Override to return true so progress bar appears during download.
    override protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean {
      return true;
    }

    // Override initialize so that we can position the loader
    override public function initialize():void {
      super.initialize();
      center(stageWidth, (stageHeight > 250) ? 250 : stageHeight);
    }
  }
}





  

          在Application页面这样写:





Java代码 
1.<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
2.    preloader="com.components.MyDownloadProgressBar"> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
preloader="com.components.MyDownloadProgressBar">



 


         或者在Flex4里





Java代码 
1.<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
2.               xmlns:s="library://ns.adobe.com/flex/spark" 
3.               xmlns:mx="library://ns.adobe.com/flex/mx" 
4.               xmlns:components="components.*" 
5.               preloader="components.MyDownloadProgressBar" > 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   xmlns:components="components.*"
   preloader="components.MyDownloadProgressBar" >


 
  其中关键代码是initialize函数里的



center(stageWidth, (stageHeight > 250) ? 250 : stageHeight),这句的意思是如果屏幕高度超过

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics