Click to go to the home page.

See Also
"Dynamism" script
"Dynamism" destructors
"Script Writer" movie script

 

Site Nav

css drop down menu by Css3Menu.com

Miscellaneous Handlers

Miscellaneous Handy Handlers

If you use the Dynamic Attachers, then use wfsRemoveScriptAndRunEndSprite to remove the behavior.

Click to go to top of section. wfsRemoveScriptAndRunEndSprite(theSpriteNum, theScriptName)

Function

This runs the endSprite handler of only theScriptName which is attached to theSpriteNum, if theScriptName does indeed have an endSprite handler, and then de-attaches the first instance of the script named theScriptName from the sprite with spriteNum=theSpriteNum, if the script is indeed attached to it. This handler will detach scripts attached to dynamic and non-dynamic sprites. This handler first checks to see if the behavior is attached (via a call to wfsScriptIsAttached). It returns 0 if the script is not attached to theSpriteNum.

Parameters

theSpriteNum: This is the spritenum of the sprite you want to remove the behavior from.

theScriptName: This is the (string) name of the script you want de-attached.

Return Value

It returns 1 if the script was successfully de-attached, and 0 otherwise. If there are multiple instances of the script attached to theSpriteNum, then only the first instance is removed.

Example

theBooleanResult = wfsRemoveScriptAndRunEndSprite(4, "some behavior")

The below runs the endSprite handler, if it exists, in the "some behavior" behavior attached to sprite 4 (if "some behavior" is indeed attached to sprite 4), and then detaches the first instance of this script from sprite 4 (if there are any such instances to detach).

Click to go to top of section. wfsScriptIsAttached (theSpriteNum, theScriptName)

Function

This is for determining whether a particular script is attached to a particular sprite. You can call wfsScriptIsAttached on dynamic and static sprites.

Parameters

theSpriteNum: This is the spritenum of the sprite you want to inspect.

theScriptName: This is the (string) name of the script you want to check for.

Return Value

This returns an index into sprite(theSpriteNum).scriptInstanceList at which the script named theScriptName is located, if the script is indeed attached to theSpriteNum. It returns 0 otherwise. For instance, if this handler returns 3, then sprite(theSpriteNum).scriptInstanceList[3] is an instance of theScriptName.

Example

theResult=wfsScriptIsAttached(5, "some behavior")

The above determines whether the behavior named "some behavior" is attached to sprite 5. If it is, then theResult will be a positive integer indicating the index of the first instance of "some behavior" in sprite(theSpriteNum).scriptInstanceList

Click to go to top of section. wfsGetScriptNameList (theSpriteNum)

Function

Returns a list containing the names of the behaviors attached to theSpriteNum.

Parameters

theSpriteNum: The spritenum of the sprite you want to examine.

Return Value

A linear list of strings. The strings are the names of the behaviors attached to theSpriteNum.

Example

theListResult = wfsGetScriptNameList(5)

The above returns a list of the names of the behaviors attached to sprite 5.

Click to go to top of section. wfsGenerateManagerName (theManagerName, theFamilyIdentifier)

Function

This is called by code generated by wfsWriteMultiSprite to generate the name of a dynamic multi-sprite. The name of an instantiated multi-sprite must be unique among all instantiated multi-sprites. This handler generates a name that is unique among instantiated multi-sprites.

Also, if we dynamically generate a family of multi-sprites, there may be links among them. For instance, menus generally open submenus that are part of the same family. So the Script Writer has not only to come up with a unique name, but it has to be cognizant of links among the family.

Multi-sprites generated by code returned by wfsWriteMultiSpriteFamily (which calls wfsGenerateManagerName with a non-void familyIdentifier parameter) have names that have three components separated by the "+" symbol. So these names are not really appropriate for display to the user. The first component is the name of the static model multi-sprite. The second component is the name of the multi-sprite at which you aimed wfsWriteMultiSpriteFamily. The third component is a number indicating the number of dynamic copies of this family.

Multi-sprites generated by code returned by wfsWriteMultiSprite (which calls wfsGenerateManagerName with a VOID familyIdentifier parameter) have names that have two components separated by the "+" symbol. The first component is the name of the static model multi-sprite. The second component is a number indicating the number of dynamic copies of this multi-sprite.

Parameters

theManagerName is the string that names the multi-sprite on which the dynamic multi-sprite is modelled.

theFamilyIdentifier is a parameter that is VOID unless we are generating a family of multisprites. Note that when wfsWriteMultispriteFamily calls wfsWriteMultiSprite, it specifies theFamilyIdentifier.

Return Value

Returns a name you can name the dynamic multi-sprite with, ie, no other instantiated multi-sprite will have this name.

Example

The code below was generated by wfsWriteMultiSprite. Note that it makes a call to wfsGenerateManagerName before the dynamic manager is created.

 

on wfsCreatemenu111E36F570  (familyIdentifier)
  --This is code generated by the wfsWriteMultiSprite handler located in the Script
  --Writer movie script. This code was  generated to dynamically reproduce
  --the multi-sprite named "menu1,1,1" whose manager was located
  --in channel 36, frame 570. When you run this handler, it creates
  --a copy of the "menu1,1,1" multi-sprite. This handler returns the spriteNum
  --of the manager of the resulting dynamic multi-sprite or 0 if there are
  --not enough available dynamic sprite channels to generate the multi-sprite.
  --The new multi-sprite's name will be generated by this handler since
  --multi-sprite names have to be unique. Use wfsGetManagerName(managerSpriteNum)
  --on the return value to see the name. You can call this handler multiple times
  --in your movie. Each time you call it, it creates a different copy of "menu1,1,1".
  --Don't specify any value for the 'familyidentifier' parameter. The
  --'familyIdentifier' parameter is used by wfsWriteMultiSpriteFamily output
  --in calls to wfsWriteMultiSprite output. Don't worry about it!
    if wfsGetNumberOfDynamicAvailableChannels() >= 3 then
      --Proceed only if there are enough channels to create all of the multisprite.
      theManagerName = wfsGenerateManagerName("menu1,1,1", familyIdentifier)
      --The name will be different from the original'
      --CREATE A SPRITE AND INIT IT:*******************************************
      theNewSpriteNum = wfsCreateSprite(["Menu Manager bitmap", "WFS 4", 0, 0, 1, 1, -82, -81, 1])
      --parameters: [member, cast, ink, blend, width, height, locH, locV, doNotCreateNewMember]
      --If you don't specify a value for doNotCreateNewMember, then a copy of the member will be created.
      theManagerSpritenum = theNewSpriteNum
      theScript=wfsAttachBehavior("Menu Manager", theNewSpritenum, [#pWFSManagerName: theManagerName, #pWFSParentName: wfsAdjustParent("menu1,1", theManagerName, familyIdentifier)])
      --CREATE A SPRITE AND INIT IT:*******************************************
      theNewSpriteNum = wfsCreateSprite(["menu background", "7: Normal Menus", 0, 100, 101, 24, 290, 61, 1])
      --parameters: [member, cast, ink, blend, width, height, locH, locV, doNotCreateNewMember]
      --If you don't specify a value for doNotCreateNewMember, then a copy of the member will be created.
      theScript=wfsAttachBehavior("4: Window/Menu Element", theNewSpritenum, [#pWFSManagerName: theManagerName, #pWFSManagerSpriteNum: theManagerSpriteNum])
      --CREATE A SPRITE AND INIT IT:*******************************************
      theNewSpriteNum = wfsCreateSprite(["modal dialog...", "7: Normal Menus", 36, 100, 87, 12, 292, 62, 1])
      --parameters: [member, cast, ink, blend, width, height, locH, locV, doNotCreateNewMember]
      --If you don't specify a value for doNotCreateNewMember, then a copy of the member will be created.
      theScript=wfsAttachBehavior("4: Window/Menu Element", theNewSpritenum, [#pWFSManagerName: theManagerName, #pWFSManagerSpriteNum: theManagerSpriteNum])
      theScript=wfsAttachBehavior("Menu Verb", theNewSpritenum, [#pWFSOpenAMenu: "mouseUp", #pWFSNameOfMenuToOpen: wfsComputeLink("1", familyIdentifier), #pWFSMenuOpeningLocation: "Do not move it, just open it.", #pWFSHorizontalLeftOffset: 1, #pWFSHorizontalRightOffset: 1, #pWFSCloseMenuOnMouseEvent: "mouseUp"])
      theScript=wfsAttachBehavior("Cursor Control", theNewSpritenum, [#pWFSTypicalSettings: "Clickable", #pWFSMouseEnterDescription: "Standard System Arrow", #pWFSMouseDownDescription: "Standard System Arrow", #pWFSMouseUpDescription: "Standard System Arrow"])
      --RETURN THE SPRITENUM OF THE MANAGER:**********************************
      return theManagerSpritenum
    else
      --Else there aren't enough available channels to create the multi-sprite
      return 0
    end if
end


Click to go to top of section. wfsAssembleTree (theManagerSpritenum)

This returns a list of the spritenums of managers that are descendants of theManagerSpritenum, and the list also includes theManagerSpritenum at the start. This handler is recursive. It is called by wfsWriteMultiSpriteFamily.

Click to go to top of section. wfsGetNumberOfSpritesInFamily (theManagerSpritenum)

This returns the number of sprites in the family (tree) of multi-sprites rooted at theManagerSpriteNum. This handler is called by wfsWriteMultiSpriteFamily.

Click to go to top of section. wfsConcatenateLists (a, b)

This returns the concatenation of two linear lists a and b.

Click to go to top of section. wfsSearchAndReplace (input, stringToFind, stringToInsert)

This searches input for occurrences of stringToFind and replaces them with stringToInsert. It returns the search and replace string. For instance, wfsSearchAndReplace("abcd", "bc", "x") would return "axd".

Click to go to the home pageMiscellaneous Handlers