MenuItemList
The MenuItemList
class extends the BSScrollingList
from the package Shared.AS3
.
It provides additional functionality to manage and animate text within menu items in a scrollable list format.
Class Definition
package {
import Shared.AS3.BSScrollingList;
import flash.display.MovieClip;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
public class MenuItemList extends BSScrollingList {
public function MenuItemList() {
super();
}
// ... Additional methods ...
}
}
Public Methods
MenuItemList()
The constructor of the MenuItemList
class. It calls the constructor of the superclass BSScrollingList
.
Syntax:
public function MenuItemList()
ConvertToGlobal(param1:TextField): Point
Converts the position of the last character in a TextField
to a global position.
Parameters:
param1
: TheTextField
from which to calculate the global position.
Returns:
- A
Point
object representing the global position of the last character in the providedTextField
.
Syntax:
public function ConvertToGlobal(param1:TextField): Point
AnimateText(param1:Boolean, param2:MovieClip, param3:uint): Boolean
Animates text within the menu items. It can either reveal the text by slicing or display the full text instantly.
Parameters:
param1
: ABoolean
indicating whether to display full text instantly (true
) or to animate the text by slicing characters (false
).param2
: TheMovieClip
to which the position of the animated text will be set.param3
: Auint
value indicating the number of characters to slice per animation frame whenparam1
isfalse
.
Returns:
- A
Boolean
indicating whether the animation has finished.
Syntax:
public function AnimateText(param1:Boolean, param2:MovieClip, param3:uint): Boolean
Usage Example
Below is a usage example of how MenuItemList
methods can be utilized:
var menuItemList:MenuItemList = new MenuItemList();
// Assume we have a TextField instance and MovieClip instance
var someTextField:TextField;
var someMovieClip:MovieClip;
// Convert the position of the last character to a global position
var globalPoint:Point = menuItemList.ConvertToGlobal(someTextField);
// Start text animation in the menu items
var animationFinished:Boolean = menuItemList.AnimateText(false, someMovieClip, 1);
if (animationFinished) {
// Animation has finished, proceed with additional logic
}
📌 Important Notes
- The
AnimateText
method relies on the internal state ofEntriesA
, which is likely an array inherited fromBSScrollingList
representing the list entries. - The
AnimateText
method updates the state of each entry inEntriesA
and may modify thex
andy
properties ofparam2
(MovieClip
) to match the global position of the current animated text. iListItemsShown
is likely a property inherited fromBSScrollingList
which defines how many list items are displayed at once.- The
GetClipByIndex
method is used to retrieve a specificMovieClip
associated with a list entry, implying that each entry has a correspondingMovieClip
representing its visual component. disableInput
is set based on the state of the animation and list contents, suggesting an interaction mechanism with the list items.
📖 Best Practices
- Ensure that
EntriesA
is correctly initialized and populated before callingAnimateText
. - Handle the
animationFinished
state appropriately after callingAnimateText
to synchronize any dependent logic with the animation state. - Be mindful of the visual and interactive states of the list items when manipulating
disableInput
.