THE ACTORLIST
If you add an object (behavior or parent) to the “actorList” Director will send a “stepFrame” event to this object every time the stage is updated.
If you modify the contents of the “actorList” while inside a “stepFrame” handler Director will not send the “stepFrame” event correctly to the remaining objects in the list. Here is a workaround for this.
Movie Script:
on newPrepareMovie end on newStopMovie end on prepareMovie the actorList = [script("cActorList").new()] newPrepareMovie() end on stopMovie sendSprite(0, #endSprite) sendAllSprites(#endSprite) sprite(0).scriptInstanceList = [] repeat with c = 1 to the lastChannel sprite(c).scriptInstanceList = [] sprite(c).visible = TRUE sprite(c).puppet = FALSE end repeat the actorList = [] newStopMovie() abort() end on enableStepFrame aObject l = actorList[1].pActorList if not l.getPos(aObject) then l.add(aObject) end on disableStepFrame aObject the actorList[1].pActorList.deleteOne(aObject) end on setMovieValue aName, aValue the actorList[1].pValueList[aName] = aValue end on getMovieValue aName return the actorList[1].pValueList[aName] end on getFrameDelay return the actorList[1].pFrameDelay end on setFrameDelayMax aMax the actorList[1].pFrameDelayMax = aMax end
Parent Script “cActorList”:
property pActorList property pValueList property pFrameTime property pFrameDelay Property pFrameDelayMax on new me pActorList = [] pValueList = [:] pFrameTime = the milliSeconds pFrameDelay = 0 pFrameDelayMax = 250 return me end on stepFrame me vMilliSeconds = the milliSeconds pFrameDelay = min(pFrameTime - vMilliSeconds, pFrameDelayMax) pFrameTime = vMilliSeconds call(#stepFrame, duplicate(pActorList)) end