[英]Syntax error - rightparen - ActionScript 3 - using an array
我正在創建一個自定義 Adobe Connect pod,在 AS3 中進行簡單的拖放操作 - 目前可在 Adobe Connect 中使用,並且沒有錯誤。 不過,它不適用於 SyncConnector 元素,這正是我苦苦掙扎的地方。
我在別處找到了一篇文章,建議將我的每個拖放項用作數組。 我在代碼的頂部設置了一個數組,然后我有我的拖/放代碼,然后是我最后的同步部分。 我收到“在點之前期望右括號”的語法錯誤,這對我來說 - 令人困惑 - 因為我對 AS3 非常陌生。
我真的很感激有人向我展示我需要的正確代碼,因為我不完全理解術語。 我確實需要為我詳細說明。 下面的完整代碼,如果這不是一個簡單的解決方案,很樂意為某人支付時間:
import com.adobe.sync.components.SyncConnector;
import com.adobe.sync.events.SyncSwfEvent;
var connector:SyncConnector;
function init(c:SyncConnector):void
{
connector=c;
}
// Keep stage reference here.
var draggedStage:Stage;
// Keep dragged item reference here.
var draggedItem:InteractiveObject;
// The list of items to drag.
var aList:Array =
[
AirBP,PetroChem,LiquifiedGas,Exploration,Plastic,
BiofuelsFarm,Trading,Electricity,Development,
Production,Distribution,Lubes,Retail,Shipping,
Refining,BPMarine,Terminal,Terminal2,Pipeline,
Pipeline2,SugarCane,WindPower
];
// Subscribe all items for MOUSE_DOWN event.
for each (draggedItem in aList)
draggedItem.addEventListener(MouseEvent.MOUSE_DOWN, onDrag);
function onDrag(e:MouseEvent):void
{
// Get the source of event.
draggedItem = e.target as InteractiveObject;
draggedItem.startDrag();
// Hook the stage events for MOUSE_UP event. You can skip using "draggedStage"
// if you are sure that stage reference is always available.
draggedStage = dtaggedItem.stage;
draggedStage.addEventListener(MouseEvent.MOUSE_UP, onDrop);
}
function onDrop(e:MouseEvent):void
{
// Stopp dragging things.
draggedItem.stopDrag();
// Unhook stage for it is no longer needed.
draggedStage.removeEventListener(MouseEvent.MOUSE_UP, onDrop);
// Forget the references.
draggedItem = null;
draggedStage = null;
}
connector.dispatchSyncMessage("dragdrop", myObj, true);
connector.addEventListener(SyncSwfEvent.SYNC_MSG_RCVD, mouseListen);
function mouseListen(e.SyncSwfEvent):void
{
if (e.data.msgNm == "dragdrop") {
myObj = e.data.msgVal as Array;
}
}
這個建議完全正確。 使您的代碼更簡單,因為很容易在一大塊看起來很相似的代碼行中遺漏語法錯誤。 所有不可讀的監聽器都應該替換為:
// Keep stage reference here.
var draggedStage:Stage;
// Keep dragged item reference here.
var draggedItem:InteractiveObject;
// The list of items to drag.
var aList:Array =
[
AirBP,PetroChem,LiquifiedGas,Exploration,Plastic,
BiofuelsFarm,Trading,Electricity,Development,
Production,Distribution,Lubes,Retail,Shipping,
Refining,BPMarine,Terminal,Terminal2,Pipeline,
Pipeline2,SugarCane,WindPower
];
// Subscribe all items for MOUSE_DOWN event.
for each (draggedItem in aList)
draggedItem.addEventListener(MouseEvent.MOUSE_DOWN, onDrag);
function onDrag(e:MouseEvent):void
{
// Get the source of event.
draggedItem = e.target as InteractiveObject;
draggedItem.startDrag();
// Hook the stage events for MOUSE_UP event. You can skip using "draggedStage"
// if you are sure that stage reference is always available.
draggedStage = draggedItem.stage;
draggedStage.addEventListener(MouseEvent.MOUSE_UP, onDrop);
}
function onDrop(e:MouseEvent):void
{
// Stopp dragging things.
draggedItem.stopDrag();
// Unhook stage for it is no longer needed.
draggedStage.removeEventListener(MouseEvent.MOUSE_UP, onDrop);
// Forget the references.
draggedItem = null;
draggedStage = null;
}
我的另一個拖放相關答案在這里: https : //stackoverflow.com/a/42542667/4687633
此錯誤通常意味着存在語法錯誤。 請更換
function mouseListen(e.SyncSwfEvent):void
到
function mouseListen(e:SyncSwfEvent):void
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.