动作3 - 对增量/计数器负载和图书馆形象增量、负载、计数器、图书馆

2023-09-08 15:34:18 作者:扑进先生怀里

我有一个非常简单的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的 getDefinition()方法,或 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