From: Applied CD on
I?m updating a project that allows users to layout factory equipment on a
factory floor (2 dimensional, top down view only). The original project had a
fixed factory floor space (the stage) and about 20 different item types that
could be placed into that space. The new version must have a scrollable floor
and over 100 different item types (and up to 300 actual equipment sprites). I
figured no problem, I?ll make the factory floor an LDM holding all of the
equipment sprites with the behaviors to add, delete, group, move, rotate, etc?
while the main stage would have the scrollbars, user interface (tool pallets),
etc? The scrolling works great and I thought I was on the right track with the
LDM?s until I tried moving a sprite within the LDM. The code below is attached
to each equipment sprite and is responsible for movement ? I can?t use just a
simple moveable sprite because it was possible in the old project to move
sprites as a group as well as individually and I?d like to retain that
functionality, the global glSelectedList is a list of all the sprite numbers
currently selected, member names ending with ?.off? are swf?s showing
deselected equipment, member names ending in ?.on? are swf?s showing the same
equipment with a selection highlight. If I open the LDM and play it directly
everything works fine, the selected objects track with the mouse until mouseUp
? if I play the LDM through the user interface the LDM does not update while
the mouse is down, so the sprites stay put until mouseUp, then the sprites all
jump to the final location. Anyone know why this is happening? Was LDM a bad
choice? I had two other choices for the factory floor, MIAWs (I started this a
while ago, I don?t remember why I abandoned MIAWs but I remember the LDM came
together faster) or I could assign a block of sprites in the main stage to be
equipment sprites and scroll them under a bit bitmap mask to separate factory
floor from interface ? not very nice compartmentalization of roles and I doubt
scrolling the floor will be very smooth (potentially big repeat loop with lots
of equipment sprites) but maybe easier code in the long run.

global glSelectList

on mouseDown me
myMouseStartPos = _mouse.mouseLoc
-- Sprite Selection:
-- if the sprite is not in the select group and the shift is down, add me to
group
-- if the sprite is not in the select group and the shift is not down,
deselect others, select me, move to top
-- if the sprite is already in the select group and the shift is down,
deselect me
-- if the sprite is already in the select group and the shift is not down,
leave the group unchanged
if glSelectList.getOne(me.spriteNum) = 0 then
if not(_key.shiftDown) then deselectAll()
glSelectList.append(me.spriteNum)
sprite(me.spriteNum).member =
member(replaceString(sprite(me.spriteNum).member.name,".off",".on"))
else
if _key.shiftDown then
glSelectList.deleteOne(me.spriteNum)
sprite(me.spriteNum).member =
member(replaceString(sprite(me.spriteNum).member.name,".on",".off"))
else
nothing
end if
end if
myStartPosList = []
repeat with mySpriteNum in glSelectList
myStartPosList.append(sprite(mySpriteNum).loc)
end repeat
repeat while _mouse.mouseDown
myMouseOffset = _mouse.mouseLoc - myMouseStartPos
repeat with i = 1 to glSelectList.count()
sprite(glSelectList[i]).loc = myStartPosList[i] + myMouseOffset
updateStage
end repeat
end repeat
end