Accessibility
 
Home > Products > Director > Support > Basics of Director 3D
Macromedia Director Support Center - Basics of Director 3D
Examining the backdrop Lingo

Open the Script window for the movie and view the BackdropBehavior script. This Lingo declares and holds properties for the Parameters for "BackdropBehavior" dialog box.

Farther down the Script window, there is Lingo that accomplishes a variety of tasks, including resetting the 3D world, creating the texture, inserting the backdrop image into the 3D world, centering the backdrop, and determining where the backdrop should appear in the list of camera properties. You can review both the heavily commented Lingo in the Script window and the comments and code in this article.

This script checks for the member type to ensure you've selected a valid cast member:

on begin sprite me
    I=sprite(me.spritenum)
    case member(pMybackdrop).type of:
        #bitmap, #vectorShape, #flash, #text
        nothing

If the cast member is not valid, then you see an alert:

        Alert "The member you have chosen cannot be used for this behavior. Please choose either a bitmap, vector shape, Flash, or text member."
        abort

    end case
The following script ensures that the world resets each time the movie plays:

if presetworld then
    i.member.resetWorld()
end if

This script calls a subhandler that creates the texture:

t=createTexture(me) 

This script calls a subhandler that applies the texture as a backdrop:

    doBackdrop(me, t)
end

This script checks to see if the texture is already in the 3D world and, if so, deletes the "old" texture before creating the new one:

    I = sprite(me.spritenum)
    txtr = i.member.texture(pMyTextureName)
    if not voidp(txtr) then
    i.member.deleteTexture(pMyTextureName)
end if

This script creates the new texture and stores a reference to it in txtr , then returns the value of the new texture:

    txtr = i.member.newTexture(pMyTextureName, #fromImageObject, member(pMybackdrop).image)
    return txtr
end
The following handler creates the actual backdrop:

on DoBackdrop me, Txtr2BeUsed
    I=sprite(me.spritenum)

This script displays an alert message if an error occurs in handling the texture:

if voidp(Txtr2BeUsed) then
    Alert "The specified texture is VOID."
    abort
end if

This script centers the backdrop, if centering is specified:

if pMyLoc = point(-1,-1) then
    pmyLoc = point((i.width/2-member(pMybackdrop).width/
    2),(i.height/2-member(pMybackdrop).height/2))
end if

This script retrieves the number of the last index entry in the backdrop list for the camera:

pLastOne = i.camera.backdrop.count + 1

This script inserts the texture into the list of backdrops at the pLastOne position:

if pAddToListFlag then
    i.camera.insertbackdrop(pLastOne,Txtr2BeUsed, pMyLoc, pMyRot)
else

This script inserts the texture into the list of backdrops if it is not to appear at the end of the lists:

        i.camera.addbackdrop(Txtr2BeUsed, pMyLoc, pMyRot)
    end if
end

The following handler rotates the backdrop:

on prepareframe me
    I=sprite(me.spritenum)

If the value of pAnimRot is TRUE , then this script retrieves the current rotation value:

if pAnimRot then
    r=i.camera.Backdrop[pLastOne].rotation
end if

if pAnimTxT then
    createTexture(me)
end if

If the texture is animated, then this script creates a new texture on every prepareFrame event:

if pAnimRot then
    t=createTexture(me)

This script applies the texture to the 3D world:

    Dobackdrop(me, t)
end if

If the value of the pAnimRot variable is TRUE , this script specifies the rotation:

    if pAnimRot then
        i.camera.backdrop[pLastOne].rotation=r+pAnimate
    end if
end

To Table of Contents Back to Previous document Forward to next document