I seem to always have problems with text when it comes to tweening or whatever. But now I am having problems in the code below doing very simple things like controlling the “y” position of a textfield. It;s highlighted in red. What is going on? Thanks in advance.
import flash.filters.GlowFilter;
import flash.filters.BlurFilter;
var numbChildren:uint = this.numChildren + 1;
var colorSet:uint;
var txtInfocon5:String;
var txtInfocon4:String;
var txtInfocon3:String;
var txtInfocon2:String;
var txtInfocon1:String;
var loaded:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleXML);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.load(new URLRequest("infocon.xml"));
var formatNormal:TextFormat = new TextFormat();
formatNormal.color = 0x000000;
formatNormal.size = 22;
var formatSmall:TextFormat = new TextFormat();
formatSmall.size = 24;
var myTextLabels:Array = [];
var myText:Array = [];
var myTextFields:Array = [];
var mcBacking:MovieClip = new MovieClip();
mcBacking.graphics.beginFill(0xFFFFFF);
mcBacking.graphics.drawRoundRect(0, 0, 510, 300, 15, 15);
mcBacking.graphics.endFill();
mcBacking.x = 155;
mcBacking.y = 600;
mcBacking.filters = [new GlowFilter(0x333333, .6, 15, 15, 3, 2, false, false)]
stage.addChild(mcBacking);
var txtMainDisp:TextField = new TextField();
txtMainDisp.wordWrap = true;
txtMainDisp.x = 180;
[COLOR=red]txtMainDisp.y = 600; //I can change this all day, nothing happens.
[/COLOR]txtMainDisp.width = mcBacking.width - 50;
txtMainDisp.height = 200;
function handleXML(evt:Event)
{
loaded = XML(evt.target.data);
txtInfocon1 = loaded.infocon1;
myText.push(txtInfocon1);
txtInfocon2 = loaded.infocon2;
myText.push(txtInfocon2);
txtInfocon3 = loaded.infocon3;
myText.push(txtInfocon3);
txtInfocon4 = loaded.infocon4;
myText.push(txtInfocon4);
txtInfocon5 = loaded.infocon5;
myText.push(txtInfocon5);
for (var i:uint = 1; i < numbChildren; i++)
{
this["mcInfocon" + i].buttonMode = true;
this["mcInfocon" + i].useHandCursor = true;
this["mcInfocon" + i].mouseChildren = false;
this["mcInfocon" + i].x = 20;
this["mcInfocon" + i].addEventListener(MouseEvent.ROLL_OVER, handleHover);
this["mcInfocon" + i].addEventListener(MouseEvent.ROLL_OUT, handleHoverOut);
var txtLabel:TextField = new TextField;
txtLabel.text = "INFOCON"+i;
txtLabel.x = this["mcInfocon" + i].x + 14;
txtLabel.y = this["mcInfocon" + i].y + 10;
txtLabel.mouseEnabled = false;
stage.addChild(txtLabel);
myTextLabels.push(txtLabel);
var tf:TextField = new TextField();
tf.width = 560;
tf.x = this["mcInfocon" + i].x + 110;
tf.y = this["mcInfocon" + i].y - 10;
tf.text = myText[i-1];
tf.alpha = 0;
tf.wordWrap = true;
stage.addChild(tf);
myTextFields.push(tf);
}
}
function handleHover(evt:MouseEvent):void
{
switch(evt.currentTarget.name.charAt(9))
{
case "5":
colorSet = 0x00FF00;
break;
case "4":
colorSet = 0x0000FF;
break;
case "3":
colorSet = 0xFFFF00;
break;
case "2":
colorSet = 0xFFA000;
break;
case "1":
colorSet = 0xFF0000;
break;
}
evt.currentTarget.filters = [new GlowFilter(colorSet, .6, 15, 15, 3, 2, false, false)];
myTextFields[(evt.currentTarget.name.charAt(9)-1)].alpha = 1;
stage.addChild(myTextFields[(evt.currentTarget.name.charAt(9)-1)]);
mcBacking.parent.setChildIndex(mcBacking, mcBacking.parent.numChildren-1);
txtMainDisp.text = myTextFields[(evt.currentTarget.name.charAt(9)-1)].text;
txtMainDisp.y = 100;
txtMainDisp.setTextFormat(formatNormal);
stage.addChild(txtMainDisp);
mcBacking.y = 60;
}
function handleHoverOut(evt:MouseEvent):void
{
evt.currentTarget.filters = [];
myTextFields[(evt.currentTarget.name.charAt(9)-1)].alpha = .6;
txtMainDisp.y = 600;
mcBacking.y = 600;
}
function onIOError(evt:IOErrorEvent):void
{
trace("There is an error loading the file. Please contact suppport personell for this course. "+evt.text);
}