vendredi 20 novembre 2015

Null reference, AS3

I'm creating a text based adventure game for my first flash game, at the moment I have got:

type writing effect

displaying parts in order

key down to continue/finish typing text

and so on.

Right now, I'm trying to make it so choices appear at the correct parts. I've done this but now I need to display clickable textbuttons that run the choice (I'm using flashdevelop). I got some code from this thread (second answer)

trying to create the list of choices:

    for (var i:int = 0; i < optionsArray[currentChoicePart].length; i++) 
    {
        var textButton:Sprite = getTextButton(optionsArray[currentChoicePart][i])
        textButton.x = myTextField.x
        textButton.y = stage.stageHeight / 2 +50 - (i * 25)
        choicesOnScreen[textButton.name] = textButton // erroring line
        addChild(textButton)
    }

when this runs, the line with the comment "erroring line" saying that textButton is a null value. (choicesOnScreen is a dictionary)

Aucun commentaire:

Enregistrer un commentaire