TextBubbleController class -- manages text bubbles
1.0
© TheoWorlds.com, 2007--2009.
| com. | TextBubbleController class -- manages text bubbles |
| Variables | |
| _targetMC | the movieclip for drawing the bubles in |
| orders | |
| _aTextBubbles | the array contains objects {intervalID:Number, textBubble:TextBubble} intervalID -- the time in wich the bubble will disappear textBubble -- the bubble itself |
| _textBubbleCounter | for names generation |
| _charactersColors | |
| _maxTextLength | 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 | 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 | 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 | |
| setBorders | sets the border within which the bubbles should be located |
| characterSay | adds a text bubble or extends the existing one when a character says something |
| getBubbleLifeTime | |
| updateBubblePosition | updates the position of the bubble (to match with the character position) |
| clearTextBubble | removes a text bubble |
| clearAllTextBubbles | removes all text bubbles (TextBubble) |
| kill | clears the assets |
| getTextBubbleByID | get a text bubble by its ID |
| getTextBubbleByCharacterID | find the character’s text bubble |
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
| 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 |
public function updateBubblePosition( characterID: Number, posX: Number, posY: Number ):Void
updates the position of the bubble (to match with the character position)
| 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 |
public function clearAllTextBubbles():Void
removes all text bubbles (TextBubble)
private function getTextBubbleByID( textBubbleID: Number, removeFromArray: Boolean ): TextBubble
get a text bubble by its ID
| textBubbleID | (TextBubble) |
| removeFromArray | (true || false) |
private function getTextBubbleByCharacterID( characterID: Number, removeFromArray: Boolean ):TextBubble
find the character’s text bubble
| characterID | (Character) |
| removeFromArray |
the movieclip for drawing the bubles in
private var _targetMC: MovieClip
private var _globalBorders: Rectangle
the array contains objects {intervalID:Number, textBubble:TextBubble} intervalID -- the time in wich the bubble will disappear textBubble -- the bubble itself
private var _aTextBubbles: Array
for names generation
private var _textBubbleCounter: Number
private var _charactersColors: Array
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 _maxTextLength: 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 _maxBubbleLifeTime: 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)
private var _minBubbleLifeTime: Number
function TextBubbleController( target: MovieClip )
sets the border within which the bubbles should be located
public function setBorders( x: Number, y: Number, width: Number, height: Number ):Void
adds a text bubble or extends the existing one when a character says something
public function characterSay( characterID: Number, posX: Number, posY: Number, txt: String, initObj: Object ):Void
private function getBubbleLifeTime( strLength: Number ):Number
updates the position of the bubble (to match with the character position)
public function updateBubblePosition( characterID: Number, posX: Number, posY: Number ):Void
removes a text bubble
public function clearTextBubble( textBubble: TextBubble ):Void
removes all text bubbles (TextBubble)
public function clearAllTextBubbles():Void
clears the assets
public function kill():Void
get a text bubble by its ID
private function getTextBubbleByID( textBubbleID: Number, removeFromArray: Boolean ): TextBubble
find the character’s text bubble
private function getTextBubbleByCharacterID( characterID: Number, removeFromArray: Boolean ):TextBubble