Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




True GetCaretIndex() In An HTML Text Field



I have something set up where I am identifying numeric value for the curser position in a text field. Then when I click on a button I am taking that value and saying count over to where the curser was and insert this varable. THIS WORKS FINE IN A NORMAL TEXT FIELD (See script below)

but how do I get it to work in a HTML Text Field? The problem is that I am getting the CaretIndex() of only what is shown in the text field (THIS IS MINUS ALL OF THE HTML TAGS) Which inturn throws eveything off.

------------Looping Key Frame----------
var cursorPosition
cursorPosition=Selection.getCaretIndex()
------------On the Button-------------------
on (press) {
midPoint = cursorPosition; // the point where the text will be inserted

remain = myVar.length-midPoint; // how much of the string is after midPoint

string1 = myVar.substr(0, midPoint);
string2 = myVar.substr(midPoint, remain);
insertString = " first_name ";
myVar = string1+insertString+string2;
}



FlashKit > Flash Help > Flash ActionScript
Posted on: 07-01-2002, 11:19 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

True GetCaretIndex() In HTML Text Field?
I have something set up where I am identifying numeric value for the curser position in a text field. Then when I click on a button I am taking that value and saying count over to where the curser was and insert this varable. THIS WORKS FINE IN A NORMAL TEXT FIELD (See script below)

but how do I get it to work in a HTML Text Field? The problem is that I am getting the CaretIndex() of only what is shown in the text field (THIS IS MINUS ALL OF THE HTML TAGS) Which inturn throws eveything off.

In Flash MX I have been working with calling the string from the text field myField.htmlText but I can't get it to work. Anyone have any ideas?

This is how you would do it in a normal text field.
------------Looping Key Frame----------
var cursorPosition
cursorPosition=Selection.getCaretIndex()
------------On the Button-------------------
on (press) {
midPoint = cursorPosition; // the point where the text will be inserted

remain = myVar.length-midPoint; // how much of the string is after midPoint

string1 = myVar.substr(0, midPoint);
string2 = myVar.substr(midPoint, remain);
insertString = " first_name ";
myVar = string1+insertString+string2;
}

"<" Problem In Html=true Text Field
I'm trying to add a "<" symbol to an html=true dynamic text field using the escaping character as described in the help section under special characters. When flash encounters the x3C, it appears to convert it to the opening symbol, "<", of an html statement. Flash then ignores all of the remaining text. The x3B, x3D and x3E, ";", "=" and ">" respective, all work correctly. Is this a known problem? Is there a patch for this? If not, how do I get around this? I have to have the "<" symbol.

Dynamic Text Field To Display Specific Text When Visibility Of Mc = "true"
Does anyone know if it is possible to display a certain line of text in a dynamic text field when a specific movieclips visibility is true? This is the script I am using now but it is'nt working.

if (_global.gothicBlockSide = "true") {
rightSideFont.text = "Gothic Block";
}

Loading HTML True Text With PHP And LoadVars
I've got a small custom "blog" set up.

An input field sends text to the db w/ PHP and a dynamic text field is SUPPOSED to pull all the text from that column of my db Table.

It works when I run the PHP file in the browser, but Flash can't seem to see it. I've tried sending it back to Flash as a name=value pair, and as a straight echo, but neither seems to work.

I have a feeling the problem is my code is too simple to deal with multiple values for one loadVar.

Here's the PHP code that calls the db and pulls all the entries from the column 'blogBody' in the table 'blogText'


PHP Code:



<?$user = 'simplec_admin';$password = 'eugene';$database = 'simplec_blog';mysql_connect('mysql12.ixwebhosting.com', $user, $password);mysql_select_db($database);$query = 'SELECT * FROM blogText';$blogQuery = mysql_query($query) or die('error');//$display = mysql_fetch_array($blogBody) or die('error2');while($blogDisplay = mysql_fetch_array($blogQuery)){echo $blogDisplay['blogBody'];echo "<br>";}?>




Here's my Actionscript that pulls the text from the PHP file and puts it in a dynamic text field:


Code:
var blogIn:LoadVars = new LoadVars();
var blogOut:LoadVars = new LoadVars();

blogIn.load("blogIn.php",_blank);

blogIn.onLoad = function (success) {
if(success){
blogField.text = blogIn.blogDisplay;
}else{
blogField.text = 'Error loading from Database';
}
};

Thanks a ton! x-posted in ACTIONSCRIPT 2.0

Loading HTML True Text With PHP And LoadVars
I've got a small custom "blog" set up.

An input field sends text to the db w/ PHP and a dynamic text field is SUPPOSED to pull all the text from that column of my db Table.

It works when I run the PHP file in the browser, but Flash can't seem to see it. I've tried sending it back to Flash as a name=value pair, and as a straight echo, but neither seems to work.

I have a feeling the problem is my code is too simple to deal with multiple values for one loadVar.

Here's the PHP code that calls the db and pulls all the entries from the column 'blogBody' in the table 'blogText'


PHP Code:



<?$user = 'simplec_admin';$password = 'eugene';$database = 'simplec_blog';mysql_connect('mysql12.ixwebhosting.com', $user, $password);mysql_select_db($database);$query = 'SELECT * FROM blogText';$blogQuery = mysql_query($query) or die('error');//$display = mysql_fetch_array($blogBody) or die('error2');while($blogDisplay = mysql_fetch_array($blogQuery)){echo $blogDisplay['blogBody'];echo "<br>";}?>




Here's my Actionscript that pulls the text from the PHP file and puts it in a dynamic text field:


Code:
var blogIn:LoadVars = new LoadVars();
var blogOut:LoadVars = new LoadVars();

blogIn.load("blogIn.php",_blank);

blogIn.onLoad = function (success) {
if(success){
blogField.text = blogIn.blogDisplay;
}else{
blogField.text = 'Error loading from Database';
}
};

Thanks a ton! x-posted in GENERAL QUESTIONS

[FMX04] AS - Showing Text Field As HTML Field With XML/CDATA.
Hey all -

Trying to get a text field in my Flash MX movie to pull from and XML file with CDATA tags to show as HTML. I've checked the box to render as HTML for the text data field... but I'm having problems with the Actionscripting.

The field from this line is what I need to recognize as HTML reading CDATA tags:

this.ref["textField"+i].text = subnodes[3].firstChild.toString()

I know I need to do more than just change it to ".html" instead of ".text" and have tried a couple things, but nothing seems to work.

Any help greatly appreciated!


Code:
//Create the XML Object
myXML = new XML ();
myXML.load(newXml);
myXML.ignoreWhite = true;

//Load XML file
myXML.load("PBintro.xml");
//Make a reference to current timeline
myXML.ref = this
// Parse XML and fetch
myXML.onLoad = function(success){
if(success){
var root = this.firstChild ;
nodes = root.childNodes
for(var i=0; i<nodes.length; i++) {
this.ref["Title_txt"+i].text = nodes[i].attributes.name
subnodes = nodes[i].childNodes
this.ref["Comments_txt"+i].text = subnodes[0].firstChild.toString()
this.ref["Link_txt"+i].text = subnodes[0].firstChild.toString()
this.ref["Link_txt"+i] = subnodes[1].firstChild.toString()
this.ref["holder_mc"+i].loadMovie(subnodes[2].firstChild.toString())
this.ref["textField"+i].text = subnodes[3].firstChild.toString()
this.ref["textField"+i] = subnodes[4].firstChild.toString()
}
} else trace("Error loading XML document")
}

Sending Html Text To Html Dynamic Text Field But It Dosnt Show
code: theNews = "<font color=#FF9900>"+newsRow0newsDate+"</font>"+": "+newsRow0newsStory+newline+"<font color=#FF9900>"+newsRow1newsDate+"</font>"+": "+newsRow1newsStory+newline+"<font color=#FF9900>"+newsRow2newsDate+"</font>"+": "+newsRow2newsStory+newline;
newsArea.textMain.htmlText = theNews;
trace("the news ="+theNews);

The data dosn't display but if i change the textMain.htmlText to .Text then it works, i need the formatted text.
Is ther something wrong with this?
i cant see anything wrong.

Cheers
Paul

Sending Html Text To Html Dynamic Text Field But It Dosnt Show
ActionScript Code:
theNews = "<font color=#FF9900>"+newsRow0newsDate+"</font>"+": "+newsRow0newsStory+newline+"<font color=#FF9900>"+newsRow1newsDate+"</font>"+": "+newsRow1newsStory+newline+"<font color=#FF9900>"+newsRow2newsDate+"</font>"+": "+newsRow2newsStory+newline;
newsArea.textMain.htmlText = theNews;
trace("the news ="+theNews);
The data dosn't display but if i change the textMain.htmlText to .Text then it works, i need the formatted text.
Is ther something wrong with this?
i cant see anything wrong.

Cheers
Paul

Scroll Bar For Html Dynamic Text Field Won't Work With Html
Hi:

I'm trying to add a scroll bar to a dynamic text field that is populated with an XML file. (see attached scolltext.zip file).

If I populate the field with plain hard coded text, it works fine. However, in my application, I need the text to contain html formatting codes. When I change the hard coded string to include html, it doesn't appear to work.

Can anyone suggest an alternative way to create a scroll bar for this dynamic text field? I need the html to stay as is because eventually the glossary will be populated via XML through a CF server.

Thanks in advance for any assistance!

Dawnthea

Xml File Containing Html To Html Text Field
Hi all,
I am currently trying to import some HTML through XML and so far so good however when I import a string of code ie

Code:
some text and <a href="http://www.example.com" target="_blank">a link</a>
using this in XML

Code:
<?xml version="1.0" encoding="UTF-8"?>

<prop amountToShow="6">
<news newsStatus="1">
<date_txt>28 Feb 2004</date_txt>
<headline_txt>headline 4</headline_txt>
<content_txt><![CDATA[some text and <a href="http://www.example.com" target="_blank">a link</a>]]></content_txt>
</news>
</prop>
I get the string

Code:
some text and <a href="http://www.example.com" target="_blank">a link</a>
Where it breaks it down the open square brackets and more into html code.
I want to keep the html code as it is.
Does anyone know how I can do this?
Thanks

Html Text Field Not Parsing Html
hi everyone

another problem. I have a text field marked at html text, and I want to dynamically apply text to it. Works fine and well, but the html (only a href tags) are not being parsed. I've also tried manually putting this into an html text field, and the same thing happens... nothing.

Any help? I'm desperate.

Loading A Html-tagged Text File Into A Text Field...it's Just Not Working For Me...
hi,

i'm trying to load news.txt into a textfield using loadvars.

news.txt:
-----------------------------------
&news=<p font face="Verdana" size="12"><b>Recent Achievements:</b><br>Congratula etc. etc.

the as:
----------------------------------
loadnews = new LoadVars();
loadnews.load("flash/news.txt");
loadnews.onLoad = function(success) {
newstext = loadnews.news;
trace(newstext);
gotoAndStop(2);
}

the trace is showing that newstext is the text out of news.txt ... in the frame 2 that the onLoad function refers to is a textfield (multiline, with the html as true) which is supposed to display the newstext variable.

If i set newstext to something else ... eg: newstext = "some text" then it works fine ...

what's going on???

Cheers,
Ben

Receiving 'true' In The Dynamic Field Rather Than The Data
Hi I'm having problems getting a dynamic field to display some XML properly, i think it is jut my syntax but not sure, if i make a manual path of Movieclips with instance names it displays fine!!!

Basically I have this load Var statement, which contains the path to the dynamic field when generated:

var description_lv = new LoadVars();
description_lv.onData = function(raw_text){
currentThumb_mc.DJ.VenueN2.description_txt.text = raw_text;
}

in turn i have below creating the dynamic clip

//create DJ: clip
currentThumb_mc.DJ.attachMovie("DJ2","DJ3",2)
currentThumb_mc.DJ.DJ3._x = 56
currentThumb_mc.DJ.DJ3._y = -5
currentThumb_mc.DJ.DJ3.DJN_txt.text = currentPicture.attributes.title; //-- is working

//create Venue: clip
currentThumb_mc.DJ.attachMovie("VenueN","VenueN2",3)
currentThumb_mc.DJ.VenueN2._x = 56
currentThumb_mc.DJ.VenueN2._y = 7
currentThumb_mc.DJ.VenueN2.description_txt.text = description_lv.load(this.description);

the bottom line is one i have modified out of a release statement, I am receiving a error URL not found, in addition the path is correct as the field is displaying true, but i'm not sure how to change the code to get this data appearing correctly, like i said it works manually creating MC and i'm thinking the path is right above, so I cannot work out why else it wouldn't be working can someone pleeeeeeeeeeease help!

Thanks V much





























Edited: 11/09/2006 at 05:52:42 AM by elviskat

Preserving Rich Text... Html In Dynamic Text Field
i have a dynamic text field that gets the text from data.html and i turned on the "render text as html" button, what eltse do i have to do to get it to work?

Html Text Field Write To Flash Dynamic Text Box
I have a dynamic text field in Flash.
I would like to have users type a message in the HTML text field and have it eventually appear in the Flash dynamic text field.
How can I get text from an HTML text field (on the same page as the swf) to write to the Flash dynamic text field?

Space In Html Freaks Out Text Format In Text Field
heres the html

<P ALIGN="LEFT"><FONT FACE="Helvetica" SIZE="43" COLOR="#000000"><A HREF="http://www.thelink.com" TARGET=""><U>link1</U></A> <A HREF="http://www.thelink.com" TARGET=""><U>link2</U></A></FONT></P>

The HTML Text Field Won't Center The Text Inside... Why?
Hello there,

The thing is: I have a HTML text field in my movie that loads a variable from a txt file. I set in the text field paragraph option the 'center' mode.

Ok, it should work fine, but it doesn't... The text loads fine, but it starts in the left side of the field and not in the center as wanted.

I tried to put HTML center tags in the txt like:

Code:
&text=<center><a href="http://www.link.com">This is my text</a></center>
and:


Code:
&text=<div align=center><a href="http://www.link.com">This is my text</a></div>
Both options didn't work as well.

Is there a way to do that or I'll just have to let the HTML aside and use regular dynamic text fields?

Thanks in advance and sorry for the 'ingrish'

Justifying Html Text In Dynamic Text Field
i as'ed html text into dynamic text field, but i can only get it to align left, right or center.

is there anyway to justify the html text so that it looks good?

the example i'm talking about is seen here:

http://www.eight.nl/ttb/ttb.html

Html Text - Dynamic Text Field - Escape?
I am trying to embed a link into a html external text document that I am importing into a dynamic text box.

The url is passing a variable to a cgi script and has a "?" and a "&" in it.

Is there a way to escape these characters or another way to get this url into my text field?

Thanks!

Load Html Text Into Dynamic Text Field
Does anyone know the action script I need in order to load an external html text file (e.g. mytext.htm) into a dynamic text box. The dynamic text box has an instance name of ArticleTxt. Also where do I apply the action script, is it frame based? or do I apply it to the text box?

HTML Enabled Text Field Not Showing Text... Help.
Last edited by myles724 : 2006-03-29 at 06:47.
























I've got a dynamic text field on the stage with the variable name myField. I've clicked the <> button to Render Text as HTML.
I've also attached the code
myField.htmlText = "<b>My Name</b>";
on the first frame...
problem is, nothing shows up in the text field when I preview it. What's the problem?

UPDATE: it seems to work fine when the font isnt embedded... so how do i embed a font and format it using html?

HTML Text Field, HELP
Hey peeps!

Here is my problem. I am send this string to my text field:
"your results are as follows:<br>Member ID= 3<br>Name= Greg Starr<br>Member Details=Here are my details if your interested"

Now the text field has render as HTML turned ON. but it renders the string just like it is. What am I doing wrong?

Thanks all,
SuM

HTML Into A Text Field ?
Hi there,

I would like to know if it's possible to make a HTML page loading into a flash window (instead of a txt file ?)

Here's an example



Thank you

Text Field/HTML
Hi!

i was wondering if there is a way to embedd HTML code in an externally loaded .txt file into my flash 2004 MX movie...and if so, how?


* second question, how do i change colour/make links and stuff like that in an externally loaded .txt file?



Thanks for taking your time to read this!

Text Field/HTML
Hi!

i was wondering if there is a way to embedd HTML code in an externally loaded .txt file into my flash 2004 MX movie...and if so, how?


* second question, how do i change colour/make links and stuff like that in an externally loaded .txt file?



Thanks for taking your time to read this!

Using <img> HTML Tag In Text Field
Can anyone help me fix alignment issues using the <img> tag to place an image into a text field?  I am using loadVars to load text into a dynamic text field.  It loads my text and clears room enough for the picture, but aligns it over the edge of my text field instead of placing it against the left margin.  It is as if it's just pushing my image about 50 pixels left of where it should be, even when I specify align="right" in the tag, it places the image over top of text.

HTML DYNAMIC TEXT FIELD
Well, I have a news system where a txt file is loaded wit the dynamic text field content and it scrolls etc.

But!...I want to make it a font that is fully embedded, you know, when you click Embed all. If I do that then the friggin text doesn't show, is it something in the HTML or can't you embed all??

Thx in advance.

Why Does MX Not Parse My Text Field Like Html
look i`ve a dynamic text field it load from an external text file with some html code inside but the html come out as codem and not render as html

thnx

Text Field Wont Allow Html
hi guys,
i am having a strange problem with my new Flash forum. for somne reason my textfield wont accept urls. the text field is set to allow urls but as soon as i make a post it come up with the web address but its not linkable. If you check out my link and try to make some posts yourselfs you will see what i mean.

http://www.innovativedesigns.org.uk/...D=6&threadID=5

cheers

Flash 6 Html To Text Field
Hello,
I am working on a flash site, and I need help!! PLease.

I am trying to get a flash movie to load an html page when a link is clicked..Now I know that is easy. but here is the tricky part. I have all my text coming up in a box, and I want the page to load there as well.
kind of like frames, but I can't seem to get the page to load in the text area.

Does anyone know how to do this?


THank you very much.
AJ

HTML Rollovers In Text Field?
Hi - Ive got a whole list of elements in a dynamic text field - I know its quite hard to asign action script to individual bits of text so I have created buttons behind the bits I need, BUT I would still like to highlite the text when I rollover it.

Could somebody explain how I can change the colour of the HTML text when I rollover it?

thanks alot for your help

HTML Inn Dynamic Text Field
I am using a tooltip and in that tooltip is some dynamic text...the texxt is loaded in from a cfm page...the text shows up but now i want to be able to modify that text using html...the text appears but the html tags dont do anything...here is what i have.
this is what calls the tooltip function
_root.tooltip("<font color="red">Resident:</font> "+resident);
the next code is the tooltip function
function tooltip (string,tipColor) {
xmouse = getProperty("", _xmouse);
ymouse = getProperty("", _ymouse);
duplicateMovieClip ("_root.tooltip", "tooltip1", 1);
tooltip1.tooltip = string;
setProperty (tooltip1, _x, xmouse);
setProperty (tooltip1, _y, ymouse);
startDrag ("_root.tooltip1");
_root.tooltip1._alpha=ttAlpha;
//toolTipBG = new Color("_root.tooltip1");
//toolTipBG.setRGB(tipColor);
tooltip1.gotoAndPlay(2);
}

function remove_tooltip () {
stopDrag ();
removeMovieClip ("tooltip1");
}

any help would be appreciated

Urgent Please: HTML In Text Field
Hi all

I have a string of HTML format, contains some break line tag (<br>). How ever, the textfield can display font, color, size well but the break line. Can anyone tell me what I am wrong?

Please see the attachment for more detail.
Thanks,
Tuy Le

Open Pop-up From Html Text Field
hi,
I have a html dinamic text field.

Is it possible to open a pop-up window with tag <a> from a text field?

i've tried with:
<a href="javascript:window.open('news.php?id=3','news 3','width=200,height=200,toolbar=no,location=no,di rectories=no,status=no,menubar=no,scrollbars=yes,r esizable=yes,top='+((screen.height/2)-(100))+',left='+((screen.width/2)-(100))+'');void(0);">open news</a>

but it don't work.
Thank you in advance.
noir

Dynmaic Text Field And HTML CSS
Is there a way to have a CSS applied to imported HTML?

How Do I Display Html In A Text Field?
I used to know how to do this in MX 2004 but it won't work in CS3 so act like I know nothing (which I don't). How do I make a text field that reads either html from a txt file or even better, from a proper html file in Flash CS3?

_x,_y Positions Of Text In Html Field?
Hi

I have been trying to get absolute positions of pieces of text in a dynamic html textField, it does not seem to be simple Sorry for the amount of code.

Here is the code I have been working on

Attempt 1

Code:
// Gradient fill circle or elipse prototype :)
//Justin Mills JLM@justinfront.net
//10 October 2003
//
MovieClip.prototype.drawElipse=function(x,y,w,h,t,c,a,s,f,fa){
if (f==undefined) {f=c; fa=0;}else if (fa==undefined) {af=100};
if (s==undefined) {s=5;} //smoothness
this.beginGradientFill('radial', [f,c,c,c], [fa,a,a,0], [255-s*2-t,255-s-t,255-s,255], {matrixType:'box', x:x, y:y, w:w, h:h, r:0});
this.moveTo(x,y)
this.lineStyle(1,0,0);
this.lineTo(x,y+h)
this.lineTo(x+w,y+h)
this.lineTo(x+w,y)
this.lineTo(x,y)
this.endFill();
}
//example
/*
this.createEmptyMovieClip("elipse",100);
elipse._x=100;
elipse._y=100;
elipse.drawElipse(0,0,150,100,4,0xFF0000,100,5); //x,y,w,h,t=4 thickness,c=red,a=100%,s=5 smoothness,f=fill, fa=fill alpha
/*/
// End Gradient fill circle or elipse prototype


depth=0;
wide=100;
createTextField("mytf_txt",depth++,100,100,wide,10000);
someText="A long section of <font size='14'><b>text to test</b></font> my dimensions of a textfield aksd dfahs ldfak jsdhf";
someText="A long section of text to test my dimensions of a textfield aksd dfahs ldfak jsdhf";
mytf_txt.html=true;
mytf_txt.htmlText=someText;
TextField.prototype.locateStringBefore=function(searchString, afterTrue, bottom){//include format ends
trace("search string ="+searchString);
var oldText=this.htmlText;
if(bottom==undefined){bottom==0.9};
var testText=((this.htmlText).split(searchString))[0];
//trace(testText);
if(afterTrue||afterTrue==undefined){
testText+="_";
}else{
testText+=searchString;
}
this._parent.createTextField(this._name,this.getDepth(),this._x,this._y,this._width,10000);
this.selectable=false;
this.html=true
this.htmlText=testText;
this.wordWrap=true;
this.autoSize=true;
var tempheight=this._height;
this.htmlText=testText;
var lines;
trace("Number of lines " add (lines=this.maxscroll));
this.autoSize=false;
this._height=tempheight;
this.scroll+=lines;
var currScroll=this.scroll;
var maxScroll=this.maxscroll
selection.setFocus(this);
var count=1;
var fulength=selection.getEndIndex();
var temptext="";
while(maxScroll==this.maxscroll){
count++
selection.setSelection(fulength,fulength);
this.replaceSel("_");
temptext+="_";
if(count>(this._width*1.5)){
trace("broken");
return(null);
}
}
this.htmlText=temptext;
var remainX;
trace("remainder htmlText " add (remainX=this._width-this.textWidth));
this.htmlText=testText;
this.scroll-=lines;
this.autoSize=true;
var posX;
var posY;
trace("end of Text Position x : " add (posX=this._x+remainX));
trace("end of Text Position y : " add (posY=this._y+((lines-bottom)/lines)*this._height));
//if(count==3){posY+=this._height/(lines+1)+2*bottom/(lines+1);posX=this._x;}//<- this line not right yet
if(count==3){posY=this._y+((lines-bottom)/(lines-lines/((lines+1))))*this._height;posX=this._x;}
this.htmlText=oldText;
return({_x:posX,_y:posY,_lines:lines});
}
TextField.prototype.diagonalthru=function(myString,posSlope){
if(posSlope||posSlope==undefined){
d=0.3;
pos=this.locateStringBefore(myString,true,0.6-d);
pos2=this.locateStringBefore(myString,false,0.6+d);
} else {
d=-0.3;
pos2=this.locateStringBefore(myString,true,0.6-d);
pos=this.locateStringBefore(myString,false,0.6+d);
}
trace(pos._lines);
var mc=this._parent.createEmptyMovieClip("blob" add _root.depth++,_root.depth)
with(mc){
_x=pos._x,_y=pos._y,lineStyle(1,0xff0000,100),lineTo(pos2._x-pos._x, pos2._y-pos._y);
}
};
TextField.prototype.getCorners=function(myString){
d=0.5;
pos=this.locateStringBefore(myString,true,0.6-d);
pos2=this.locateStringBefore(myString,false,0.6+d);
var mc=this._parent.createEmptyMovieClip("blob" add _root.depth++,_root.depth);
mc.drawElipse((pos._x+pos2._x)/2-Math.abs(pos._x-pos2._x)/2,(pos._y+pos2._y)/2-1.1*Math.abs(pos._y-pos2._y)/2,Math.abs(pos._x-pos2._x)*1.1,Math.abs(pos._y-pos2._y)*0.9,10,0xFF0000,100,3,0xFF0000,20);
};
TextField.prototype.crossOut=function(mywords){
var aword;
for(myString in mywords){
trace("crossOut "+mywords[myString]);
aword=mywords[myString];
this.diagonalThru(aword,false);
this.diagonalThru(aword,true);
}
}
TextField.prototype.circleText=function(mywords){
var aword;
for(myString in mywords){
trace("crossOut "+mywords[myString]);
aword=mywords[myString];
this.getCorners(aword);
}
}
mytf_txt.circleText(["section"]);
mytf_txt.circleText(["my","text","textfield","of","ldfak"]);
//mytf_txt.crossOut(["section"]);
//mytf_txt.crossOut(["my","textfield","of","ldfak"]);
Now I realised that the heights were not accurate for Html so I made this which is also buggy


Code:
TextField.prototype.getNoLines=function(){
var hTxt=this.htmlText;
this.wordWrap = this.autoSize =true;
trace(this.htmlText = this._height);
this.htmlText = hTxt;
this.totalLines=this.maxscroll;
return(this.maxscroll);
};
TextField.prototype.seperateHtml = function() {
var newText = (this.htmlText).split("<");
var newhtml = [];
var newTextText = [];
for (i=0; i<newText.length; i++) {
txtSplit = newText[i].split(">");
newhtml.push("<"+txtSplit[0]+">");
newTextText.push(txtSplit[1]);
}
return ({text:newTextText, htmlText:newhtml, length:newhtml.length});
};
TextField.prototype.joinHtml = function(obj) {
var anotherText = [];
for (i=0; i<obj.length; i++) {
anotherText.push(obj.htmlText[i]);
anotherText.push(obj.text[i]);
}
this.htmlText = anotherText.join("").substr(2);
};
TextField.prototype.getCharPerLine=function(){
lines=this.getNoLines();
trace(lines);
var o = this.seperateHtml();
o.temp = o.text.join("|");
noCharPerLine=[];
ks=[];
oldnoChar=0;
while (k<o.temp.length+1) {k++;
o.temp2 = o.temp.substr(0, o.temp.length-k);
o.text = o.temp2.split("|");
this.joinHtml(o);
this.autoSize = true;
this.wordWrap = true;
this.autoSize = false;
if (this.maxscroll != lines) {
if(lines==2){lastLess=o.text.length};
lines--;
noChar=k-oldnoChar
noCharPerLine.push(noChar);
ks.push(k);
oldnoChar=k+2;
}
}
noCharPerLine[noCharPerLine.length-1]-=lastLess;
this.htmlText = someText;
this.wordWrap = true;
this.autoSize = true;
trace(ks);
return noCharPerLine;
};
TextField.prototype.getTextMarkersforLines=function(){
lines=this.getNoLines();
trace(lines);
var o = this.seperateHtml();
o.temp = o.text.join("|");
noCharPerLine=[];
ks=[];
oldnoChar=0;
while (k<o.temp.length+1) {k++;
o.temp2 = o.temp.substr(0, o.temp.length-k);
o.text = o.temp2.split("|");
this.joinHtml(o);
this.autoSize = true;
this.wordWrap = true;
this.autoSize = false;
if (this.maxscroll != lines) {
if(lines==2){lastLess=o.text.length};
lines--;
noChar=k-oldnoChar
noCharPerLine.push(noChar);
ks.push(k);
oldnoChar=k+2;
}
}
noCharPerLine[noCharPerLine.length-1]-=lastLess;
this.htmlText = someText;
this.wordWrap = true;
this.autoSize = true;
this.thechars=[];
for(all in ks){
this.thechars[all]=ks[all];
}
return ks;
};
TextField.prototype.getLineHeights=function(){
var marker=this.getTextMarkersforLines();
var o = this.seperateHtml();
o.temp = o.text.join("|");
var j = 0;
o.temp2 = o.temp.substr(0, o.temp.length-j);
o.text = o.temp2.split("|");
this.joinHtml(o);
this.autoSize = true;
this.wordWrap = true;
var tempheight = this._height;
var lines=0;
lineheights=[];
while (j<o.temp.length+1) {
j++;
o.temp2 = o.temp.substr(0, o.temp.length-j);
o.text = o.temp2.split("|");
this.joinHtml(o);
this.autoSize = true;
this.wordWrap = true;
if (tempheight != this._height) {
tempheight=this._height;
if(marker[lines]==(j)){
lineheights.unshift(tempheight);lines++;
}
}

}
lineheights.shift();
lineheights.push(+3);
lineheights.unshift(this._height);
this.lineheights=[];
for(all in lineheights){
this.lineheights[all]=lineheights[all];
}
return lineheights;
};
TextField.prototype.drawLines=function(){
drawWidth=this._x+this._width;
this.getLineHeights();
for(i in lineHeights){
drawHeight=lineHeights[i]+this._y-3;
this._parent.lineStyle(1,0xff0000,100);
this._parent.moveTo(mytf_txt._x,drawHeight);
this._parent.lineTo(drawWidth,drawHeight);
}
}
TextField.prototype.findString=function(myString){
txt=this.text;
o2={};
o2.txt=txt.split(myString);trace(txt);
o2.info=[];
var o = this.seperateHtml();
tempTxt="";
for(i=1;i<this.totalLines;i++){trace("looping through lines"+i);
for(j=0;j<o2.txt.length-1;j++){trace("looping through strings"+j);
tempTxt=o2.txt[j]+tempTxt;
trace(tempTxt.length);
trace("line "+i+" is "+this.theChars[i]+" long");
trace(tempTxt.length);
if(tempTxt.length>this.theChars[i]){
trace("'"+myString+" is on not on line"+i);
}else{
j++;
o2.info.push(i);trace("My string '"+myString+"' is on line "+i)
break;
}
}
}
}
/*create TextField*/
depth = 0;
wide = 100;
createTextField("mytf_txt", depth++, 100, 100, wide, 10000);
someText = "A long section of <font size='18' color='#ff0000'><b>text to test</b></font> my dimensions section of a <font size='14' color='#ff0000'><b>textfield</b></font> aksd dfahs ldfak jsdhf";
mytf_txt.html = true;
mytf_txt.htmlText = someText;
//mytf_txt.selectable = false;
/*end create TextField*/

mytf_txt.drawLines();
mytf_txt.findString("section");
But as I try to put the ideas in both fla's together (which I won't post as it currenly does not work) I am wondering if there might be a better approach and if this approach is dodgy. I am assuming text is not embeded since I do not want the overheads.

Any ideas

Many thanks

JLM

Dynamic Html Text Field
Ok I have always had problems with dynamic text fields and fonts but now I am at a crossroads as to a problem. I have a component that fills a dynamic text field created at runtime that is html enabled but it seems to be not "catching" the tags. Now before someone gets on here and says:

Did you set the txt.html = true?
Did you assign the txt.htmlText = "some text"?
Did you embed the fonts?
YES-YES-YES within the component with all the glyphs I need ...meaning also the bolded/italic and regular. The tags are catching at authoring time when I am using the compiled clip. But at runtime they are showing < characters here is what I am tracing for the dynamic field at authoring time:

<TEXTFORMAT LEADING="2"><P ALIGN="JUSTIFY"><FONT FACE="Arial Narrow" SIZE="12" COLOR="#000000" LETTERSPACING="1" KERNING="1">HTML <B>text</B> goes here...</FONT></P></TEXTFORMAT>

Now when I do a trace at runtime this is what I am getting:
<TEXTFORMAT LEADING="2"><P ALIGN="JUSTIFY"><FONT FACE="Arial Narrow" SIZE="12" COLOR="#000000" LETTERSPACING="1" KERNING="1">HTML <b>text</b> goes here...</FONT></P></TEXTFORMAT>

Now the only thing I can think of is that there is a race condition that is not catching the boolean or something before the text is rendered on the stage?

Now the funny thing is the component I am working on is version 2...version 1 is the EXACT same code nothing has changed and it works but for the longest time it was having the same problems but ...boom it just started working when I set the txt.border = true.

I was also thinking maybe the order of setting the particular properties was an issue or something so I did trace on the format and textfields and assigned them in order of which they are created. On other thing is I already tried embedding the fonts within the library that did not solve my issue.

I was curious of kglad or another developer would have an answer to this.







Attach Code

private function setInputText():Void {
_inputText.selectable = false;
_inputText.multiline = true;
_inputText.wordWrap = true;
//_inputText.border = true;
_inputText.html = true;
_inputText.embedFonts = true;
_inputText.htmlText = _boxText;
_inputText.type = "dynamic";
//_inputText.text = _boxText;
_inputText.autoSize = "left";
_inputText.antiAliasType = "normal";
_fmt = new TextFormat();
_fmt.letterSpacing = 1;
_fmt.kerning = true;
_fmt.leading = 2;
_fmt.align = "justify";
_fmt.color = _boxTextColor;
_fmt.size = 12;
_fmt.font = "Arial Narrow";
_inputText.setTextFormat(_fmt);
trace(_inputText.htmlText);
/*********Format Testing************
for (var prop in _fmt) {
trace(prop+": "+_fmt[prop]);
}
trace("---------------------------------------");
for (var prop in _inputText) {
trace(prop+": "+_inputText[prop]);
}
trace("---------------------------------------");
****************************************/
}

























Edited: 02/22/2007 at 11:28:55 AM by poisoniver

Antialiasing Html Text Field
Hi Kirupaeans,
I'm using a dynamic text field to display CSS-formatted html. My question: can I embed the font for this text field? When I try to embed the font outlines (via the "character..." button), nothing shows up when I run the swf.
Does anyone know if this is simply not allowed with html text fields, or is there a way around it? Note that using the "alias" button doesn't affect the results.
In other words, on one part of my design I have text in a static field, and on rendering it appears anti-aliased, and frankly, looks nicer. Now on the html-dynamic field, it's aliased and looks worse.
What's the story? Thanks in advance!
:: v_D ::

Rendering Xml As Html In Text Field
Hi,

I have a simple xml file with this structure.

<?xml version="1.0" encoding="iso-8859-1"?>
<content>
<page name="Page Name">
<text>
<p>This is line 1....</p>
<p>This is line 2....</p>
<p>This is line 3....etc</p>
</text>
</page>
</content>


I can update a text field to show the page name attribute but I cannot get another text field to show the text content rendered as html.

The 'render as html' option is selected but the <p> tags don't render as expected.

What am I doing wrong?? I'm thinking it's something simple!

T

Rendering Xml As Html In Text Field
Hi,

I have a simple xml file with this structure.

<?xml version="1.0" encoding="iso-8859-1"?>
<content>
<page name="Page Name">
<text>
<p>This is line 1....</p>
<p>This is line 2....</p>
<p>This is line 3....etc</p>
</text>
</page>
</content>

I can update a text field with the page name with - xmlData.firstChild.childNodes[0].attributes.name but I cannot get another text field to show the text content rendered as html.

The 'render as html' option is selected but the <p> tags don't render as expected.

What am I doing wrong?? I'm thinking it's something simple!

T

Embed Swf Into Html Text Field
anyone know if this can be done, and if not how do we ask macrodia to do so.

I'm putiing together a possible project for a client and they would like to display html within text field on page, okay,  but every now and then they like to display an inline graphic, (screen shot, arrow, and icons).

I know that html text field will only text of html

text= my text or
text= <b>my text</b>

if we could include

text=<b>my inserted swf</b>add code for object embed

anyone ever think of this?

jef

Html Text In Dynamic Text Field
Hey all
I've got a dynamic text box that pulls it's text from MySQL through PHP.

The text that it pulls is a mix of straight text and HTML code.

Everything works fine except the formatting. The main issue being text that follows a <img src=> tag.

www.simplecoat.tv - click the "BLOG" button on the remote control.
www.simplecoat.tv/blogIn.php - you can see that the HTML code is fine in the database.

Is it a problem with having images in a dynamic text field?

Thanks!

Get Selection Index From Html Text Field
argh!

hey all,

has anyone had to get the selection indicies from a html enabled text area?

I'm using the

Selection.getBeginIndex()
and
Selection.getEndIndex()

but these are returning counts based on the visible text
BUT...
then when I need to do substring functions, the indicies refer to the whole string (html tags etc.)


does anyone have a clever idea??


thanks,
glenn

Button In Flash Html Text Field?
hi there!

i'm trying to set up a button into a flash hml text list,
so that it triggers an action in the flash movie.
is that possible?

so far, all i can find is the <a href> tag to create
a button, but that only triggers external browser windows....

Html Tags Showing In Text Field
myTextfield.html=1;
myTextfield.text="a<br>a";

shows:

a<br>a

I don't want to see <br> in there I just want it to breal row

how can I fix that?

Display Html Page In A Text Field
How can we load a html page as a variable and display it in a text field?

Having HTML Content Inside A Text Field
how can i have html content inside a flash file, particulalry inside text field? i can't use xml, since i don't know how, and since school doesn't want to use xml...

can anyone help?

Format Dynamic Text Field To HTML ?
Hi all,

cant seem to format my actionscript created text field....
here is my code
=============================
this.createTextField("warningText",10,-97,-50,175,90);
warningText.html = true;
warningText.text = " < u > Assistance < / u > ";
=============================

Am trying to have the text say "Assistance" and make it underlined aswell.

At the moment the HTML tags are displayed too - "< u >Assistance< / u >"

??

Thanks in advance

gilesb

Copyright © 2005-08 www.BigResource.com, All rights reserved