我对 as3 代码有疑问。当我停止拖放时,我想重新启动我的轮播,但有些时候,在拖动之后,有些元素没有重新开始移动。这是drop的代码
function drop(event:MouseEvent):void
{
event.target.stopDrag();
event.target.visible=false;
var myTargetName:String = "antipasti_drag";
var myTargetName1:String = "primi_drag";
var myTargetName2:String = "secondi_drag";
var myTargetName3:String = "contorni_drag";
var myTargetName4:String = "bevande_drag";
var myTargetName5:String = "dessert_drag";
var myTarget:DisplayObject = getChildByName(myTargetName);
var myTarget1:DisplayObject = getChildByName(myTargetName1);
var myTarget2:DisplayObject = getChildByName(myTargetName2);
var myTarget3:DisplayObject = getChildByName(myTargetName3);
var myTarget4:DisplayObject = getChildByName(myTargetName4);
var myTarget5:DisplayObject = getChildByName(myTargetName5);
if (event.target.dropTarget != null || event.target.dropTarget.parent == myTarget || event.target.dropTarget.parent == myTarget1 || event.target.dropTarget.parent == myTarget2 || event.target.dropTarget.parent == myTarget3 || event.target.dropTarget.parent == myTarget4 || event.target.dropTarget.parent == myTarget5) // se trascini da sotto a sopra
{
switch (portata)
{
case 0: prima();
break;
case 1: seconda ();
break;
case 2: terza ();
break;
case 3: quarta ();
break;
case 4: quinta ();
break;
case 5: sesta ();
break;
}
function prima ():void
{
switch(trascina)
{
case 0: objSel0.x=event.target.x;
objSel0.y=event.target.y;
addChild(objSel0);
nuova_lunghezza();
break;
case 1: objSel1.x=event.target.x;
objSel1.y=event.target.y;
addChild(objSel1);
nuova_lunghezza();
break;
case 2: objSel2.x=event.target.x;
objSel2.y=event.target.y;
addChild(objSel2);
nuova_lunghezza();
break;
case 3: objSel3.x=event.target.x;
objSel3.y=event.target.y;
addChild(objSel3);
break;
nuova_lunghezza();
case 4: objSel4.x=event.target.x;
objSel4.y=event.target.y;
addChild(objSel4);
break;
nuova_lunghezza();
case 5: objSel5.x=event.target.x;
objSel5.y=event.target.y;
addChild(objSel5);
nuova_lunghezza();
break;
}
}
function seconda ():void {
switch(trascina)
{
case 0: objSel6.x=event.target.x;
objSel6.y=event.target.y;
addChild(objSel6);
nuova_lunghezza();
break;
case 1: objSel7.x=event.target.x;
objSel7.y=event.target.y;
addChild(objSel7);
nuova_lunghezza();
break;
case 2: objSel8.x=event.target.x;
objSel8.y=event.target.y;
addChild(objSel8);
nuova_lunghezza();
break;
case 3: objSel9.x=event.target.x;
objSel9.y=event.target.y;
addChild(objSel9);
break;
nuova_lunghezza();
case 4: objSel10.x=event.target.x;
objSel10.y=event.target.y;
addChild(objSel10);
break;
nuova_lunghezza();
case 5: objSel11.x=event.target.x;
objSel11.y=event.target.y;
addChild(objSel11);
nuova_lunghezza();
break;
}
}
function terza ():void {
switch(trascina)
{
case 0: objSel12.x=event.target.x;
objSel12.y=event.target.y;
addChild(objSel12);
nuova_lunghezza();
break;
case 1: objSel13.x=event.target.x;
objSel13.y=event.target.y;
addChild(objSel13);
nuova_lunghezza();
break;
case 2: objSel14.x=event.target.x;
objSel14.y=event.target.y;
addChild(objSel14);
nuova_lunghezza();
break;
case 3: objSel15.x=event.target.x;
objSel15.y=event.target.y;
addChild(objSel15);
break;
nuova_lunghezza();
case 4: objSel16.x=event.target.x;
objSel16.y=event.target.y;
addChild(objSel16);
break;
nuova_lunghezza();
case 5: objSel17.x=event.target.x;
objSel17.y=event.target.y;
addChild(objSel17);
break;
}
}
function quarta ():void {
switch(trascina)
{
case 0: objSel18.x=event.target.x;
objSel18.y=event.target.y;
addChild(objSel18);
nuova_lunghezza();
break;
case 1: objSel19.x=event.target.x;
objSel19.y=event.target.y;
addChild(objSel19);
nuova_lunghezza();
break;
case 2: objSel20.x=event.target.x;
objSel20.y=event.target.y;
addChild(objSel20);
nuova_lunghezza();
break;
case 3: objSel21.x=event.target.x;
objSel21.y=event.target.y;
addChild(objSel21);
break;
nuova_lunghezza();
case 4: objSel22.x=event.target.x;
objSel22.y=event.target.y;
addChild(objSel22);
nuova_lunghezza();
break;
case 5: objSel23.x=event.target.x;
objSel23.y=event.target.y;
addChild(objSel23);
nuova_lunghezza();
break;
}
}
function quinta ():void {
switch(trascina)
{
case 0: objSel24.x=event.target.x;
objSel24.y=event.target.y;
addChild(objSel24);
nuova_lunghezza();
break;
case 1: objSel25.x=event.target.x;
objSel25.y=event.target.y;
addChild(objSel25);
nuova_lunghezza();
break;
case 2: objSel26.x=event.target.x;
objSel26.y=event.target.y;
addChild(objSel26);
nuova_lunghezza();
break;
case 3: objSel27.x=event.target.x;
objSel27.y=event.target.y;
addChild(objSel27);
nuova_lunghezza();
break;
case 4: objSel28.x=event.target.x;
objSel28.y=event.target.y;
addChild(objSel28);
nuova_lunghezza();
break;
case 5: objSel29.x=event.target.x;
objSel29.y=event.target.y;
addChild(objSel29);
nuova_lunghezza();
break;
}
}
function sesta ():void {
switch(trascina)
{
case 0: objSel30.x=event.target.x;
objSel30.y=event.target.y;
addChild(objSel30);
nuova_lunghezza();
break;
case 1: objSel31.x=event.target.x;
objSel31.y=event.target.y;
addChild(objSel31);
nuova_lunghezza();
break;
case 2: objSel32.x=event.target.x;
objSel32.y=event.target.y;
addChild(objSel32);
nuova_lunghezza();
break;
case 3: objSel33.x=event.target.x;
objSel33.y=event.target.y;
addChild(objSel33);
nuova_lunghezza();
break;
case 4: objSel34.x=event.target.x;
objSel34.y=event.target.y;
addChild(objSel34);
nuova_lunghezza();
break;
case 5: objSel35.x=event.target.x;
objSel35.y=event.target.y;
addChild(objSel35);
nuova_lunghezza();
break;
}
}
function nuova_lunghezza():void{
new_length = itemArray.length - 1;
}
}
else //se il target lo ritrascino da sopra a sotto
{
new_length = itemArray.length;
}
for (var i:Number = 0; i < new_length; i++) // ridai vita al corousel
{
itemArray[i].addEventListener(Event.ENTER_FRAME, animate);
}
}
拜托,有人可以帮助我。我试图移动event.target.visible=false;
我的代码的每一部分,但问题仍然存在。
在这里,您可以通过单击名为“carne”的按钮找到我的 video.sfw 的示例https://www.box.com/s/sdlryf5gfg2vw6xrvjrf
问候