Draw and Fill Rectangle BEHIND Dynamic Text Field

Hello,

I’m designing an experiment in Flash Prof. CC that displays 188 different words, with changing background colors to the participant. My main problem right now is getting the background color to change depending on which word is being displayed. For instance, when item 1 is displayed, the background should be blue, etc.

Basically, I thought I could get this to work if I wrote a conditional function that would change the color of the background (that is, draw and fill a rectangle of the appropriate color) based on the value of my counter variable, i. For instance, if i = 2 or i = 5, the first "else if"statement below would be executed. **The problem is that the rectangle is drawn OVER my dynamic text field so the words cannot be seen. How can I fix this?
**
Thanks for any suggestions! This has got my puzzled.

Here’s the code:

import flash.display.Shape;
import flash.display.Graphics;


stop();


var i: int = new int;
var list:Array=[""]

list[1]="SNAIL";
list[2]="ENEMY";
list[3]="PASSAGE";
list[4]="ORGANISM";
list[5]="ENEMY";

startTrial();
function startTrial():void
{
  i = 1;
    txtColorWord.text = list*
    i++;
    setTimeout(nextTrial, 5000);
}


function nextTrial():void
{
    if(i == (list.length-1))
        { 
            setTimeout(endList, 5000);
        }


    else if(i==2 || i==5)
        //green
        {
            var box:Shape = new Shape();
            addChild(box)
            var g:Graphics = box.graphics;
            g.clear();
            g.beginFill(0x00FF00);
            g.drawRect(0,0, stage.stageWidth, stage.stageHeight);
            g.endFill();
            txtColorWord.text = list*            
            i++;        
            setTimeout(nextTrial, 5000)
        }
        
    else if(i==3)
        //red
        {
            var box:Shape = new Shape();
            addChild(box)
            var g:Graphics = box.graphics;
            g.clear();
            g.beginFill(0xFF0000);
            g.drawRect(0,0, stage.stageWidth, stage.stageHeight);
            g.endFill();
            txtColorWord.text = list*            
            i++;        
            setTimeout(nextTrial, 5000)
        }
    else if(i==4)
        {
            var box:Shape = new Shape();
            addChild(box)
            var g:Graphics = box.graphics;
            g.clear()
            g.beginFill(0x00FF00);
            g.drawRect(0,0, stage.stageWidth, stage.stageHeight);
            g.endFill();
            txtColorWord.text = list*
            i++;
            setTimeout(nextTrial, 5000);
            
        }


}


function endList():void
{
    gotoAndStop(5)
}