User Guide
286 Chapter 12: Behaviors
description = [:]
description[#movement] = \
[#default: 5, \
#format:#integer, \
#comment: "Set motion to the right:", \
#range: [#min:1, #max:10] \
]
description[#noise] = \
[#default:"", \
#format: #sound, \
#comment:"Sound cast member name" \
]
return description
end
// JavaScript syntax
function enterFrame() {
if (sprite(spriteNum).locH > _movie.stageRight) {
sprite(spriteNum).locH = _movie.stageLeft
} else {
sprite(spriteNum).locH += movement
}
}
function mouseUp() {
sprite(spriteNum).foreColor = Math.floor(Math.random())*255
sound(noise)
}
function getBehaviorDescription() {
return "This changes sprite color and position"
}
function getPropertyDescriptionList {
description = new Array();
description["Movement"] = new Array();
description["Movement"]["default"] = 5;
description["Movement"]["format"] = "integer";
description["Movement"]["comnt"] = "Set motion to the right";
description["Movement"]["range"] = new Array();
description["Movement"]["range"]["min"] = 1;
description["Movement"]["range"]["max"] = 10;
description["noise"] = new Array();
description["noise"]["default"] = "";
description["noise"]["format"] = "sound";
description["noise"]["comment"] = "Sound cast member name";
return description;
}
When this behavior is attached to a sprite, each time the playhead enters a frame, the sprite moves
to the right by the amount the user specifies. When the user clicks a sprite, its color changes and a
specified sound plays.