Dinamic Text field as htmlText
Hi,
I got a dinamic text field using htmltext = <some xml
feed>
but on this feed i got
£
’
and others
any idea how can i get it to render properly?
Thanks
rS
Well, i found a way, not saying is the best as AS only
support
Entity Description
< < (less than)
> > (greater than)
& & (ampersand)
" " (double quotes)
' ' (apostrophe, single quote)
so if you are struggling check this that may help
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
var xml:XML;
var poundSymbol:RegExp = /£/;
function onXMLLoaded(event:Event):void
xml = new XML(event.target.data);
tf.htmlText = xml.data.text().toString();
tf.htmlText = tf.text.replace(poundSymbol, "£");
xmlLoader.load(new URLRequest("test.xml"));
But if you found some other way please post it here
Thanks
rS
Similar Messages
-
I have an application that loads variables from a text file.
It loads them into several dynamic text fields by using the
variable property. I tried populating other text fields with these
values but doesnt seam to work.
i tried this.
username.text = username;
I tried this because i need the value of the variable
"username" to appear in the username text field.
Why didnt this work. How can i correct this?
Thanksit's a component? Why do you need that? Create the username
simply with a dinamic text field and assign the data to it.
I think your missing something. from what i remember and i'm
not so good at this ( i must first see an exemple of something made
by me) you must have a variable which contains the variable in
which the data is loaded.
I have to check out first some work i did to remember. If
problem not solved i will come back in a few hours with the
answer. -
HtmlText in input text field?
Hi
Is it possible to have input text fields respond to htmlText? I'm sure I've done it before.
Although the following code displays the string correctly, there is no color formatting displayed:
e.target.htmlText = noColour + "<font color='0x00FF00'>"+ colorText +"</font>";
I've clicked the button in the field's properties (Flash Pro) to render as htmlText.
Cheers for having a look.Never mind - I had the wrong syntax.
Should be '#00FF00', not '0x00FF00' when it's within quotes. -
Use 2 different fonts in a dynamic text field with tf.htmlText?
i've got a dynamic text field on the screen and all of my
fonts embedded. is it possible to use 2 different fonts when
dynamically setting the fields text with the htmlText property?
i've tried the <font> and the <textformat> tags and
neither work. I can set it once via a texformat object, but that's
it.
thanksyou're answering all of my questions today aren't you? :)
right, i think this will be hard since my data is all comming
from XML and i have no way to specifically set text ranges as
different fonts within a string.
i've told the developers to just use images for the special
characters. -
Problem with characters in text field
hi all
i am missing a few characters, once i load text into a dynamic text field. chars are not missing per say; they are being replaced with empty squares.
characters like the euro sign and accentuated german a letter.
whats is weird is that other accentuated german letters do appear. so only a few selected are missing.
How ive set up the fla:
1) i've added 4 text fields to the stage in the font im using, Arial, one for each font style: normal, italic, bold and bold italic, and in all 4 fields ive embedded all latin characters (to include the german accentuaded characters and im guessing it's in the punctuation group that holds the euro sign, so that one is also embedded), besides lowercase, uppercase, numerical, and all the default groupd to include basic text.
2) i've got a dynamic text field, created with createTextField, and setup the following ActionScript (2):
this.createTextField("T_text",1,0,10,Stage.width-60,50);
var myFmt = new TextFormat();
myFmt.size = 12;
myFmt.leading = 3;
myFmt.font = "Arial";
T_text.html = true;
T_text.autoSize = "left";
T_text.multiline = true;
T_text.wordWrap = true;
T_text.selectable = false;
T_text.embedFonts = false;
T_text.textColor = "0x666666";
T_text.htmlText = _global.gallery_1_image_text_1; // this holds the text im displayed, called in from a database.
T_text.setNewTextFormat(myFmt);
now, im calling text from a database.
when calling the text from the browser url bar, there's no chars missing.
its just when i make this call from flash and load the text into the dynamic text field, that characters go missing.
below is a link to a print screen of the faulty text that is displayed in flash's dynamic text field.
http://img210.imageshack.us/img210/340/utf8.png
any ideas? i mean, it seems that the arial font is missing a few accentuated characters! because the code i have setup loads other accentuated characters.
anyone has seen this issue before and know how to solve it?
regardsno.
you assigned your embedFonts property to be false.
look, you can test if you've embedded fonts correctly by using:
T_text._rotation=3;
if you see no text, you're not embedding fonts correctly.
so, use:
T_text.embedFonts=true;
and then test. if you see no text, use:
click on the upper right of your library panel > new Font > select Arial and tick the symbols you need to embed > tick export for actionscript and assign a linkage id (eg, ArialID). click ok. then use:
this.createTextField("T_text",1,0,10,Stage.width-60,50);
var myFmt = new TextFormat();
myFmt.size = 12;
myFmt.leading = 3;
myFmt.font = "ArialID";
T_text.html = true;
T_text.autoSize = "left";
T_text.multiline = true;
T_text.wordWrap = true;
T_text.selectable = false;
T_text.embedFonts = true;
T_text.textColor = 0x666666; // no quotes here. this is a number
T_text.htmlText = _global.gallery_1_image_text_1; // this holds the text im displayed, called in from a database.
T_text.setTextFormat(myFmt); // to format the above text, use setTextFormat(). if you want to format text added after this line, use setNewTextFormat() -
Content of a single line in a text field
I am loading a hundred string values from a text field (each
with a <br> after them) into a multiple line Dynamic text
field set to display html. When a user clicks on any one of the
lines, I want the content of that line only to be set into a
variable for further processing.
any ideas on how to do this simply assuming that the loaded
in data will be changing quite often?
thanksUse the asfunction protocol to call a function and set the
value into a
variable.
mytxt.htmlText = "<a
href='asfunction:setValue,test'>Hi!</a>";
var valuelink:String = null;
function setValue(value:String):Void
valuelink = value;
trace(valuelink );
Regards,
Erick Souza | ericksouza.com -
Problem with append += text in Text Field
Hi guys
i have a problem with append text.
I have one array which contain some city names, like CityArea=["NAME 1", "NAME2" ...etc];
Then i have one String and one Text Field.
Using for loop im getting right results. But when im running script again then im getting same text again.
F.ex.
First time:
City name: Name 1
City name: Name 2
Second time:
City name: Name 1
City name: Name 2
City name: Name 1
City name: Name 2
I have tried to make TextField to and String to Null and delete it, but it's appearing again.. :/
How to avoid this?
Here is script:
for (var i1:int = 0; i1 < CityArea.length; i1++)
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='32' COLOR='#ffffff'> "+CityArea[i1]+"</FONT></P>";
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='5' COLOR='#ffffff'><BR></FONT></P>";
_CityAreaTF1 = new TextField();
_CityAreaTF1.border = true;
_CityAreaTF1.wordWrap = true;
_CityAreaTF1.multiline = true;
_CityAreaTF1.selectable = false;
_CityAreaTF1.antiAliasType = AntiAliasType.ADVANCED;
_CityAreaTF1.name = "CityAreaTF1";
_CityAreaTF1.embedFonts = true;
_CityAreaTF1.htmlText = _CityAreaString1.toUpperCase();I think i found why.
There was no problem with TextField.
There was a problem with Array. "CityArea"
So each time I executed script it added new string in Array. And that is because i got like:
TextField
City 1
City 2
City 1
City 2
Running this script is Ok:
for (var i1:int = 0; i1 < CityArea.length; i1++)
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='32' COLOR='#ffffff'> "+CityArea[i1]+"</FONT></P>";
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='5' COLOR='#ffffff'><BR></FONT></P>";
But outside of this for loop there is another for loop for adding Cities in CityArray.
I fixed it by adding empty array at the start of function
function myFunc():void
CityArea = [ ]; // Empty array fixed this issue
// LOOP FOR ADDING SHOPS IN CITY AREA
for (var j:int = 0; j < _Shops; j++)
CityArea.push(_Shop);
// FOR LOOP TO ADDING SHOPS IN STRING
for (var i1:int = 0; i1 < CityArea.length; i1++)
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='32' COLOR='#ffffff'> "+CityArea[i1]+"</FONT></P>";
_CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='5' COLOR='#ffffff'><BR></FONT></P>";
Thank you for your help kglad -
Difficulty displaying numeric info in text field
I'm trying to display the playheadTime of an FLV movie
(called vid_player) on the stage in a test field (called
myTextField). I used to be able to do this in older actionscript,
but with AS3, I'm having a heck of a time. Here's my code:
function getCurrentTime(evt:MouseEvent):void {
var currentTime:Number = this.vid_player.playheadTime;
this.myTextField = currentTime;
step3Tab.addEventListener(MouseEvent.CLICK, getCurrentTime);
I get this error:
1067: Implicit coercion of a value of type Number to an
unrelated type flash.text:TextField.I don't think you've quite been able to do this in previous
versions! The error is telling you exactly what is wrong. You are
trying to change a TextField into a Number and that just won't
work.
I haven't done enough with AS3 to be sure off the top of my
head if it changed or not, but I think you want the text or the
htmlText property of the text field.
this.myTextField.text=currentTime;
or if it doesn't like that you may need to cast or convert
the currentTime to a string;
this.myTextField.text=String(currentTime);
this.myTextField.text=currentTime.toString(); -
HTML tags in TLF (slice to 2 text fields)
i create on stage TLF and i slice to 2 text fields
i put text to TLF in actions tText.htmlText = "Some text...."
if text is too much, text from 1 text field is not displayed
in 2 text field. All is displayed only in 1 text field
if i add text from tText.text is displayed in 1 and 2 text field.
how to make to text with html tags displayed in 1 and 2 text field?This looks to me like a bug in TLFTextField. I'll report this bug to the Flash Authoring team.
You could use this as a workaround - find all of the containers that should be attached to the flow, set htmlText then reattach the containers (past the first):
var controllerArray:Array = new Array()
for (var i:int = 0; i < myText.textFlow.flowComposer.numControllers; i++)
controllerArray[i] = myText.textFlow.flowComposer.getControllerAt(i);
myText.htmlText = "some text that should be flowing into the other containers";
for (i = 1; i < controllerArray.length; i++)
myText.textFlow.flowComposer.addController (controllerArray[i]);
myText.textFlow.flowComposer.updateAllControllers(); -
Adding a progress loader to a dynamic text field / scrollPane
I have a dynamic text field which is loading images from an external html. This text is named scrollPaneImage and is a child of a movieClip called scrollPaneContent. I then load scrollPaneContent into a scroll pane named scrollPane
When the user interacts with my swf different images are loaded into scrollPaneImage. Since some of the images take a few seconds to load, I'd like there to be a progress loader displayed in the scrollpane.
I have tried adding the progress event listner to the dynamic text, the movie clip and the scrollpane and cannot get it to respond or track the loading.
scrollPaneContent.addEventListener(ProgressEvent.PROGRESS,reportProgress);
function reportProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + " loaded out of " + e.bytesTotal);
trace("LOADED");
Can anyone suggest what I might be doing wrong or of another approach?
thanks in advance,
JoshHi KGLAD. Thanks for the response. Yes my code is a little messy. Here I have included everything and tried to do a little cleaning. Is there enough code here for you to get an idea of how/when things are firing?
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.distriqt.gmaps.kml.utils.*;
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.TweenLite;
import flash.geom.Point;
import com.greensock.plugins.*;
TweenPlugin.activate([AutoAlphaPlugin]);
import com.google.maps.controls.NavigationControl;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.OverviewMapControl;
import com.google.maps.overlays.GroundOverlay;
import com.google.maps.overlays.GroundOverlayOptions;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.MapMouseEvent;
import com.google.maps.controls.*;
import com.google.maps.overlays.Marker;
import com.google.maps.InfoWindowOptions;
import com.google.maps.overlays.MarkerOptions;
import com.anttikupila.utils.JPGSizeExtractor;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLLoader;
import fl.controls.UIScrollBar;
import flash.events.Event;
import fl.events.ScrollEvent;
import flash.sampler.NewObjectSample;
[Embed(source="ICONS/PHOTO_BLACK.png")]var photoIcon:Class;
[Embed(source="ICONS/BLOG_BLACK.png")]var blogIcon:Class;
scrollPane
// GMAP PARAMETERS
var map:Map = new Map();
map.key = "map key";
//map.key = "api key";
//define the size of the map extent....
map.sensor = "false";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
map.addEventListener(MapEvent.MAP_READY, createmarkers);
map.addEventListener(MapEvent.MAP_READY, createMarkerArrays);
map.addEventListener(MapEvent.MAP_READY, createPhotoPingers);
this.addChild(map);
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
//on map ready params
function onMapReady(event:Event):void
map.setCenter(new LatLng(48,-113.5), 8, MapType.PHYSICAL_MAP_TYPE);
map.enableScrollWheelZoom();
map.disableContinuousZoom();
//Marker options for a photo piece
var photoMarkerOptions:MarkerOptions = new MarkerOptions();
photoMarkerOptions.icon = new photoIcon();
photoMarkerOptions.hasShadow=false;
//Marker options for a blog piece
var blogMarkerOptions:MarkerOptions = new MarkerOptions();
blogMarkerOptions.icon = new photoIcon();
blogMarkerOptions.hasShadow=false;
//load xml tester
var pntloader:URLLoader = new URLLoader();
var pntxml:XML = new XML();
pntloader.addEventListener(Event.COMPLETE, loadpntXML);
pntloader.load(new URLRequest("map_feed.xml"));
// create an array of jpgs to index
var JPGIndexArray:Array = new Array();
//Create array that will be populated with points
var pointsArray:Array = new Array();
//Load the XML
function loadpntXML(e:Event):void {
pntxml=new XML(e.target.data);
pntxml.ignoreWhite = true;
for (var i:int = 0; i< pntxml.row.length(); i++){
pointsArray[i]="mrk"+i;
JPGIndexArray[i]="JPG"+i;
//trace(pntxml);
//Create the markers and add them to the map
function createmarkers(event:Event):void
for (var i:Number = 0; i < pntxml.row.length(); i++) {
var markerOptions:MarkerOptions = new MarkerOptions();
if (pntxml.row[i].TYPE=="PHOTO")
markerOptions.icon = new photoIcon();
markerOptions.tooltip = "Photo";
markerOptions.hasShadow=false;
else if(pntxml.row[i].TYPE=="BLOG")
markerOptions.icon = new blogIcon();
markerOptions.tooltip = "Blog Entry";
markerOptions.hasShadow=false;
else
null
pointsArray[i] = new Marker(new LatLng(pntxml.row[i].LAT,pntxml.row[i].LONG),markerOptions);
markerA.push(pointsArray[i]);
map.addOverlay(pointsArray[i]);
pointsArray[i].addEventListener(MapMouseEvent.CLICK,indexCalledMarkerRecord);
pointsArray[i].addEventListener(MapMouseEvent.CLICK,scrollPanePopulate);
// PING PHOTO DIMENSIONS BEFORE LOADING //
var je : JPGSizeExtractor = new JPGSizeExtractor( );
je.addEventListener( JPGSizeExtractor.PARSE_COMPLETE, jeLoadHandler );
je.addEventListener( JPGSizeExtractor.PARSE_FAILED, jeParseFailed );
function createPhotoPingers(event:Event):void{
for (var k:Number=0; k <pntxml.row.length(); k++){
JPGIndexArray[k]=new JPGSizeExtractor();
JPGIndexArray[k].debug = false;
JPGIndexArray[k].addEventListener(JPGSizeExtractor.PARSE_COMPLETE, jeLoadHandler );
trace("madeit");
pingPhotoUrls();
function pingPhotoUrls():void
for (var i:Number = 0; i < pntxml.row.length(); i++) {
var calledMarkerUrl=pntxml.row[i].URL_OF_CONTENT;
JPGIndexArray[i].extractSize(calledMarkerUrl);
var JPG1=null;
function jeLoadHandler(e:Event) : void {
trace(e.currentTarget.width + "x" + e.currentTarget.height );
imageWidths.push(e.currentTarget.width);
function jeParseFailed( event : Event ) : void {
trace( "Parse failed" );
var imageWidths = new Array;
// FUNCTIONS FOR INDEXING CALLED MARKERS//
//Create blank array for use in indexing
var markerA:Array=[];
//VAR FOR USE IN INDEXING CALLED MARKER
var pointindex=null;
//INDEX CALLED MARKER POINT XML RECORD
function indexCalledMarkerRecord(e:MapMouseEvent):void{
pointindex=genIndexPos(markerA,Marker(e.currentTarget));
//trace(pntxml.row[pointindex].DESC);
//FUNCTION FOR INDEXING CALLED MARKER
function genIndexPos(a:Array,e:Marker):uint{
for(var i:uint=0;i<a.length;i++){
if(a[i]==e){
return i;
return null;
// SCROLLPANE FUNCTIONS //
this.addChild(scrollPane);
scrollPane.setSize(255,300);
scrollPane.x=-200;
scrollPane.y=-200;
scrollPane.alpha=0;
scrollPaneContent.mouseEnabled=false;
spHeader.closeBox.addEventListener(MouseEvent.CLICK, function(eMouseEvent):void
TweenLite.to(scrollPane, .5,{autoAlpha:0,overwrite:true});
spHeader.forDrag.addEventListener(MouseEvent.MOUSE_DOWN, function (e:MouseEvent):void
scrollPane.startDrag();
spHeader.forDrag.addEventListener(MouseEvent.MOUSE_UP, function (e:MouseEvent):void
scrollPane.stopDrag();
spHeader.forDrag.buttonMode=true;
spHeader.forDrag.useHandCursor=true;
spHeader.width=300;
scrollPane.source = scrollPaneContent;
scrollPaneContent.scrollPaneText.autoSize='left';
scrollPaneContent.scrollPaneImage.autoSize='center';
scrollPaneContent.scrollPaneImage.autoSize=TextFieldAutoSize.CENTER;
scrollPaneContent.mouseEnabled=false;
scrollPaneContent.scrollPaneText.condenseWhite = true;
// Add listener.
scrollPane.addEventListener(Event.COMPLETE, completeListener);
scrollPaneContent.addEventListener(ProgressEvent.PROGRESS,reportProgress);
function completeListener(event:Event):void {
trace('Scrollpane content loaded');
function reportProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + " loaded out of " + e.bytesTotal);
trace("LOADED");
function scrollPanePopulate(event:Event){
//show scroll pane
scrollPane.x=33;
scrollPane.y=33;
TweenLite.to(scrollPane, .5,{autoAlpha:1,overwrite:true});
TweenLite.to(spHeader, .5,{autoAlpha:1,overwrite:true});
//create the temp variables
var calledMarkerIndex=pntxml.row[pointindex].ID;
var calledMarkerDate=pntxml.row[pointindex].DATE;
var calledMarkerDescription=pntxml.row[pointindex].DESC;
var calledMarkerContent=pntxml.row[pointindex].URL_OF_CONTENT;
var imgWidth=JPGIndexArray[pointindex].width;
var imgHeight=JPGIndexArray[pointindex].height;
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
var imgBoxHeight=scrollPaneContent.scrollPaneImage.height;
var txtHeight=scrollPaneContent.scrollPaneText.height;
var contentHeight=(imgBoxHeight+txtHeight);
scrollPane.setSize(300,(contentHeight+15));
//size the text box
scrollPaneContent.scrollPaneText.width=270;
//if image is wide or tall, scale accordingly and create a string that will be used
if(imgWidth>=imgHeight){
var imgSource:String = "<img src="+"'"+calledMarkerContent+"'"+"width='"+250+"'"+"height='"+150+"'"+"/>";
var calledImgHgh=160;
else
var imgSource:String = "<img src="+"'"+calledMarkerContent+"'"+"width='"+110+"'"+"height='"+167+"'"+"/>";
var calledImgHgh=177;
//fill in the text
scrollPaneContent.scrollPaneImage.htmlText=imgSource;
//scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
//pan the map to the called position
map.panTo(pointsArray[calledMarkerIndex-1].getLatLng())
//add the header to the SP and scale accordingly
scrollPane.addChild(spHeader);
spHeader.x=-1;
spHeader.y=1;
spHeader.width=299;
if (txtHeight>=250){
scrollPane.setSize(300,275);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription+"<br><br>";
if (txtHeight<=5){
scrollPane.setSize(300,200);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
if (txtHeight>=5){
scrollPane.setSize(300,275);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription+"<br><br>";
// CREATE TEMP VARIABLES FOR POSITIONING AND PLACE DYNAMIC TEXT
var scTextY=scrollPaneContent.scrollPaneText.y;
var scImageY=scrollPaneContent.scrollPaneImage.y;
var scTextHeight=scrollPaneContent.scrollPaneText.height;
scrollPaneContent.scrollPaneText.y=scImageY+calledImgHgh;
//update the scrollpane and reset the scrollbar
scrollPane.update();
scrollPane.verticalScrollPosition=(0);
scrollPane.verticalScrollBar.height=270;
scrollPane.verticalScrollBar.x=281;
scrollPane.verticalScrollBar.y=3;
spHeader.alpha=0;
this.addChild(spHeader);
var photoMarkersArray=new Array();
var photoMarkersIndexArray=new Array();
//CREATE ARRAY OF PHOTO MARKERS
function createMarkerArrays(e:Event):void{
for (var j:int=0; j<pntxml.row.(TYPE=="PHOTO").ID.length(); j++){
var tempMarkerIndex=pntxml.row.(TYPE=="PHOTO").ID[j];
var tempMarkerRef="mrk"+tempMarkerIndex;
photoMarkersArray.push(tempMarkerRef);
photoMarkersIndexArray.push(tempMarkerIndex); -
CreateTextField and _height: Problem with Placement of Text Fields
I'm using createTextField to create several text fields
dynamically. I'm also using an external XML file and a style sheet
to populate the text fields.
My problem is that I'm trying to position the various text
fields on the page so that they are spaced evenly on the page
(regardless of how much content they might contain). I'm trying to
use _height of the prior text fields to place subsequent text
fields, but I'm getting very inconsistent results. When I trace the
value of _height, I get differing results, even if I don't actually
change any of the parameters. So, the question is...is there a way
for Flash to get the height of a dynamically created text field
that's populated via an exteral XML file and using CSS? I know
that's asking a lot, but I'm trying to avoid using scroll bars if
at all possible.
Thanks for any pointers.
Billi assume you're using multiline textifields with a fixed
width and autoSize="left".
flash will report the correct _height of your textfields IF
you access the _height property after your htmlText has been
assigned to your textfield. ie, you're probably seeing inconsistant
results because you're not waiting until all data needed to
populate your textfield has loaded. -
HTML links won't display in Dynamic Text Field
I am loading external text files in dynamic text fields on my
webage. These texts contain html links (<a href="page.html"
target="_blank">Click Here</a> and I have "render as HTML"
on and "selectable" off in my dynamic text field. Also, I am
loading a CSS file. Not only do I not have a hand cursor, but I do
not even have any of the text from that piece of html code down.
What is going on with this? Please respond asap, as I have been
struggling with this for a day now. Here is the Actionscript for
loading the CSS:
var flash_css = new TextField.StyleSheet();
flash_css.load("styles.css");
flash_css.onLoad = function(success:Boolean) {
if (success) {
zloc_txt.styleSheet = flash_css;
} else {
trace("Error loading CSS file.");
var zloc_lv:LoadVars = new LoadVars();
zloc_lv.load("zloc.txt");
zloc_lv.onLoad = function(success:Boolean) {
if (success) {
zloc_txt.text = this.content;
} else {
trace("unable to load text file.");
zloc_txt.html = true;
zloc_txt.editable = false;
_global.styles.TextArea.setStyle("backgroundColor" ,
"transparent");
_global.styles.TextArea.setStyle("border styles" , "solid");
Here is a sample of the text file code:
&content=<span class="headline">Northwest Arkansas
Locations</span>
121 Main St.
Russellville, AK 77801
(626) 111-1111<br />
<html><a href="
http://www.mapquest.com"
target="_blank">Click Here for Driving
Directions</a></html><br />
Thanks for the help,
ChuckThe error is here:
zloc_txt.text = this.content;
Even if you rendered the textfield as HTML, you still need to
tell flash that the variable you are inserting is HTML. Therefore
you need to use the htmlText property.
zloc_txt.htmlText = this.content; -
AS3: How to get height of a dynamically created text field
I am importing text from an XML file and want the lines of text to display in separate text fields beneath each other. How can I set the y value of each succeeding text field so that there is some space (40 pixels or so) from the above field, regardless of the length of the text? Here is my current code. Any help would be greatly appreciated.
var textArray:Array = new Array();
for (var i:int; i <myXML.TOPIC[0].QUERY.length(); i++) {
var textField:TextField = new TextField();
textField.htmlText = myXML.TOPIC[0].QUERY[i].QUESTION;
textField.x = 100;
//below is my problem....I want the y value to be based on the height of all the previous text fields that have been created
textField.y = 100+(40*i);
textField.border = true;
textField.width = 800;
textField.textColor = 0x000000;
textField.multiline = true;
textField.wordWrap = true;
textField.selectable = false;
addChild(textField);
textArray.push(textField);There's nothing wrong with the approach you took... retain it as is. What I was suggesting is basically the same, just a slightly different angle that doesn't need the conditional....
var currentY:Number = 100;
for (var j:int = 0; j <myXML.TOPIC[0].QUERY.length(); j++) {
textArray[j].y = currentY;
// text gets added somewhere in here
currentY = currentY+textArray[j].height+5; -
Is there a way to get the cursor position index of html text field
I'm trying to work on a text pad like MC with "insert text at
position X" and "find and replace" can anyone tell me how to find
the cursor index of an html text field. Selection.getBeginIndex() ,
Selection.getEndIndex(), Selection.getCaretIndex() as far as I know
these methods only work with text and not htmltext.
What I'm trying to do is assign different parts of the string
to variables so that I can combine them to reconstitute my html
string.enfantterrible:
If I understand correctly, you want the corresponding
position in the
htmlText propery of the caret index (which as you point out
is only the
position in the plain text version of the textfield content).
Below is how I would do it. Maybe there's an easier or more
efficient
way (using XML objects etc), but I don't know it. You could
conduct all
your string searches in the plain text and then convert the
result to
the html positions. I didn't build this to accept negative
parameters
for the pos parameter (e.g. from end of string backwards) but
the
function could be adapted to do this too if necessary. The
test data is
not proper html from a text field, but it doesn't really
matter what it
is so long as its formatted correctly. It just separates the
tags from
the content to enable apples with apples comparison.
//some test data
var testStringXML = "<format>Hel<b>lo i can't
t<i>ell you h</i>ow hap</b>py I
am.</format>";
var undecoratedString = "Hello i can't tell you how happy I
am.";
//the conversion function
function findDecoratedPosition(pos:Number, xmlString:String,
test:Boolean):Number {
//anything between '<' and '>' should be excluded from
plain text search.
//create an array of array elements (n=2) consisting of tag
then plain text
//requires correctly formatted xml/html
var tempArr:Array = xmlString.split("<");
for (var aa = 0; aa<tempArr.length; aa++) {
tempArr[aa] = tempArr[aa].split(">");
//remove the first and last elements of the new array (these
are empty)
tempArr.pop();
tempArr.shift();
//find the corresponding plaintext location and calculate
the "decorated" position
var retPos:Number = 0;
var posCount:Number = 0;
for (var aa = 0; aa<tempArr.length; aa++) {
retPos += tempArr[aa][0].length+2+tempArr[aa][1].length;
//+2 allows for missing < and >
posCount += tempArr[aa][1].length;
if (posCount>pos) {
return (retPos+(pos-posCount));
//out of range
return -1;
//test code:
for (var aa = 0; aa<undecoratedString.length; aa++) {
var altPos = findDecoratedPosition(aa, testStringXML);
trace(undecoratedString.charAt(aa)+" in position "+aa+"
plainText equates to position "+altPos+" in the decorated version
["+testStringXML.charAt(altPos)+"]");
} -
Image not displaying with HTML text field
I am trying to display am image within
flash using CS3.
I have a text field with the following code.
feedback.htmlText = "<img src='Logo_small.png'</img>"
nothing displays. The image and flash document are at the same level, so that is why I am using a relative link. Do I need to use a full (absolute) link to the image?That's not properly coded html...
feedback.htmlText = "<img src='Logo_small.png' />";
image tags do not have a closing tag and you didn't close the opening tag if they did, so it would still fail.
Maybe you are looking for
-
Hi All, I have created a user 'Bitest' and group 'Bi_Test_Group'. Assigned the user to the group and the group to BI consumer role. I gave access to only procurement and spend catalog folder reports and Dashboards. When I login to BI Presentation Ser
-
I just installed the brand new OS X 10.10 Yosemite beta 2 on a USB thumb drive. It almost works. Now I want to boot my good old OS X 10.9 Mavericks from the SSD. But there is no option for that, if I reboot the macbook holding the opt key! I see only
-
Closed lid MBP wakes up by itself
I just bought a mid 2012 MBP OS 10.8.3 and it keeps waking itself up when the lid is closed at random times during the night. I never had this problem with the 2007 Black MacBook or the Late 2011 MacBook Pro. "Wake for networkaccess" is turned off, t
-
FM/BAPI to update Production Order at Operation Level
Hi Friends, Can any one help me in this issue. My rek is, needs to update Production Order Sequence Number(AFVC-CY_SEQNRV) at operation level. There are some Production Orders under one Project.User is updating theSequence Numberfor the first order i
-
Hi all.... At our place the route definition has a forwarding agent in it.......now they want it to bring it in to header partner...... Does anyone has any idea on this... Thanks in advance....