Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 我应该使用什么事件(显然不是MouseEvent)[I';我是as3的新成员]_Actionscript 3_Flash_Variables_Mouseevent - Fatal编程技术网

Actionscript 3 我应该使用什么事件(显然不是MouseEvent)[I';我是as3的新成员]

Actionscript 3 我应该使用什么事件(显然不是MouseEvent)[I';我是as3的新成员],actionscript-3,flash,variables,mouseevent,Actionscript 3,Flash,Variables,Mouseevent,我已经搜索过了,但我觉得答案太简单了,我找不到(我已经做了5天的flash) 我有一堆对象,当单击其中一个时,我的项目会上升,并且当项目>=1时,我希望另一个对象(苜蓿)发光 我用一个MouseEvent做这个,但是我不能让三叶草发光,除非我点击这个对象…所以很明显MouseEvent.click不是我想要的。我只希望对象在我的项目>=1时发光。下面的代码(为了简洁起见,我对其进行了编辑,所以可能遗漏了一些内容,但运行时没有出现错误) 如果我理解正确的话,您有很多项(为了保持简单,代码中只显示了

我已经搜索过了,但我觉得答案太简单了,我找不到(我已经做了5天的flash)

我有一堆对象,当单击其中一个时,我的项目会上升,并且当项目>=1时,我希望另一个对象(苜蓿)发光

我用一个MouseEvent做这个,但是我不能让三叶草发光,除非我点击这个对象…所以很明显MouseEvent.click不是我想要的。我只希望对象在我的项目>=1时发光。下面的代码(为了简洁起见,我对其进行了编辑,所以可能遗漏了一些内容,但运行时没有出现错误)


如果我理解正确的话,您有很多项(为了保持简单,代码中只显示了1项?merch.b1?)。单击这些项中的任何一项时,如果
var大于或等于
1
,则希望使
三叶草
发光

如果我有这个权利,那么这应该可以回答您的问题(附带一些减少冗余代码的技巧)


如果我理解正确的话,您有很多项(为了保持简单,代码中只显示了1项?merch.b1?)。单击这些项中的任何一项时,如果
var大于或等于
1
,则希望使
三叶草
发光

如果我有这个权利,那么这应该可以回答您的问题(附带一些减少冗余代码的技巧)


不清楚问题出在哪里?单击某个项目时不会发生任何情况?代码中的项目在哪里?这就是merch.b1的代码吗?似乎您需要做的就是在
grabB1
函数中调用
payUp()
,因为您不想让用户点击三叶草,对吗?是的,我想点击
merch.b1
,让三叶草发光。现在,当我点击merch.b1时,三叶草只会在我点击它时发光。如果我在单击merch.b1之前单击clover,它将不会发光(这是正确的)(我还有一个'merch.b2'、'merch.b3'等,但我在代码中遗漏了这些)不清楚问题是什么?单击某个项目时不会发生任何情况?代码中的项目在哪里?这就是merch.b1的代码吗?似乎您需要做的就是在
grabB1
函数中调用
payUp()
,因为您不想让用户点击三叶草,对吗?是的,我想点击
merch.b1
,让三叶草发光。现在,当我点击merch.b1时,三叶草只会在我点击它时发光。如果我在单击merch.b1之前单击clover,它将不会发光(这是正确的)(我还有一个'merch.b2'、'merch.b3'等,但我没有在这段代码中添加这些内容)非常感谢!还感谢您对代码其余部分的建议!谢谢,这很有帮助!还感谢您对代码其余部分的建议!
//import greensock
import com.greensock.*;
import flash.events.MouseEvent;

//make a variable to count items
var items = 0;

//add a click event to the clover
clover.addEventListener(MouseEvent.CLICK, payUp); //this is where i think it's wrong...

//click on b1 merch item
merch.b1.addEventListener(MouseEvent.CLICK, grabB1)

function grabB1(e: MouseEvent): void {
 //make the item disappear and add 1 to items
merch.b1.visible = false;
items++
merch.b1.removeEventListener(MouseEvent.CLICK, grabB1)
}

//explain the payUp function
function payUp(m:MouseEvent){
if (items >= 1) {
    //make the clover glow green
    TweenMax.to(clover, 0.5, {glowFilter:{color:0x66CC00, alpha:1, blurX:40, blurY:40}});
    clover.buttonMode = true;
    clover.useHandCursor = true;
    }
}
//add a click event to the clover
clover.addEventListener(MouseEvent.CLICK, cloverClick);
//disable the ability to click the clover at first
clover.mouseEnalbled = false;
clover.mouseChildren = false;

//click listeners for your items
merch.b1.addEventListener(MouseEvent.CLICK, itemClick);

function itemClick(e:MouseEvent):void {
    //make the item disappear

    var itemClicked:DisplayObject = e.currentTarget as DisplayObject;
    //e.currentTarget is a reference to the item clicked
    //so you can have just this one handler for all the items mouse clicks

    itemClicked.visible = false;

    //if you want the item to be garbage collect (totally gone), you also need to remove it from the display (instead of just making it invisible)
    itemClicked.parent.removeChild(itemClicked);

    items++
    itemClicked.removeEventListener(MouseEvent.CLICK, itemClick);

    //now see if the clover needs to grow
    playUp();
}

//explain the payUp function
function payUp(){
    if (items >= 1) {
        //make the clover glow green
        TweenMax.to(clover, 0.5, {glowFilter:{color:0x66CC00, alpha:1, blurX:40, blurY:40}});

        //make the clover clickable
        clover.buttonMode = true;
        clover.useHandCursor = true;
        clover.mouseEnalbled = true;
        clover.mouseChildren = true;
    }
}

function cloverClick(e:Event):void {
    //do whatever you need to do when the clover is clicked
}