动作3 - 对增量/计数器负载和图书馆形象 [英] Actionscript 3 - load and library image on increment / counter

查看:181
本文介绍了动作3 - 对增量/计数器负载和图书馆形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的Flash影片。

I have a very simple flash movie.

  • 在24 PNG图像库中的
  • 在图像属性被设置为为ActionScript导出和班级命名为此搜索,图像2等
  • 单帧时间轴中

我需要在电影开头的动态加载此搜索在舞台上。我已经能够使用的BitmapData ojects做到这一点。

I need to dynamically load 'image1' on the stage at the start of the movie. I have been able to do this using BitmapData ojects.

在单击图像,我需要增加一个内部图像,并与IMAGE2替换图像在屏幕上。

On clicking the image, I need to increment an internal image and replace the image on screen with image2.

当我尝试通过该库类,它抛出一个错误的变量。

When I try to pass the library class as a variable it throws an error.

谁能帮我举个例子?

任何问题,只是让我知道。

Any questions, just let me know.

推荐答案

加载外部可能是方便,但图书馆的做法是可行的。 您需要为使用的LoaderInfo程序的applicationDomain的<一个href="https://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/system/ApplicationDomain.html#getDefinition%28%29"相对=nofollow> getDefinition()方法,或 <一href="https://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName%28%29"相对=nofollow> flash.utils.getDefinitionByName();

Loading externally might be handy, but the library approach is doable. You need to either use loaderInfo's applicationDomain's getDefinition() method, or flash.utils.getDefinitionByName();

应用领域例如:

for(var i:int = 0 ; i < imagesNum ; i++){
    var ImageClass:Class = this.loaderInfo.applicationDomain.getDefinition('YourLinkageID'+i) as Class;
    //I add 0,0 because since you have png, they will extend BitmapData which has width and height as compulsory 
    //constructor arguments. If the thing doesn't look right, use the actual dimensions instead of 0,0
    var bitmap:Bitmap = new Bitmap(new ImageClass(0,0));
    //display it or do whatever
}

getDefinitionByName例如:

getDefinitionByName example:

import flash.utils.*;

for(var i:int = 0 ; i < imagesNum ; i++){
    var ImageClass:Class = getDefinitionByName('YourLinkageID'+i) as Class;
    var bitmap:Bitmap = new Bitmap(new ImageClass(0,0));
    //display it or do whatever
}

心连心, 乔治

HTH, George

这篇关于动作3 - 对增量/计数器负载和图书馆形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆