tock_v
08-11-2008, 08:38 AM
I'm trying to add an instance of a movieclip, and then add a TextField into it and display some text in that TextField. Everything works fine (movieclip is added, and the TextField is there because the text cursor appears when i mouse over the area where the TextField should be) except the text just doesn't want to appear at all.
Here's my code:
import flash.filters.DropShadowFilter;
import flash.text.TextField;
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("data.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
//load XML data
function processXML(e:Event):void {
myXML = new XML(e.target.data);
var textFormatter:TextFormat = new TextFormat("Times",12)
for (var i:int = 0; i<myXML.*.length(); i++) {
var myInstance = new itemContainer();
addChild(myInstance);
//add caption
var textCaption:TextField = new TextField();
myInstance.addChild(textCaption);
textCaption.defaultTextFormat = textFormatter;
textCaption.x = 7;
textCaption.y = 170.5;
textCaption.height = 49.5;
textCaption.width = 200.4;
textCaption.textColor = 0x000000;
textCaption.multiline = true;
textCaption.wordWrap = true;
textCaption.embedFonts = true;
textCaption.visible = true;
textCaption.text = 'blah blah blah';
//add drop shadow
var myFilter:DropShadowFilter = new DropShadowFilter();
myFilter.distance = 2;
myFilter.angle = 45;
myFilter.color = 0x666666;
var filtersArray:Array = new Array(myFilter);
myInstance.filters = filtersArray;
//position and rotate
var xpos = randomNumber(50, 584);
var ypos = randomNumber(50, 373);
var rotate = randomNumber(-25, 25);
myInstance.x = xpos;
myInstance.y = ypos;
myInstance.rotation = rotate;
}
}
Any help would be greatly appreciated
Here's my code:
import flash.filters.DropShadowFilter;
import flash.text.TextField;
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("data.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
//load XML data
function processXML(e:Event):void {
myXML = new XML(e.target.data);
var textFormatter:TextFormat = new TextFormat("Times",12)
for (var i:int = 0; i<myXML.*.length(); i++) {
var myInstance = new itemContainer();
addChild(myInstance);
//add caption
var textCaption:TextField = new TextField();
myInstance.addChild(textCaption);
textCaption.defaultTextFormat = textFormatter;
textCaption.x = 7;
textCaption.y = 170.5;
textCaption.height = 49.5;
textCaption.width = 200.4;
textCaption.textColor = 0x000000;
textCaption.multiline = true;
textCaption.wordWrap = true;
textCaption.embedFonts = true;
textCaption.visible = true;
textCaption.text = 'blah blah blah';
//add drop shadow
var myFilter:DropShadowFilter = new DropShadowFilter();
myFilter.distance = 2;
myFilter.angle = 45;
myFilter.color = 0x666666;
var filtersArray:Array = new Array(myFilter);
myInstance.filters = filtersArray;
//position and rotate
var xpos = randomNumber(50, 584);
var ypos = randomNumber(50, 373);
var rotate = randomNumber(-25, 25);
myInstance.x = xpos;
myInstance.y = ypos;
myInstance.rotation = rotate;
}
}
Any help would be greatly appreciated