开发者

AS2 - Switching text in Dynamic Text box

I'm making a very simple adventure game with a dialogue box.

The dialogue box is a dynamic text box. I need it to display the next message everytime the "next" button is pushed.

Right now, this is how it looks.

stop();

onEnterFrame = gameProgression();

function gameProgression()
{
if (MessageProgress = 1)
{
    MessageText.text = "Blah blah blah.";
}
else
{
    if (MessageProgress = 2)
    {
        MessageText.text = "More blah.";
    }
    else
    {
        if (MessageProgress = 3)
        {
            MessageText.text = "And again.";
        }
        else
        {

And so on and so forth. 开发者_开发知识库Every time the "next" button is pressed, +1 is added to the MessageProgress variable.

However, when I try this, it'll display the first message perfectly fine but not display any other message no matter how many times the button is clicked.


The statement if(MessageProgress = 1) means you assign Messageprogress as 1.

Use if(MessageProgress == 1) to evaluate expression & similarly for other if conditions.

Anyways, The above method is not at all the way to go. Why not put the messages in an array and simply refer to them like Array[0],Array[1]...


EDIT :

Something like,

stop();

onEnterFrame = gameProgression();

myArray = new Array("Blah blah blah.","More Blah.","And Again");

function gameProgression()
{
     // Remember to start MessageProgress from 0 and not 1

     myArray[MessageProgress];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜