I am popultating a dynamic text box with values from a database. I need/want the location of the text box to be at a random position on the stage, so I have been using:
[AS]
//Put text in text box
Services_mc.Services_text_mc.Services_txt.text = Services_array[count];
//Move the text feild to a random position on the stage, but make
//sure that the entire text will fit
Services_mc._x = Math.random() * (Scene_Width - Services_mc.Services_text_mc.Services_txt.textWidth);
Services_mc._y = Math.random() * (Scene_Height - Services_mc.Services_text_mc.Services_txt.textHeight);
[/AS]
I would like to make the text a link to a section on my site, so I was trying to follow the thread “Dynamic text with HTML code” So I changed my code to :
[AS]
//Build html to go in text field from the two arrays that are built from the database
//where count is the index of the values that we are on
Services_str = “<a href=’”+Services_Links_array[count]+"’>"+Services_array[count]+"</a>";
Services_mc.Services_text_mc.Services_txt.html = true;
Services_mc.Services_text_mc.Services_txt.htmlText = Services_str;
//Move the text feild to a random position on the stage, but make
//sure that the entire text will fit
Services_mc._x = Math.random() * (Scene_Width - Services_mc.Services_text_mc.Services_txt.textWidth);
Services_mc._y = Math.random() * (Scene_Height - Services_mc.Services_text_mc.Services_txt.textHeight);
[/AS]
In doing a “List Variables” in Debug I see the following (I did a PHP code block so that it would not render my html in the text box):
Level #0:
Variable _level0.$version = "WIN 6,0,21,0"
Variable _level0.Services = "Service 1,Service 2,Service 3,Service 4,Service 5"
Variable _level0.services_links = "1,2,3,4,5"
Variable _level0.status = "1"
Variable _level0.Services_array = [object #1, class 'Array'] [
0:"Service 1",
1:"Service 2",
2:"Service 3",
3:"Service 4",
4:"Service 5"
]
Variable _level0.Services_Links_array = [object #2, class 'Array'] [
0:"1",
1:"2",
2:"3",
3:"4",
4:"5"
]
Variable _level0.Scene_Width = 483
Variable _level0.Scene_Height = 115
Variable _level0.count = 0
Variable _level0.Services_str = "<a href='1'>Service 1</a>"
Variable _level0.junk1 = 0
Variable _level0.junk2 = 2
Movie Clip: Target="_level0.Services_mc"
Movie Clip: Target="_level0.Services_mc.Services_text_mc"
Edit Text: Target="_level0.Services_mc.Services_text_mc.Services_txt"
variable = "Services_text",
text = "Service 1",
htmlText = "<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"25\" COLOR=\"#B81215\"><A HREF=\"1\" TARGET=\"\">Service 1</A></FONT></P></TEXTFORMAT>",
html = true, textWidth = 0, textHeight = 2, maxChars = null,
borderColor = 0x000000, backgroundColor = 0xFFFFFF, textColor = 0xB81215, border = false,
background = false, wordWrap = false, password = false, multiline = false,
selectable = false, scroll = 1, hscroll = 0, maxscroll = 1,
maxhscroll = 0, bottomScroll = 1,
type = "dynamic",
embedFonts = true, restrict = null, length = 9, tabIndex = undefined,
autoSize = "none",
condenseWhite = false
I see that the htmlText is getting set, and with what looks like good html, and I see that text gets set with the non html part from the htmlText. This brings my questions: Am I just going the htmlText part wrong? Is it not possiable to calculate the width of the text when html is set to “true”?
Thanks for reading my post and any pointers you may give.
Jimmy Puckett