Whittler
03-12-2011, 04:17 AM
hi,
I'm sure I'm missing some logic here or something... I THINK I've read an XML file with various fields. I want to display one XML field in one TLFTextField and another XML field in another TLFTextField when a button is clicked. One text field has the product name the other has the product description.
This is the code but I can't seem to display anything, much less even trace any of the text string variables I THINK I've assigned. Any help would be greatly appreciated.
ActionScript Code:
import flash.events.MouseEvent;
import fl.text.TLFTextField;
import flashx.textLayout.accessibility.TextAccImpl;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
mc_slidingDoors.gotoAndStop("open");
var myXML:XML;
var itemNumber:uint = 0;
var myLoader:Loader = new Loader();
var totalItems:int = 0;
var prodName:String;
var prodDescription:String;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("m_products.xml")); xmlLoader.addEventListener(Event.COMPLETE, setupXMLData);
function setupXMLData(e:Event):void
{
myXML = new XML(xmlLoader.data);
totalItems = myXML.children().length() - 1;
}
function displayProduct():void
{
prodName = myXML.prodpage.prodname;
prodDescription = myXML.prodpage[itemNumber].proddescription;
}
var myTextField:TLFTextField = new TLFTextField();
myTextField.width = 202;
myTextField.height = 170; myTextField.x = 48;
myTextField.y = 360;
myTextField.selectable = false;
myTextField.border = false;
myTextField.wordWrap = true;
myTextField.autoSize = TextFieldAutoSize.NONE;
addChild(myTextField);
var myFormat:TextFormat = new TextFormat();
myFormat.color = 0x000000;
myFormat.bold = false;
myFormat.leading = 1.5;
myFormat.font = "Arial";
myFormat.size = 15;
myFormat.italic = false;
myTextField.defaultTextFormat = myFormat;
myTextField.text = prodName;
myTextField.setTextFormat(myFormat); [I]
//This trace doesn't even work...
trace(prodName);
function click1(event:MouseEvent):void
{
mc_slidingDoors.txt_gotoPage.text = "1";
myTextField.text = prodName;
if (mc_slidingDoors.currentFrame == 1)
{
mc_slidingDoors.gotoAndPlay("open");
}
else
{
mc_slidingDoors.gotoAndPlay("close");
}
}
button1.addEventListener(MouseEvent.CLICK, click1);
I'm also getting a prompt when I compile that says:
"Your content will not stream. Runtime Shared Library (RSL) preloading will require all of your content to download before the first frame will play.
To prevent this you can change the Runtime Shared Library Library Settings in the Advanced ActionScript 3.0 Settings dialog which can be raised from the Publish Settings dialog.
The Runtime Shared Libraries being preloaded are:
textLayout_1.0.0.595.swz for TLF Text"
I don't know if this is good or bad.. ANY help would be greatly appreciated.
Thanks
I'm sure I'm missing some logic here or something... I THINK I've read an XML file with various fields. I want to display one XML field in one TLFTextField and another XML field in another TLFTextField when a button is clicked. One text field has the product name the other has the product description.
This is the code but I can't seem to display anything, much less even trace any of the text string variables I THINK I've assigned. Any help would be greatly appreciated.
ActionScript Code:
import flash.events.MouseEvent;
import fl.text.TLFTextField;
import flashx.textLayout.accessibility.TextAccImpl;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
mc_slidingDoors.gotoAndStop("open");
var myXML:XML;
var itemNumber:uint = 0;
var myLoader:Loader = new Loader();
var totalItems:int = 0;
var prodName:String;
var prodDescription:String;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("m_products.xml")); xmlLoader.addEventListener(Event.COMPLETE, setupXMLData);
function setupXMLData(e:Event):void
{
myXML = new XML(xmlLoader.data);
totalItems = myXML.children().length() - 1;
}
function displayProduct():void
{
prodName = myXML.prodpage.prodname;
prodDescription = myXML.prodpage[itemNumber].proddescription;
}
var myTextField:TLFTextField = new TLFTextField();
myTextField.width = 202;
myTextField.height = 170; myTextField.x = 48;
myTextField.y = 360;
myTextField.selectable = false;
myTextField.border = false;
myTextField.wordWrap = true;
myTextField.autoSize = TextFieldAutoSize.NONE;
addChild(myTextField);
var myFormat:TextFormat = new TextFormat();
myFormat.color = 0x000000;
myFormat.bold = false;
myFormat.leading = 1.5;
myFormat.font = "Arial";
myFormat.size = 15;
myFormat.italic = false;
myTextField.defaultTextFormat = myFormat;
myTextField.text = prodName;
myTextField.setTextFormat(myFormat); [I]
//This trace doesn't even work...
trace(prodName);
function click1(event:MouseEvent):void
{
mc_slidingDoors.txt_gotoPage.text = "1";
myTextField.text = prodName;
if (mc_slidingDoors.currentFrame == 1)
{
mc_slidingDoors.gotoAndPlay("open");
}
else
{
mc_slidingDoors.gotoAndPlay("close");
}
}
button1.addEventListener(MouseEvent.CLICK, click1);
I'm also getting a prompt when I compile that says:
"Your content will not stream. Runtime Shared Library (RSL) preloading will require all of your content to download before the first frame will play.
To prevent this you can change the Runtime Shared Library Library Settings in the Advanced ActionScript 3.0 Settings dialog which can be raised from the Publish Settings dialog.
The Runtime Shared Libraries being preloaded are:
textLayout_1.0.0.595.swz for TLF Text"
I don't know if this is good or bad.. ANY help would be greatly appreciated.
Thanks