Problem with Script Using New() to Create a #Vectorshape
Rod@FOF Apr 28, 2014 9:56 AMHello,
I am having a problem integrating an existing movie script into a movie I am building and I can't figure out why.
The single movie script, developed by JC in 2004, appears below. It works perfectly in a movie all by itself. But I need to integrate it into an existing movie in which other sprites and behaviors must coexist.
The problem I am seeing is that gMem is created with the new command (can see it in the message window using put gMem), but it will not allow attachment of gMem.regPoint, gMem.centerRegPoint, and so on. These all return errors.
I would also be open to another solution to the problem. What I need to do is create rectangles that represent a plan view of a rooftop on an underlying grid and then be able to drag and place other images on it (it is for training purposes, not a game).
I am using MX2004 on a PC. Any help, deeply appreciated.
Rod Wolford
------------------------------------------------------------------------------------------ --
global gMem, gCount, gNum, gLoc, gCreateVert, gMemNum
on prepareMovie
clearGlobals()
_movie.puppetTempo(60)
gCreateVert = False
gMemNum = 5
end
on mouseDown
if not(gCreateVert) then
gMem = new (#vectorShape, member gMemNum of castLib 1)
gMemNum = gMemNum + 1
gMem.regPoint = point(0,0)
gMem.centerRegPoint = False
gMem.closed = False
gMem.antialias = True
gMem.strokeWidth = 0.25
gMem.strokeColor = rgb(0,0,0)
gNum = getFreeChannel()
channel(gNum).makeScriptedSprite(gMem, point(0,0))
sprite(gNum).ink = 36
gCount = 0
gCreateVert = True
end if
if gCreateVert then
if the doubleClick then
gCreateVert = False
gCount = gCount - 1
gMem.deleteVertex(gCount)
gMem.closed = True
gMem.fillMode = #solid
gMem.fillColor = rgb(random(256) - 1,random(256) - 1,random(256) - 1)
gFinished = True
exit
end if
gCount = gCount + 1
gMem.addVertex(gCount, the mouseLoc)
gCount = gCount + 1
gMem.addVertex(gCount, the mouseLoc)
gLoc = the mouseLoc
end if
end
on enterFrame
if gCreateVert then
gMem.moveVertex(gCount, the mouseH - gLoc[1], the mouseV - gLoc[2])
theLoc = (gMem.vertexList)[gCount][1]
if not(theLoc = the mouseLoc) then
gMem.moveVertex(gCount, the mouseH - theLoc[1], the mouseV - theLoc[2])
end if
gLoc = the mouseLoc
end if
end
on stopMovie
theCount = castLib(1).member.count
repeat with i = 1 to theCount
if member(i).type = #vectorShape then member(i).erase()
end repeat
end
on getFreeChannel
repeat with i = 1 to the lastChannel
if sprite(i).member.type = #empty then
aNum = i
exit repeat
end if
end repeat
return aNum
end


