zoukankan      html  css  js  c++  java
  • SWFLibrary类加载外部资源库

    在as3中使用到外部SWF文件做为资源库,通常是用ApplicationDomain类的getDefinition()来得到类定义,

    再进行实例化。SWFLibrary类对这一方法封装,让调用外部资源库更通简单易用。
    // 建立SWFLibrary类的实例, 添加侦听器和加载swf文件----creates an instance of SWFLibrary, adds a listener, and loads a SWF
    var gameAssets:SWFLibrary = new SWFLibrary
    gameAssets.addEventListener( Event.COMPLETE, handleAssetsLoaded );
    gameAssets.load( "myCustomGameAssets.swf" );
     function handleAssetsLoaded(){
    // 访问资源----accesses the asset (assumes there is a symbol exported as 'Character' in the loaded SWF, as seen in step 1 above)
    //  以下代码在上面的事件[Event.COMPLETE]触发时运行----this code should run after the Event above has fired
    var mySprite:Sprite = gameAssets.getSprite( "Character" );
    addChild( mySprite );
     
    // 获取MovieClip资源----gets the asset as a MovieClip (assuming, of course, that it actually is a movieclip)
    var myMC:MovieClip = gameAssets.getSprite( "Character" );
    addChild( myMC );
     
    // 获取声音元件----getting a sound
    var mySound:Sound = gameAssets.getSound( "SoundLinkageNameHere" );
    mySound.play();
    }

    SWFLibrary 下载
    Usage
    1 – In Flash, select “Export for ActionScript” in the symbol’s Linkage settings in the Library (ex. ‘Character’).
    在Flash中,选择“作为ActionScript导出”,名称就是到时候要引用的那个,例如“Character”
    2 – Publish the Flash file as a SWF.
    发布成为swf
    3 – Load the SWF into an instance of SWFLibrary
    在SWFLibrary中加载
    4 – Access the symbol through SWFLibrary, using the class name chosen in Step 1.
    通过SWFLibrary,使用第一步里面的名称,就可以调用了

  • 相关阅读:
    阿里云ECS linux通过rinetd 端口转发来访问内网服务
    阿里云ECS linux通过iptables 配置SNAT代理网关,实现局域网上网
    适用于CentOS6.x系统的15项优化脚本
    ELK学习笔记
    MAC OSX环境下cordova+Ionic的安装配置
    Windows下 VM12虚拟机安装OS X 10.11 和VM TOOLS
    cordova 下载更新
    android adb常用命令
    ionic实现双击返回键退出功能
    ionic ngCordova插件安装
  • 原文地址:https://www.cnblogs.com/bulolo/p/2744152.html
Copyright © 2011-2022 走看看