-- RESUME BUTTON -- -- -- © July 2000, James Newton -- -- This behavior cannot function without the "History Button" -- behavior. It contains very little code: it simply sets its -- ancestor to the unique instance of the History Button behavior -- which is stored on the actorList (if it exists), and gets that -- instance to do almost all its work for it. -- PROPERTY DECLARATIONS -- property spriteNum property ancestor -- instance of the History Button on the actorList property mySprite -- sprite(me.spriteNum) -- EVENT HANDLERS -- on beginSprite(me) mySprite = sprite(spriteNum) me.findAncestor() me.setButtonState() end beginSprite on endSprite(me) -- Destroy reciprocal pointers call(#unsubscribe, [ancestor], me) end endSprite on mouseUp(me) if voidP(ancestor) then me.findAncestor() end if -- Use call..., just in case ancestor is still void, or does -- not include a goForward() handler, for some reason. call(#goForward, [me]) end mouseUp -- PRIVATE METHODS -- on findAncestor(me) --------------------------------------------------- -- Sent by beginSprite() and mouseUp() -- -- * Sets to the unique instance of the History Button -- behavior which is stored on the actorList... if it exists -------------------------------------------------------------------- historyInstance = [] call(#subscribe, the actorList, #history, historyInstance, me) ancestor = historyInstance.getLast() -- may be void end findAncestor on setButtonState(me) ------------------------------------------------- -- Sent by beginSprite(), and by the setButtonStates() handler in -- the ancestor instance, which may itself have been called by the -- mouseUp() handler in the current instance. -- -- * Informs any "Mouse States" behaviors on the same sprite that -- there are, or are not, any markers to History to. -------------------------------------------------------------------- behaviors = mySprite.scriptInstanceList if not ilk(behaviors, #list) then -- Due to a bug in D7.02 and beyond, the scriptInstanceList may be -- set to 0 until the playback head moves back a frame, if linked -- #movie members of a certain type are present. exit end if moreMarkersAhead = 0 if ilk(ancestor, #instance) then if ilk(ancestor.myResumeList, #list) then moreMarkersAhead = (ancestor.myResumeList).count() end if end if call(#toggleActive, mySprite.scriptInstanceList, moreMarkersAhead) end setButtonState -- INTER-SPRITE COMMUNICATION -- on subscribe(me, ID, returnList, historyInstance) -------------------- -- Sent by the beginSprite() handler of the History Button behavior -- in case the current behavior was instanciated first -- -- * Sets to the unique instance of the History Button -- behavior which is stored on the actorList, and returns a -- pointer to the History Button, so that a "Mouse States" -- instance on this sprite can activate|disactivate the Resume -- button -------------------------------------------------------------------- if ID <> #resume then exit else if not ilk(returnList, #list) then exit end if returnList.append(me) if ilk(historyInstance, #instance) then ancestor = historyInstance end if end subscribe -- BEHAVIOR DESCRIPTION -- on isOKToAttach(me, spriteType, spriteNumber) return spriteType = #graphic end on on getBehaviorTooltip me return \ "Use with graphic members."&RETURN&RETURN&\ "This behavior can only be used in conjunction with"&RETURN&\ "the 'History Button' behavior. When the user"&RETURN&\ "clicks on a sprite with this behavior the playback"&RETURN&\ "head will retrace the steps previously taken in"&RETURN&\ "the reverse direction by the 'History Button'." end getBehaviorTooltip on getBehaviorDescription me return \ "RESUME BUTTON"&RETURN&RETURN&\ "© July 2000, James Newton "&RETURN&RETURN&\ "Allows users to retrace their steps after having used the "&\ "'History Button'."&RETURN&RETURN&\ "This behavior requires an instance of the 'History Button' "&\ "behavior as its ancestor: it cannot function alone."&RETURN&RETURN&\ "While authoring, the 'History Button' and 'Resume Button' "&\ "may take you to other (unconnected) movies where you used the "&\ "same behavior. If you find this disconcerting, type "&\ "'clearGlobals' into the Message Window before you run your "&\ "current movie."&RETURN&RETURN&\ "PERMITTED MEMBER TYPES"&RETURN&"Graphic members"&RETURN&RETURN&\ "PARAMETERS: None"&RETURN&RETURN&\ "ASSOCIATED BEHAVIORS:"&RETURN&\ " + Go Marker Button"&RETURN&\ " + Go Movie Button"&RETURN&\ " + History Button"&RETURN&\ " + Mouse States (to alter rollover / mouseDown states)" end getBehaviorDescription