com.theoworlds.builder.TextBubbleController

TextBubbleController class -- manages text bubbles

Version

1.0

Author

© TheoWorlds.com, 2007--2009.

Summary
com.theoworlds.builder.TextBubbleControllerTextBubbleController class -- manages text bubbles
Variables
_targetMCthe movieclip for drawing the bubles in
orders
_aTextBubblesthe array contains objects {intervalID:Number, textBubble:TextBubble} intervalID -- the time in wich the bubble will disappear textBubble -- the bubble itself
_textBubbleCounterfor names generation
_charactersColors
_maxTextLengththe maximum number of characters in a message if the previous text bubble didn’t disappear yet, and the sum of the new message and the old message characters is less then _maxTextLength, then the new message is added to the existing bubble (appended)
_maxBubbleLifeTimethe maximum bubble life (in ms) (the lifetime of a text bubble is directly proportional to its length in characters, but can not be longer than this maximum value)
_minBubbleLifeTimethe minimum bubble life (the lifetime of a text bubble is directly proportional to its length in characters, but can not be shorter than this minimum value)
Functions
TextBubbleController
setBorderssets the border within which the bubbles should be located
characterSayadds a text bubble or extends the existing one when a character says something
getBubbleLifeTime
updateBubblePositionupdates the position of the bubble (to match with the character position)
clearTextBubbleremoves a text bubble
clearAllTextBubblesremoves all text bubbles (TextBubble)
killclears the assets
getTextBubbleByIDget a text bubble by its ID
getTextBubbleByCharacterIDfind the character’s text bubble

Variables

_targetMC

private var _targetMC: MovieClip

the movieclip for drawing the bubles in

orders

private var _globalBorders: Rectangle

_aTextBubbles

private var _aTextBubbles: Array

the array contains objects {intervalID:Number, textBubble:TextBubble} intervalID -- the time in wich the bubble will disappear textBubble -- the bubble itself

_textBubbleCounter

private var _textBubbleCounter: Number

for names generation

_charactersColors

private var _charactersColors: Array

_maxTextLength

private var _maxTextLength: Number

the maximum number of characters in a message if the previous text bubble didn’t disappear yet, and the sum of the new message and the old message characters is less then _maxTextLength, then the new message is added to the existing bubble (appended)

_maxBubbleLifeTime

private var _maxBubbleLifeTime: Number

the maximum bubble life (in ms) (the lifetime of a text bubble is directly proportional to its length in characters, but can not be longer than this maximum value)

_minBubbleLifeTime

private var _minBubbleLifeTime: Number

the minimum bubble life (the lifetime of a text bubble is directly proportional to its length in characters, but can not be shorter than this minimum value)

Functions

TextBubbleController

function TextBubbleController(target: MovieClip)

Parameters

target-- movieclip for drawing the bubble in

setBorders

public function setBorders(x: Number,
y: Number,
width: Number,
height: Number):Void

sets the border within which the bubbles should be located

Parameters

x-- x coordinate
y-- y coordinate
width-- with of area for bubbles
height-- height of area for bubbles

characterSay

public function characterSay(characterID: Number,
posX: Number,
posY: Number,
txt: String,
initObj: Object):Void

adds a text bubble or extends the existing one when a character says something

Parameters

characterID-- id of Character
posX-- x coordinate of a bubble relative to the local coordinates of the target movie clip
posY-- y coordinate of a bubble relative to the local coordinates of the target movie clip
txt-- message
initObj// TODO -- make it simpler -- may be the same as it’s done in MapObjectSettings

getBubbleLifeTime

private function getBubbleLifeTime(strLength: Number):Number

Parameters

strLength-- an integer specifying the number of characters in the message

Returns

the life time of a bubble depending on its length

updateBubblePosition

public function updateBubblePosition(characterID: Number,
posX: Number,
posY: Number):Void

updates the position of the bubble (to match with the character position)

Parameters

characterID-- id of Character
posX-- x coordinate of a bubble relative to the local coordinates of the target movie clip
posY-- y coordinate of a bubble relative to the local coordinates of the target movie clip

clearTextBubble

public function clearTextBubble(textBubble: TextBubble):Void

removes a text bubble

Parameters

paramtextBubble

clearAllTextBubbles

public function clearAllTextBubbles():Void

removes all text bubbles (TextBubble)

kill

public function kill():Void

clears the assets

getTextBubbleByID

private function getTextBubbleByID(textBubbleID: Number,
removeFromArray: Boolean): TextBubble

get a text bubble by its ID

Parameters

textBubbleID(TextBubble)
removeFromArray(true || false)

Returns

(TextBubble)

getTextBubbleByCharacterID

private function getTextBubbleByCharacterID(characterID: Number,
removeFromArray: Boolean):TextBubble

find the character’s text bubble

Parameters

characterID(Character)
removeFromArray

Returns

(TextBubble)

private var _targetMC: MovieClip
the movieclip for drawing the bubles in
private var _globalBorders: Rectangle
private var _aTextBubbles: Array
the array contains objects {intervalID:Number, textBubble:TextBubble} intervalID -- the time in wich the bubble will disappear textBubble -- the bubble itself
private var _textBubbleCounter: Number
for names generation
private var _charactersColors: Array
private var _maxTextLength: Number
the maximum number of characters in a message if the previous text bubble didn’t disappear yet, and the sum of the new message and the old message characters is less then _maxTextLength, then the new message is added to the existing bubble (appended)
private var _maxBubbleLifeTime: Number
the maximum bubble life (in ms) (the lifetime of a text bubble is directly proportional to its length in characters, but can not be longer than this maximum value)
private var _minBubbleLifeTime: Number
the minimum bubble life (the lifetime of a text bubble is directly proportional to its length in characters, but can not be shorter than this minimum value)
function TextBubbleController(target: MovieClip)
public function setBorders(x: Number,
y: Number,
width: Number,
height: Number):Void
sets the border within which the bubbles should be located
public function characterSay(characterID: Number,
posX: Number,
posY: Number,
txt: String,
initObj: Object):Void
adds a text bubble or extends the existing one when a character says something
private function getBubbleLifeTime(strLength: Number):Number
public function updateBubblePosition(characterID: Number,
posX: Number,
posY: Number):Void
updates the position of the bubble (to match with the character position)
public function clearTextBubble(textBubble: TextBubble):Void
removes a text bubble
public function clearAllTextBubbles():Void
removes all text bubbles (TextBubble)
TextBubble class - chat “bubbles” that appear above characters when they “talk”
public function kill():Void
clears the assets
private function getTextBubbleByID(textBubbleID: Number,
removeFromArray: Boolean): TextBubble
get a text bubble by its ID
private function getTextBubbleByCharacterID(characterID: Number,
removeFromArray: Boolean):TextBubble
find the character’s text bubble
Character class -- character/avatar main class
Close