English 中文(简体)
AS3 动态地增加纽芬兰语,以进入不同功能阶段和进入
原标题:AS3 Dynamically adding buttons to stage and accessing in different function

我正试图将同一纽芬兰语的多种不同版本加到这个阶段,并能够稍后通过指定一个身份证进入。 我假定这样做的方式是,在确定内部静态变量的纽芬兰州有一个等级,以便可以在下一个职能中找到该等。 这似乎并不奏效,因为身份证不断显示最后的号码,因此在本案中是6。

我假定,我正在这样做吗? 我的守则使你能更好地了解:

package src  {

import flash.display.MovieClip;
import flash.events.*;
import flash.utils.Timer;
import flash.net.*
import flash.display.Loader

public class main extends MovieClip {

public var xmlData:XML = new XML
public var currentName = null

    public function main() {
        var y = 0
        for(x=0; x<=6; x++){
            var names:namez = new namez
            namez.ID = y
            y++
            names.y = x*25
            names.addEventListener(MouseEvent.CLICK, checkMe)
            spinner.addChild(names)
        }
    }

    public function checkMe(e:MouseEvent){
        trace("clicked"+namez.ID)
    }
}
}

namez.as class:

package src {

import flash.display.MovieClip

public class namez extends MovieClip{

    internal static var ID

    public function namez() {
    }

}

}

尽管为国名做了追踪。 ID and it better show 0,1,2,3,4,5,6 when the button is listed on, the only number that show is 6.

我如何正确对待如何使有活力的附加纽子能够利用其他职能? 我是否应该在这里使用一个阵列?

FYI the total number of buttons required is 241.

最佳回答

由于ID是一个静态变量,这意味着所有名字都只有一个身份证,而它像你希望每个案例都有一个身份证。 简单地消除静态属性,将国际发展法定义为:

internal var ID

Pbirkoff就你如何回去打好。 国际发展学会的财产,但你也可能想将活动目标投到名称类别,以获得更多的习俗财产。

我还注意到,你再次遗漏了可能或不一定需要的一些半殖民地和类型定义,但这些都是良好的方案拟订做法:

public function main():void {
    var y:int = 0
    for (x:int = 0; x<=6; x++) {
        var names:namez = new namez();
        namez.ID = y;
        y++;
        names.y = x*25;
        names.addEventListener(MouseEvent.CLICK, checkMe);
        spinner.addChild(names);
    }
}

private function checkMe(e:MouseEvent):void {
    var names:namez = e.target as namez;
    trace("clicked" + names.ID);
}
问题回答

我认为,问题在于,国名上的身份证是静止的。 因此,你不把伊德价值分配给特定情况,而是重新划给名称。

变数公有财产

public var Id:int;

此外,在您的活动中,生活保障者的职能检查。 顺便说一句,你再次提到阶级名称,而不是这样。 将职能改为:

public function checkMe(e:MouseEvent)
{
    trace( clicked:   + e.target.Id);
}




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

Red5 Security Tutorial

I am looking for a step by step tutorial on securing Red5 from intrusion. This seems to be a question that comes up alot in a google search, but is never really answered in a way that makes sense to ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

visible property of DisplayObject

For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set mc1.visible = false; mc2.visible stays true. Is that supposed to happen?...

热门标签