zoukankan      html  css  js  c++  java
  • 使用Loader,运行时加载图片

    BitmapImage只能在使用@Embed位图,要想在运行时加载,可以参考下面的代码

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
     3                xmlns:s="library://ns.adobe.com/flex/spark" 
     4                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
     5                creationComplete="application1_creationCompleteHandler(event)">
     6     
     7     <fx:Script>
     8         <![CDATA[
     9             import mx.controls.Alert;
    10             import mx.events.FlexEvent;
    11 
    12             protected function application1_creationCompleteHandler(event:FlexEvent):void
    13             {
    14                 var loader:Loader = new Loader();
    15                 loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaderComplete);
    16                 loader.load(new URLRequest("assets/google.png"));
    17             }
    18             
    19             private function handleLoaderComplete(event:Event):void
    20             {
    21                  var bmp:Bitmap = LoaderInfo(event.target).content as Bitmap;
    22                 bf.source = bmp; 
    23             }
    24             
    25         ]]>
    26     </fx:Script>
    27     
    28     <fx:Declarations>
    29         <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    30     </fx:Declarations>
    31     
    32     <s:layout>
    33         <s:VerticalLayout />
    34     </s:layout
    35     
    36     <s:Graphic>
    37         <s:Group>
    38             <s:Ellipse width="300" height="300">
    39                 <s:fill>
    40                     <s:BitmapFill id="bf" fillMode="repeat"/>
    41                 </s:fill>
    42                 
    43             </s:Ellipse>
    44         </s:Group>
    45     </s:Graphic>
    46     
    47     
    48 </s:Application>
  • 相关阅读:
    屏幕的真实分辨率大小
    CCConfiguration::sharedConfiguration()->loadConfigFile cocos2d-x 中文乱码问题及国际化解决方案
    git 放弃提交到提交之前
    cocos2d-x 输出debug信息
    Ubuntu设置环境变量
    有时候需要统计手机的型号和版本号,利用程序可以获取到相应的手机信息.
    读取 android sys/下的信息
    android 读取 raw 中的文件。
    C/C++中结构体(struct)
    异步图片下载引擎(升级版——ExecutorService+handler)
  • 原文地址:https://www.cnblogs.com/iihe602/p/2440631.html
Copyright © 2011-2022 走看看