User Guide

418 Chapter 12: Methods
After the line has been executed, newMember will contain the member reference to the cast
member just created:
put newMember
-- (member 1 of castLib 1)
If you are using JavaScript syntax to create a new cast members, use the movie object's
newMember() method. This statement creates a new bitmap cast member:
var tMem = _movie.newMember(symbol("bitmap"))
The following startMovie script creates a new Flash cast member using the new command, sets the
newly created cast members
linked property so that the cast members assets are stored in an
external file, and then sets the cast member’s
pathName property to the location of a Flash movie
on the World Wide Web:
on startMovie
flashCastMember = new(#flash)
member(flashCastMember).pathName = "http://www.someURL.com/myFlash.swf"
end
When the movie starts, this handler creates a new animated color cursor cast member and stores
its cast member number in a variable called
customCursor. This variable is used to set the
castMemberList property of the newly created cursor and to switch to the new cursor.
on startmovie
customCursor = new(#cursor)
member(customCursor).castMemberList = [member 1, member 2, member 3]
cursor (member(customCursor))
end
These statements from a parent script include the on new handler to create a child object. The
parent script is a script cast member named Bird, which contains these handlers.
on new me, nameForBird
return me
end
on fly me
put "I am flying"
end
The first statement in the following example creates a child object from the above script in the
preceding example, and places it in a variable named
myBird. The second statement makes the
bird fly by calling the fly handler in the Bird parent script:
myBird = script("Bird").new()
myBird.fly()
This statement uses a new Bird parent script, which contains the property variable speed:
property speed
on new me, initSpeed
speed = initSpeed
return me
end
on fly me
put "I am flying at " & speed & "mph"
end