I'm creating a custom Adobe Connect pod, a simple drag and drop in AS3 - which currently works in Adobe Connect, and has no bugs. It doesn't work with the SyncConnector elements though, which is where I'm struggling.
I've found a post elsewhere that suggests using each of my drag/drop items as an array. I've set up an array at the top of the code, then I have my drag/drop code, then my final parts for the Sync at the end. I'm getting a syntax error of "expecting rightparen before dot", which is for me - confusing - as I'm very new to AS3.
I'd really appreciate someone showing me the correct code I'd need, as I don't fully understand the terminology. I do literally need it spelt out for me. Full code below, happy to pay for someones time if this isn't an easy fix:
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;
}
}
The advice was exactly right. Make your code simpler because it is easy to miss a syntax error in that huge chunk of they-all-look-alike-oh-my-eyes lines of code. All your unreadable listeners should be replaced with this:
// 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;
}
Another one of my drag-n-drop related answers is here: https://stackoverflow.com/a/42542667/4687633
This error usually means there is a syntax error. Please change
function mouseListen(e.SyncSwfEvent):void
to
function mouseListen(e:SyncSwfEvent):void
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.