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




Text Issues: HTML Vs. TextFormat



I have a dynamic textfield with dimensions that cannot be changed. Sometimes, the only way to squeeze in all the copy is to change the font size. Ii know how to do this via textFormat, but not via HTML.

Certain words need to be underlined. I know how to do this via HTML, but not textFormat. I see that there is a 'textFormat.underline' command, but all attempts with it have failed.

If it matters, the text source is an XML document.

Any help would be deeply appreciated.

Thanks in advance,
Paul



ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 04-24-2004, 07:44 PM


View Complete Forum Thread with Replies

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

Dynamic Text Fields And TextFormat Issues
So I'm building a business card app. There are dynamically created input text fields in the left interface. Their default font is in Arial. Then in the Center Pane, I attach the empty BusinessCard (myCard). this symbol has an empty movieclip on each layer to hold backgrounds, text, and then images. Inside myCard's empty movieclip for the textfields, I attach movie clips with dynamic text fields to serve as output textfields. I have shared in fonts called myArial-Bold and have set these output textfields to myArial-Bold.

This loads up fine, fontwise.Then i have whatever is in the input textfields go to the output textfields.

The output textfeld's font format gets overwritten to the default Arial font. Ok, so I use TextFormat to try to set it back to Arial-Bold, and it will not respond. It keeps the arial font.

The line that causes all this trouble:

newOutputPanel.output_txt.text = newPanel.input_txt.text;

I thought this would only bring over the text, not the format! Anyone else get this problem?









Attach Code

// in the root timeline

function addPanel() {
var newPanel = _root.LftPanel_mc.attachMovie("interface-section", "Panel" + panelNum, panelNum, {_x:0, _y:panelY});
newPanel.mylabel_txt.text = txtFields[i];
newPanel.input_var = txtFields[panelNum];
aInput.push (newPanel);
var newOutputPanel = Pane.myTxtBound_mc.attachMovie("myOutputTxt","Output" + panelNum,panelNum,{_x:0, _y:outputY});
newOutputPanel.output_txt.text = newPanel.input_txt.text;
var myFmt:TextFormat = newOutputPanel.output_txt.getTextFormat();
myFmt.font = "myArial-Bold";
myFmt.size = 20;
newOutputPanel.output_txt.setTextFormat(myFmt);
newOutputPanel.output_txt.setNewTextFormat (myFmt);
aOutput.push (newOutputPanel);
}

// in the input movieclip

myName = this._name;
var my_array:Array = myName.split("l"); //This is an "L"
myNum = my_array[1];
this.input_txt.onChanged = function(textfield_txt:TextField) {
varToChange = eval("_root.Pane.myTxtBound_mc.Output" + myNum);
var tfFormatter:TextFormat = varToChange.output_txt.getTextFormat();
Trace(tfFormatter.font);
varToChange.output_txt.text = textfield_txt.text;
varToChange.myHighlight._width = varToChange.output_txt._width;
varToChange.myHighlight._height = varToChange.output_txt._height;
_root.myOutputField = varToChange;
varToChange.output_txt.setTextFormat(tfFormatter);
Trace(tfFormatter.font);

};

// in the output movieclip

myFmt.font = "myArial-Bold";
this.output_txt.setTextFormat(myFmt);
this.output_txt.setNewTextFormat (myFmt);

this.onPress = function() {
this.startDrag();
_root.myOutputField = this;
var myFmt = this.output_txt.getTextFormat();
trace(myFmt.font);
//for (var prop in myFmt) {
//trace(prop+": "+myFmt[prop]);
//}
}

this.onRelease = function() {
this.stopDrag();
}

this.onEnterFrame = function() {
if (_root.myOutputField == this){
this.myHighlight._visible = true;
}else {
this.myHighlight._visible = false;
}
}

TextFormat Issues
Another short but very sweet question. Here's the code:


Code:
linkText = new TextFormat();
// Set the text to blue
linkText.color = 0x0000FF;
// Below is the line that mucks everything up.
// If you comment it you, everything works,
// except the text in the box just says _level0.txt
this.txt = "Hello";
this.txt.setTextFormat(linkText);


As you can see from the comments, the line:


Code:
this.txt = "Hello"


seems to ignore the advice of the TextFormat and decides to be black rather than blue. Edit the line out, and the text turns blue but just gives a reference to the text variable (_level0.txt).

I never knew bug hunting in 4 lines of code could be so much fun. Anyone got ideas about this?

TextFormat Issues
First time poster so bear with me...

I'm creating a textfield dynamically and populating it with xml data. I'm then applying some formating with the textFormat class using variables also defined in my xml document, kinda like so...

var c2SlashF:TextFormat = new TextFormat();
c2SlashF.font = s2txtFont;
c2SlashF.bold = s2txtBold;
c2SlashF.size = s2txtSize;
c2SlashF.italic = s2txtItalic;
c2SlashF.align = s2txtAlign;
c2SlashF.color= s2txtColor;
this.slash_txt.setTextFormat(c2SlashF);

The problem is when I run the movie, the boolean values (bold and italic) have been ignored. No matter what I define in the xml document, my text remains bolded and italicised!
Has anyone experienced anything similar? and if so, have you found a fix?

Font Issues Using TextFormat
not sure if this is an actionscript board issue or not but Im doing it all dynamicly so hey...

Ok... I am creating an online mockup tool for a T-shirt company
where users can enter their own txt to be printed on the shirts

my problem -- is that the shirts get printed in one of several wierd custom fonts.

my question -- is there a way to load/embed/bundle the fonts they need with my movie so I can format a dynamic textfield using my own font?

Thanks for any input
shoeshine

Font Issues Using Textformat
Ok... I am creating an online mockup tool for a T-shirt company
where users can enter their own txt to be printed on the shirts

my problem -- is that the shirts get printed in one of several wierd custom fonts.

my question -- is there a way to load/embed/bundle the fonts they need with my movie so I can format a dynamic textfield using my own font?

Thanks for any input
shoeshine

[MX04] Html Text Issues
Hi Everyone,

I am rendering some dynamic text fields as html text. The text value has some html tags like <br>,<b>, <font> even <img>....

The problem is everything is working fine even the images are getting loaded. But depends on the specified Dynamic Text fields height i have to create some user controls like chk box, radio btn, input box etc., below to dat textfield.

When loading the img, all the controls are getting loaded b4 the textfields size increased to the size of the image, since it takes some lil time to load the image.
So its luk like the user controls are getting messed up with the text field.

Is there any possibilities to prevent the same. I mean i will have to wait till the image loaded into the text field and then all the controls to be loaded at a desired position. Please tell me if there is any such method to control dat...

HTML Text Rendering Issues
Hi there,

I want to make a pricelist in a html text rendered text field.
I 've got a multi-line textfield with html rendered on with a vert. scrollbar attached.

I want the text on one line to split in left oriented and right oriented :
<b><p align='left'>House for sale, (this should be left) </p><p align='right'>€ 250.000 k.k.(right)</p></b>

when I try this .. the right aligned text is right aligned but on the next line !!!
HELP !!!

the other question i have is how to attach a function call to a mouse click on this text ?
<a href> etc ?



Now i've tried css too , nut not quite succesful

var myCSS = new TextField.StyleSheet();
var cssURL = "propper.css";

//Hard code some HTML text to display (for example purposes)
exampleText = "<b><span class='huis'>MAASTRICHT riante villa met omringende tuin</span>";
exampleText += "<span class='prijs'> € 100.000 k.k </span></b>";

//Load CSS file
myCSS.load(cssURL);
//define onLoad handler
myCSS.onLoad = function(success) {
if (success) {
/* If the style sheet loaded without error,
assign it to the text object, and assign the HTML text to the
text field*/
aanbod.styleSheet = myCSS;
aanbod.text = exampleText; //this should be ".htmlText",
// but Flash seems to recognise that the textbox needs to display html anyway
}
};


anyone have some tips in having left and right aligned on one line ?

Than x!

Jeroen

Scrolling Html Text Issues
I have an up and down button doing scroll functions by using html text. My issue is that when scrolling it moves only one line with each click. As my intent is to have easy usability, I'd like to be able to move by pixel rather than line and do so by being able to hold the button down. Help me!

This is the scripting I have thus far.

info_txt.html = true;

this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20);
this.createTextField("info_txt", this.getNextHighestDepth(), 10, 30, 160, 22);
info_txt.border = true;
info_txt.multiline = true;
info_txt.wordWrap = false;
info_txt.htmlText = " S C H E D U L E <br> <br><b>Week 1. | Introduction: What is an Interface? / class discussion</b> <br>Assignment: select an event, journey or place... <br>what constitutes an event, journey or place?<br>what is significant about the event, journey, or place?<br>what potential information does the event, journey or place reveal?<br>who is the audience? <br> <br><b>Week 2. | Research - Presentation of 3 Proposals</b><br>what are the significant elements of your site?<br>can your observations of your site be categorized into layers?<br>what are the distinct features of each layer?<br>how will you document your site? <br><br><b>Week 3. | Research, Documentation, Final Proposal Testing </b><br>what are the significant non-physical elements of your site?<br>is time an element?<br>is direction an element?<br>is depth an element?<br>is sound an element?<br><br><b>Week 4. | Research, Documentation, Interface Design</b> <br>three sets of sketches representing how your concept can be made visual<br>study interface by time, study interface by location <br><br><b>Week 5. | Presentation 1 - Flash Interface Navigation Test </b><br>three initial proposals for interface in Flash<br><br><b>Week 6. | Interface Navigation, Content Research and Documentation</b><br>explore and refine interface navigation<br>explore and develop Interface content<br><br><b>Week 7. | Interface Prototype</b><br>continue to develop interface navigation and content<br><br><b>Week 8. | Interface Design - CD Package Design </b><br>3 sketch proposals for interface CD package design<br><br><b>Week 9. | Presentation 2 - Interface User Testing</b><br>1 working prototype for user testing<br><br><b>Week 10. | User Testing Results Implementation</b><br>3 sketch proposals for Interface Story Board<br><br><b>Week 11. | Interface Design Refinement</b><br><br><b>Week 12. | Final Interface Finished</b><br><br><b>Week 13. | Design Production Collateral Materials </b><br><br><b>Week 14. | Design Production Collateral Materials</b><br><br><b>Week 15. | Final Presentation</b>"



up_btn.onPress=function(){
if(info_txt.scroll != 0) {
info_txt.scroll--;
}
}

down_btn.onPress=function(){
if(info_txt.scroll < info_txt.maxscroll){
info_txt.scroll++;
}
}

info_txt.border = true;
info_txt.borderColor = 0x000000;
info_txt.background = true;
info_txt.backgroundColor = 0xffffff;
info_txt.textColor = 0x000000;

HELP -- Issues With HTML Text And Flash MX Scrollbars
Hi all,

This is a troubleshooting matter I was hoping someone could answer.
Here's my situation, I have one flash movie, called interface.swf, which loads other pages within iy by page number, 770.swf, 771.swf, 772.swf, and so on...

These pages being loaded consist mostly of text boxes, set as HTML text. Large amounts of text too, probably over 100, in some cases over 200, words per page.

When these pages are loaded into the interface.swf, the interface is set up to load a scrollbar, a Flash MX scrollbar, that fits the appropriate size of the page, which we liked.

However, this scrollbar works rather "clunky" at times, scrolling through text rather slowly. It's not smooth at all, as say a browser window scrollbar. In the case of the Flash MX scrollbar, you click, drag and its a good 6 or 7 seconds before you see anything move at all.
Now my question is, does this have to do with the Flash MX scrollbar? Should I try to make my own from scratch to see if it would work better?

Or is it becasue I'm using text boxes with HTML text (which would suck because we need to use HTML text for this project).

If anyone knows anything, please fill me in.

Thanks
Chris

Issues W/plaintext In Dynamic Html Text Field
I have a text field that I load some text into from an external text file. Because I wanted to do some text formatting on individual strings in the body of the text, I turned on the 'render text as html' option in the text box properties.

My problem is that only the text that has html tags around it shows up, so if i were to load teh string "<b>May 25th</b> is graduation day for seniors at local high school...", only the May 25th would show up in bold, and the rest would be left out.

I tried this:
code:
trace(textFieldName);

AFTER i loaded the string into the text field, and it echoed ALL of the text that it was supposed to, including the text that did not have html tags. it seems that the text box isn't rendering anything that isn't html. anyone have ideas? thanks for your time

Is TextFormat() Like CSS In Html?
Hi,

Just need a quick yes or no. If I define several textFormat objects with say different fonts and colors can you apply these to different text within the same textfield...I'm guessing that if I put text in a text field with format01 and then add more text into the textfield and use format02 that the entire textfield will take on format02.

I don't have time to test this out, so wanted to ask you guys. What I'm looking for is the ability to use the textFormat object somewhat like a cascading style sheet with <span> tags.

thanx,
marcus

Html TextFormat Is Being Wierd
I have some text that is centered, and I am applying a url to it dynamically. the link is then hot(and that is good) but then the entire space to the left of it is hot too.

does anyone know how to get around this?

<textformat> In External Loaded Html?
I want to make a table like item in an externally loaded html file...
This should be possible using <textformat> but this does not seem to work with externally loaded html.

If I use one or more textformat tags it applies the first to the whole textfield and stops displaying everything else after the </textformat>

Options anyone?

Rotate TextFormat (html) Textbox Not Working
Hey guys. I have an html based textbox that i want to rotate lets say 10 degrees but when I do all the text vanishes. I understand you have to embed fonts but this doesn't seem to be working. For instance here is the string I want in the textbox (notice there are bolds and italics). (I had to put spaces near between the < > so you guys can see the html in this post)


_root.textbox.htmlText = '<P ALIGN="CENTER"><FONT FACE="Arial" SIZE="13" COLOR="#000000">< B >< U >The Textbox< /U >< /B ></FONT></P><P ALIGN="CENTER"></P>I am a textbox. < B >< I >Hear me roar!< /I >< /B ></P>'

So everything works great... but now I want to rotate that textbox 10 degrees and when I do it goes blank. Any help would be muchly appreciated!

TextFormat Not Formating My Text... Why?
This is not styling my text. What am I doing wrong?

Thank you!!!


this.textScroll.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 255, 200);
textScroll.my_txt.multiline = true;
textScroll.my_txt.html = true;
textScroll.my_txt.embedFonts = false;
textScroll.my_txt.wordWrap = true;
textScroll.my_txt.autoSize = "left";
textScroll.my_txt.condenseWhite = true;


var tFormat_tf:TextFormat = new TextFormat();
tFormat_tf.bold = true;
tFormat_tf.italic = true;
textScroll.my_txt.setTextFormat(tFormat_tf);


var loadText_lv:LoadVars = new LoadVars();
var textDocPath:String = "../txt/curriculum_vitae.txt";
loadText_lv.load(textDocPath);
loadText_lv.onLoad = function(success) {
if (success) {
// trace(success);
textScroll.my_txt.htmlText = this.myText;
} else {
textScroll.my_txt.text = "Error connecting to server.";
}
};

TextFormat And Tweened Text
has anybody been able to apply a TextFormat object with a change of font to a TextField in a MovieClip that is going to tween? I've been trying without success. What happens is that the symbol disapears if you apply alpha tweens or tweens that "flip" or rotate. However I have noticed some interesting points; Color changes to the TextField and things like bold etc work fine.Its font that causes problems. Also with tweens Scaling works ok as does simple movement. However certain tweens which unfortunately I have to use create problems. My goal for this is to develop a customisable "Text Tweening" Component so any help appreciated because at the moment the user is stuck with the fonts I specify.

TextFormat Not Formating My Text... Why?
This is not styling my text. What am I doing wrong?

Thank you!!!


this.textScroll.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, 255, 200);
textScroll.my_txt.multiline = true;
textScroll.my_txt.html = true;
textScroll.my_txt.embedFonts = false;
textScroll.my_txt.wordWrap = true;
textScroll.my_txt.autoSize = "left";
textScroll.my_txt.condenseWhite = true;


var tFormat_tf:TextFormat = new TextFormat();
tFormat_tf.bold = true;
tFormat_tf.italic = true;
textScroll.my_txt.setTextFormat(tFormat_tf);


var loadText_lv:LoadVars = new LoadVars();
var textDocPath:String = "../txt/curriculum_vitae.txt";
loadText_lv.load(textDocPath);
loadText_lv.onLoad = function(success) {
if (success) {
// trace(success);
textScroll.my_txt.htmlText = this.myText;
} else {
textScroll.my_txt.text = "Error connecting to server.";
}
};

TextFormat And Tweened Text
has anybody been able to apply a TextFormat object with a change of font to a TextField in a MovieClip that is going to tween? I've been trying without success. What happens is that the symbol disapears if you apply alpha tweens or tweens that "flip" or rotate. However I have noticed some interesting points; Color changes to the TextField and things like bold etc work fine.Its font that causes problems. Also with tweens Scaling works ok as does simple movement. However certain tweens which unfortunately I have to use create problems. My goal for this is to develop a customisable "Text Tweening" Component so any help appreciated because at the moment the user is stuck with the fonts I specify.

Problems With TextFormat With Dynamic Text --help
Hello- this seems like it should be so simple. Can someone please tell me what I'm doing wrong. I've got a dynamic text box which calls out to an external text file for it's contents. The text comes in just fine except that it is left justified. I've written some code using TextFormat to try and force it to be centered within the text box but with no luck. I don't understand what's wrong with my code. Any help is appreciated... here's the file - it's zipped because there are 2 files.

thanks
tony

MC W/ Dynamic Text Using TextFormat AS Not Working
Hello,

I was hoping someone could lend a thought on this problem:

I have 3 MCs which have dynamic text property. The 2 instances are completed properly. The site includes a shared library which has one font in it:Georgia. The web page which includes the MCs has the font linked. The font has been set up in the shared library, i.e., "Linkage Property". All 3 options in this property are selected and the url is "sharedlib.swf. (just in case anyone is wondering about the font setup).

The problem is this. I am using the following code to establish submenu activity. When the page is published and opened into the "master" web page, the MCs do not work. The initial text is present, however there is no activity on rollover, rollout, etc.

I have spent several hours reviewing syntax and help sites with no luck.

I would really appreciate anyone's thoughts. Peace.

//Create TextFormat object that defines the states of the sub-menu options

var optionDisable:TextFormat = new textFormat("Georgia", 15, null, true, true);
var optionEnable:TextFormat = new textFormat("Georgia", 13, null, false, false);

// Disable the sub-menu option that corresponds to the currently loaded section
this.AboutUs_MC.myText.setTextFormat(optionDisable );
this.AboutUs_MC.enabled = false;

// -----------<About_Us option>----------------- \
this.AboutUs_MC.onRollOver = function() {
this.myText.setTextFormat(optionDisable);

}

this.AboutUs_MC.onRollOut = function() {
this.myText.setTextFormat(optionEnable);
}
// -----------</About_Us option>----------------- \

// -----------<RMP Staff option>----------------- \
this.RMPStaffMC.onRollOver = function() {
this.myText.setTextFormat(optionDisable);
}
this.RMPStaffMC.onRollOut = function() {
this.myText.setTextFormat(optionEnable);
}
this.RMPStaffMC.onRelease = function() {
this.myText.setTextFormat(optionDisable);
this.enabled = false;
}
// -----------</RMP Staff option>----------------- \

// -----------<Projects option>----------------- \
this.ProjectsMC.onRollOver = function() {
this.myText.setTextFormat(optionDisable);
}
this.ProjectsMC.onRollOut = function() {
this.myText.setTextFormat(optionEnable);
}

this.ProjectsMC.onRelease = function() {
this.myText.setTextFormat(optionDisable);
this.enabled = false;
// -----------</Projects option>----------------- \

My TextFormat Disappears When I Change The Text
I'm making a textfield that shows some messages from my game. Like a console I guess.
However it seems to lose the textFormat I've set for it whenever I change the .text property of the textfield, which is everytime I give it a new message.

The "Loading..." shows in the nice pink verdana it's set to but after that when I change .text it becomes the default size 8 or 9 white font.

I found a way to solve it kinda which is setting the textFormat again after every time I change the text but that seems pretty stupid. Why does it lose the textformat?


Code:
format.color = 0xff00ff;
format.font = "Verdana";
format.bold = true;
format.size = 9;

tfM.textColor = 0xFFFFFF;
tfM.x = 15;
tfM.y = 353;
tfM.selectable = false;
tfM.text = "Loading...";
tfM.width = 300;
addChild(tfM);

tfM.setTextFormat(format);

External Text File And TextFormat
I'm trying to load data from an external text file into a text area and then have it formated according to my specification using textFormat. How do I go about doing so? currently text that is already in the text box gets formatted...not the text that gets imported.

Maximum Text Size For TextFormat
Afternoon everyone,

I am working on an application in which text is created dynamically. I seem to be experiencing a maximum size of 130 when using textFormat. I cannot seem to find any references to this limit. Is there a way to get around it?

So far my only resolution is to create a smaller text field within a movieClip and then scale the movieClip. This moves the text of the pixel location that I need it however.

Any help with this would be very much appreciated.
Cheers,
Michael

TextField + TextFormat => Text Does Not Show Even Though Is There
i am trying to make a function to deal easily with text formatting. there seems to be a problem as the text in the textfield is not visible. all the parameters and attributes are set properly when i trace, i can even copy the text from the textfield, but i cannot see it.


Code:
/**
* Description
* @author Mat Janson Blanchet
* @version 0.1
*/


package {

// imports
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;


// class definition
public class Main extends MovieClip {

// variables


// constructor
public function Main () {

var textfield:TextField = new TextField ();
var text:String = "<p>some paragraph 01</p><p>some paragraph 02</p><p>some paragraph 03</p>";

format (text, textfield, { width:160, height:80, selectable:true, multiline:true, border:true }, false, { font:"_arial", size:16, color:0x000000 } );

addChild (textfield);

}


// events


// functions
public function format (

text :String, // text to display
textfield :TextField, // textfield to target
textfieldParams :Object, // textfield parameters
textfieldIsHTML :Boolean, // whether or not the textfield should display in html
formatParams :Object // format parameters

) :void {

trace ("textfield parameters: ");
// loop through the parameters name and associate the proper value to the textfield
for (var txtfldParamName:String in textfieldParams) {
textfield[txtfldParamName] = textfieldParams[txtfldParamName];
trace (textfield + "[" + txtfldParamName + "] = " + textfieldParams + "[" + txtfldParamName + "]");
trace ("textfield[txtfldParamName]: " + textfield[txtfldParamName]);
trace ("textfieldParams[txtfldParamName]: " + textfieldParams[txtfldParamName]);
}
trace ("textfield: " + textfield)

trace ("");
trace ("format parameters: ");
// loop through the parameters name and associate the proper value to the textfield
var format:TextFormat = new TextFormat ();

for (var fmtParamName:String in formatParams) {
format[fmtParamName] = formatParams[fmtParamName];
trace (format + "[" + fmtParamName + "] = " + formatParams + "[" + fmtParamName + "]");
trace ("format[fmtParamName]: " + format[fmtParamName]);
trace ("formatParams[fmtParamName]: " + formatParams[fmtParamName]);
}
trace ("format: " + format);

trace ("");
trace ("textfieldIsHTML: " + textfieldIsHTML);
trace ("text: " + text);
// input text into textfield
if (!textfieldIsHTML) {
textfield.text = text;
trace ("textfield.text: " + textfield.text);

} else {
textfield.htmlText = text;
trace ("textfield.htmlText: " + textfield.htmlText);
}

textfield.embedFonts = true;
trace ("textfield.embedFonts: " + textfield.embedFonts);
textfield.setTextFormat (format);

}

}

}
does anyone know what i forgot or did not do right? i also enclosed the fla and the as if it helps anyone

Formatting Dynamic Text Using TextFormat
Hi everyone, I've managed to get my data loaded, and as you can see, some bold text courtesy of limited html tags.

I recently came across the "textFormat" object and it's properties, specifically, I want to be able to use the "textFormat.tabStops" property to set custom tab spacing for the dynamic text so that I can create nice clean coloumns of text. Can this be done using this object and property set? If so, what am I doing wrong that it doesn't work?

http://www.sdcooper.com/show_dates.htm


Code:
// Data Loader
loadVarsText = new loadVars();
// Load Data from this file
loadVarsText.load("shows.txt?RND="+random(999));
// Confirm the data is loaded
loadVarsText.onLoad = function(success) {
if (success) {
trace("done loading");
// Data is loaded
// set the Text Field to display as HTML
scroller.html = true;
scroller.multiline = true;
// use TextFormat to set Custom Tab Stops
newsFormat = new textFormat();
newsFormat.tabStops = 6;
scroller.setTextFormat(newsFormat);
scroller.getTextFormat(this.textfield);
// set the Text Field to variable contents
scroller.htmlText = this.textfield;
} else {
trace("not loaded");
}
};
Thanks,
Michael Wisniach
3rd Cherry Designs
www.3rdcherry.com

Another Dynamic Text Problem- TextFormat
OK Sorry about this guys but here goes,

I have created a clock that gets updated every second using the setInterval command.

Now this clock is part of a Bios simulator so my students must be able to change its value.

On most Bios systems when the part of the clock is selected, the type goes a different colour as does its background.

I can simulate the background changing but the textformat gets over-rided by my clock update even though there is no textformatting data in the update.

I know the code is poor but this is the clock update code

ActionScript Code:
addSec = function () {
    MyClock.Sec += 1;
    if (MyClock.Sec == 60) {
        MyClock.Sec = 0;
        MyClock.Min += 1;
    }
    if (MyClock.Min == 60) {
        MyClock.Min = 0;
        MyClock.Hour += 1;
        if (MyClock.Hour == 24) {
            MyClock.Hour = 0;
            MyClock.Day += 1;
            if (MyClock.Day>MyClock.MDays) {
                MyClock.Day = 1;
                MyClock.Month += 1;
                if (MyClock.Month == 13) {
                    MyClock.Month = 1;
                    MyClock.Year += 1;
                    if (MyClock.Year == 100) {
                        MyClock.Year = 0;
                        MyClock.Cent += 1;
                        if (MyClock.Cent=21) {
                            MyClock.Cent = 19;
                        }
                    }
                }
                MyClock.Mdays = MyClock.MonthArr[this.ClockM-1][1];
            }
        }
    }
    trace(MyClock.Hour+":"+MyClock.Min+":"+MyClock.Sec);
    if (MyClock.Sec == 0) {
        ClockSec.theText.text = "00";
    } else if (MyClock.Sec<10) {
        ClockSec.theText.text = "0"+MyClock.Sec;
    } else {
        ClockSec.theText.text = MyClock.Sec;
    }
    if (MyClock.Min == 0) {
        ClockMin.theText.text = "00:";
    } else if (MyClock.Min<10) {
        ClockMin.theText.text = "0"+MyClock.Min+":";
    } else {
        ClockMin.theText.text = MyClock.Min+":";
    }
    if (MyClock.Hour == 0) {
        ClockHour.theText.text = "00:";
    } else if (MyClock.Hour<10) {
        ClockHour.theText.text = "0"+MyClock.Hour+":";
    } else {
        ClockHour.theText.text = MyClock.Hour+":";
    }
    if (MyClock.Day<10) {
        theDayMC.theText.text = "0"+MyClock.Day;
    } else {
        theDayMC.theText.text = MyClock.Day;
    }
    var tempMonth = MyClock.MonthArr[MyClock.Month][0];
    tempMonth = tempMonth.slice(0, 3);
    theMonthMC.theText.text = tempMonth;
    if (MyClock.Year<10) {
        theYearMC.theText.text = "0"+MyClock.Year;
    } else {
        theYearMC.theText.text = "0"+MyClock.Year;
    }
    theCentMC.theText.text = MyClock.Cent;
    var tempYear = theCentMC.theText.text+theYearMC.theText.text;
    theDate = new Date(tempYear, MyClock.Month, MyClock.Day);
    var theDay = MyClock.WeekArr[theDate.getDay()];
    theDay = theDay.slice(0, 3);
    weekdayMC.theText.text = theDay;
};


and this is the changing text colour code

ActionScript Code:
elect = function (targetID) {
    mycolour = new Color(targetID.base);
    mycolour.setRGB(0xFFFFFF);
    mytext = new TextFormat();
    mytext.color = 0x0000FF;
    targetID.btext.setTextFormat(mytext);
};


any ideas

ta
zen

Displaying Text W/ TextFormat And TextField
i have a movie clip named goButton, that executes the drawText method. it works just fine when i input in some text as with the string delimiters " " but i also have an input textfield on the _root that allows the user to input text called myInput. when you click on go for the text to display it just prints out the absolute location _level0.myInput. does anyone know what i am doing wrong. it is suppose to print out what ever the user enters.....
heres all the script which goes on the first frame of the timeline

//movie clip goButton event action
goButton.onPress = function() {
drawText(_root.myInput);
};
input = "DISPLAY THIS TEXT";
function drawText(chars) {
depth++;
numText = 10;
startSize = 100;
textX = 300;
textY = 150;
depth = 1000;
currentColor = 0xff0000;
// --- set text format
myTextFormat = new TextFormat();
myTextFormat.bold = false;
myTextFormat.size = 100;
myTextFormat.color = currentColor;
myTextFormat.italic = false;
myTextFormat.font = "eurostile";
// --- end text format
for (i=1; i<=numText; i++) {
_root.createTextField("text"+i, 500, textX, textY, startSize, startSize);
myTextField = _root["text"+i];
input = myTextField.text;
myTextField.text = chars;
myTextField.border = false;
//myTextField.embedFonts = true;
//myTextField.selectable = false;
myTextField.setTextFormat(myTextFormat);
}
}
drawText(input);

Unable To Assign TextFormat To Text Field
Hi,

I used this same method before and it worked:
Declare a TextFormat , create a dynamic text field and then assign the text format to it.
For some reason this is not working on one of the MC’s on my movie, instead of fancy text I get something that looks like default text format (small times new roman fonts). please tell me what I am doing wrong:


Code:

FormatHint = new TextFormat();
FormatHint.color = 0x0000CC;
FormatHint.bullet = false;
FormatHint.font = "courier";
FormatHint.selectable = false;
FormatHint.size = 12;
FormatHint.align = "left";
FormatHint.bold ="true";

_root.MC.createTextField ("hintTextField", 1, -525,-16.5, 520, 120.5)
_root.MC.hintTextField.setTextFormat(FormatHint);
_root.MC.hintTextField.multiline = "true"
_root.MC.text = “Hello”
thnaks,
LeoBeer

Dynamically Created Text Fields & TextFormat
Can anyone spot where I have gone wrong with the textFormat. The fields answer1 and 2 get created but won't take the answerFormat. They appear as the default settings.

code: //Create stage elements
this.createEmptyMovieClip("container1",1);
this.createEmptyMovieClip("container2",2);
this.createTextField("answer1", 3, 173, 290.4, 310, 150);
this.createTextField("answer2", 4, 173, 101.6, 310, 150);

//Assign properties to stage elements
answerFormat = new TextFormat();
answerFormat.font = "Arial";
answerFormat.size = 18;
answerFormat.bold = true;

with(container1){
_x=30,
_y=250,
attachMovie("salesPerson1", "sales", 1);
}
with(container2){
_x=500,
_y=100,
attachMovie("customer1","customer",1);
}
with(answer1){
multiline = true,
wordWrap = true,
html = true,
embedFonts = false;
}
answer1.setTextFormat(answerFormat);
with (answer2){
multiline = true,
wordWrap = true,
html = true,
embedFonts = true;
}
answer2.setTextFormat(answerFormat);

//Build Arrays
loadText = new LoadVars();
loadText.load("rolePlay1.txt");
loadText.onLoad = function(success){
if(success){
preTextArray = loadText.comments;
textArray = preTextArray.split("~");
}
}

letters = new Array("", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "y", "z");

//Set initial properties and variables
i=0;
container2._alpha = 50;
answer1.htmlText = "Hi, how are you?"


I have read posts and the help section on this subject and it seems like I am doing things the right way, but it won't work.

Thanks for the help.

_t

TextFormat Being Reset When Changing The Dynamic Text
Hello,

I have a countdown running on onEnterFrame at the root level. I also have a button when clicked changes the color of the countdown text. However, when changing the color it flashes to the new color for a split second then back to the original color. If I disable the countdown the color changes like it should. Here is some of the code:

//Countdown is a MC
//CountdownText is an instance name of a dynamic text field inside the Countdown MC

var CountdownFormat:TextFormat = new TextFormat();
CountdownFormat.size = 30;
Countdown.CountdownText.setTextFormat(CountdownFor mat);

this.onEnterFrame = function() {
currentDate = new Date();
currentMillisecs = currentDate.getTime();
this.msecs = eventMillisecs - currentMillisecs;
if (this.msecs <= 0) {
play();
return;
}
this.secs = Math.floor(this.msecs / 1000);
this.mins = Math.floor(this.secs / 60);
this.hours = Math.floor(this.mins / 60);
this.days = Math.floor(this.hours / 24);
this.msecs = String(this.msecs % 1000);
this.secs = String(this.secs % 60);
this.mins = String(this.mins % 60);
this.hours = String(this.hours % 24);
this.days = String(this.days);
while (this.msecs.length < 3) {
this.msecs = "0" + this.msecs;
}
if (this.secs.length < 2) {
this.secs = "0" + this.secs;
}
if (this.mins.length < 2) {
this.mins = "0" + this.mins;
}
if (this.hours.length < 2) {
this.hours = "0" + this.hours;
}
while (this.days.length < 3) {
this.days = "0" + this.days;
}
Countdown.CountdownText.text = this.days + "." + this.hours + "." + this.mins + "." + this.secs + "." + this.msecs;
};

//Clicking the color button fires off this function

function ChangeColor(SwatchColor){
CountdownFormat.color = SwatchColor;
Countdown.CountdownText.setTextFormat(CountdownFor mat);
}

If I comment the last line of the onEnterFrame function it changes the color. If I don't it changes for a split second then resets.

Any help would greatly be appreciated.

Thanks,
Steve

Variable Property For A Dynamic Text And TextFormat
I am applying a textformat to a bunch of dynamic text fields. The problem is that doing this involves an ugly for loop. Anyway, I noticed that as I highlighted all of my textfields there was still the var property so I was wondering if I can select all of my textfields that I want to apply my textformat to, give them a variable name of say txtGroup and then say txtGroup.setTextFormat(something);
This doesn't work when I tested it, but is there a way to do it like this. Does anybody know if this works or is this a pipe dream?

Thanks.

Add Text Within Textfield At SelectionBeginIndex, Without Losing The TextFormat
Hi

I am trying to insert a special character (such as Delta) within a textfield. I can use selectionBeginIndex to find the position to add the text. However, I can't find a way to add the character to that point in the textfield? At present I have the following code:

startofText = tf.text.substr(0, cursor) + newText;
// this gets all text up until the point of which to insert the new character or word. I then add the additional text (newText)

remainingText = tf.text.substr(cursor+Math.ceil(sym.length),tf.tex t.length);
// this variable stores the text remaining after the new character or word.

tf.text = startofText + remainingText; //
I then add the two strings together to complete the new string, which includes the new character or word at the point the user click or selected using selectionBeginIndex.

The problem with this method is that I lose all formatting gained from the following code:

tf.setTextFormat(Super, startNum, endNum);

Because the string is new it wipes out any formating I had in place. Is there a way to add a character or word to a textfield without replacing the whole string and losing my formatting?

Thanks

Font Property Of Flash.text.TextFormat
The font property of flash.text.TextFormat is defined as a string.


ActionScript Code:
var tf:TextFormat = txt1_ui.getTextFormat(s,e);
Dumper.info(tf.font);
tf.font = tf.font+"---";
Dumper.info(tf.font);

the output:
King's Ransom Light
King



ActionScript Code:
var str:String = "King's Ransom Light";
var tf2:TextFormat = new TextFormat();
tf2.font = "King's Ransom Light";
Dumper.info(str);
Dumper.info(tf2.font);

the output:
King's Ransom Light
King

I assume something funny is going on in the TextFormat set method, but I don't have access to that. This has been an infuriating two hour odyssey thus far.

Using TextFormat() On Dynamic Text Instance Within A Button
I've created a button with instance btn_On on stage in the main timeline. The text "On" in the button's timeline in the Up state is dynamic with instance txt_On. I'm having trouble changing the text's properties as I can't navigate to it using dot syntax. I've created a simple trace() statement to see if txt_On is recognized using the code below, but the Output window says "undefined." How do I get this to work?

trace(btn_On.txt_On);

To change the color of txt_On in the Up state of btn_On, I use the following code, but it does not work:









Attach Code

var myTextOn:TextFormat = new TextFormat();
myTextOn.color = 0x000000;
btn_On.txt_On.setTextFormat(myTextOn);

[FMX04] HELP For TextFormat And Input Text Fields
Can anyone help with this? I am trying to create a TextField, set its type property to "input," set its format via the TextFormat object, and allow the user to add a label to a movieclip.

Assume you have a button named b_add, and you assign it this code on the main timeline:




Code:
_root.b_add.onRelease = function () {_root.createTextField("myLabel", 10, -38, -15, 76, 29.7);

_root.myLabel.type = "input";
_root.myLabel.text = "insert label";
_root.myLabel.wordWrap = true;
labelFormat = new TextFormat("Verdana", 10, 0x525252);
labelFormat.align = "center";
_root.myLabel.setTextFormat(labelFormat);
Selection.setFocus(_root.myLabel);

}

The TextField that gets created loses all of its formatting once the user starts typing. It reverts to Time New Roman and doesn't wrap. Do I have something out of order? Should I approach the problem with another solution?

Textformat: New Input Text Isnt Formatted
I've applied a textFormat to an input Field, which I created dynamically. Everything is just fine, except if the user clicks onthe field and adds text to the end of it, the formatiing does not apply to the new text. It does apply to text added in the middle of already formatted text. It seems like the formatting is not applied to the field, but to the text that happens to be in the field when you apply the formatting. Is there a way around this? Thanks.

Dave

[FMX04] HELP For TextFormat And Input Text Fields
Can anyone help with this? I am trying to create a TextField, set its type property to "input," set its format via the TextFormat object, and allow the user to add a label to a movieclip.

Assume you have a button named b_add, and you assign it this code on the main timeline:




Code:
_root.b_add.onRelease = function () {_root.createTextField("myLabel", 10, -38, -15, 76, 29.7);

_root.myLabel.type = "input";
_root.myLabel.text = "insert label";
_root.myLabel.wordWrap = true;
labelFormat = new TextFormat("Verdana", 10, 0x525252);
labelFormat.align = "center";
_root.myLabel.setTextFormat(labelFormat);
Selection.setFocus(_root.myLabel);

}

The TextField that gets created loses all of its formatting once the user starts typing. It reverts to Time New Roman and doesn't wrap. Do I have something out of order? Should I approach the problem with another solution?

Trouble Formatting Text With TextFormat Method
Hi there,

I'm loading in data from an XML file and then creating indivdual text fields for each piece of data.

I'm then trying to format the style of the data using the TextFormat method, but for some reason the text stays un-formatted and it's driving me nuts as I (typically) have a urgent deadline to get this sorted.

Any help would be appreciated, my code is below.

Many thanks.

M.

Code:

// create loader object for loading the tickertape XML
var loader:URLLoader = new URLLoader(new URLRequest("ticker.xml"));
loader.addEventListener(Event.COMPLETE, xmlDownloaded);

// this will be instantiated and duplicated for each item
var tf:TextField;

// set TextField's format properties such as font colour, size, weight
var myFormat:TextFormat = new TextFormat();      
myFormat.font = "Arial";
myFormat.color = 0x0000FF;
myFormat.size = 20;

// this will keep track of the position of the article links
var pos:int = 0;

function xmlDownloaded(e:Event):void
{
   // store the loaded XML data
   var xmlData:XML = new XML(e.target.data);

    //trace(xmlData.article.length());
   
   for each (var item:XML in xmlData.children())
   {
      createLink(item.title, item.url)
    }
   
   for each (var item:XML in xmlData.children())
   {
      trace(item);
    }
}

function gotoURL(e:MouseEvent):void
{
   var url:URLRequest = new URLRequest(e.target.name);
   navigateToURL(url,"_self");
}

function createLink(t,u):void
{
   // create a new TextField that will act a link for the current article
   tf = new TextField();
   tf.name = u;
   tf.text = t;
   tf.autoSize = TextFieldAutoSize.LEFT;
   tf.background = true;
   tf.backgroundColor = 0xff00ff;
   tf.x = pos;
   
   // assign the above formatting to the text field
   tf.defaultTextFormat = myFormat;
   
   // add the TextField to the display list
   addChild(tf);
   
   // add event listener to trigger function when story is clicked on
   tf.addEventListener(MouseEvent.CLICK, gotoURL);
   
   // increase the position for each TextField
   pos += tf.width + 10;
}

Fla Ti Html Issues
Hi,
Hope alls well.
When i turn my flash project into html and run it on my browser it runs perfectly, it even runs fine on Dreamweaver, but when i upload it on to my domain (index.html) the browser loads forever but does not display the contents, what could be the problem.

Thanks mate.

HTML Issues. Help Me
Just when I thought I was getting the hang of this…

I recently designed a few web sites and feeling bold, put some cool Flash menus I made on them. Everything works fine when I use Mozilla Firefox, but when I viewed the sites with IE, my Flash movies were all gone! Only blank white spaces appeared where the .swf files should’ve been.

I can only guess that the HTML containers I’m using are wrong. I work with Front Page 2000 and Flash MX. (Everything displayed correctly when I previewed the sites with Front Page)
Can somebody tell me how to do this or point me to some tutorials?
Appreciate it guys!

Html FPS Issues
Is there a way to have html files use the correct framerate for swf files?

The html seems to run the framerate differently from the swf files and trying to increase it in the flash document doesn't work.




If not, is it possible to control a SWF's window properties through action script? As in, have it keep a fixed size and disable window enlargement?


If so, how?

HTML From XML Issues- Bug?
I'm working on a little XML fed news ticker. I've come up against an 'oddity'

If I use AS to create my text field


Code:
var body:TextField = new TextField();
this.addChild(body);
none of the HTML tags in the XML that would cause a line break, br or p tags, seem to have any effect. It's like they don't exist.

But if I draw the dynamic text field on the stage (and remove the code above) and name it 'body' those HTML tags do create the needed line breaks.

Is this a bug? Or (more likely) am I doing some thing wrong along the way?

THanks

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

HTML And SWF File Issues
I have a navigation menu done in Flash with 8 separate expanded sub menus. Each is a different SWF file. I finally got my SWF files to look good but for some reason when it is published in my Dreamweaver site the menus don't match my SWF files. I finally figured out that it is the HTML files that are causing the problem but I am not sure how to fix it. If I use gotoAndStop the SWF files look OK but the HTML files are messed up. If I use gotoAndPlay the HTML file looks fine but all 8 menus are played before it stops on the correct one. Anyone out there know how to fix this. I can provide examples if needed. Thanks.

Issues Viewing Swf In Html.
Hi all,

My problem is as follows: I have developed a flash website and published it into a html file using standard MX2004 publish settings. Everything works as usual no problems on my pc. When the site is uploaded to my server, a standard html file will work ok, but any html with flash embedded will not display. I have published the file as flash player 6.0.0 and above compatible, I have flash player 8.0.22 installed. I have tested this using IE,

BG INFO
The flash movie loads several external swf files (one of them being a preloader used a few times and as such set to export for runtime sharing) and I have checked all the referencing for each, including using the full domain path name http://... yet it is still unviewable. Where all other browsers fail, using Firefox I can view the initial swf file however it then fails to load any other swf files when the appropriate link is selected.

You can view the problem at www.lukebrown.com.au/test/index.html

Is this possibly a problem with the html embed tags or am a failing to see an easier explanation elsewhere. As usual the hosting server's tech assures me its my problem not theirs. If the source files can help I will post them on request.

Any help would be greatly appreciated.

HTML Rendering Issues
Hi,
I've got a textfield that i've put together, which uses html content.

I've found that... it seems that flash will not render html tags unless they are followed by a line break. For example:

<ul><li>item1</li><li>item2</li></ul>
renders as:
item1item2

Putting line breaks before the <li></li> items will cause the list to render as a bulleted. The same also seems to be true with line breaks, paragraphs, and just about anything else I've tried.

This is making a bit of mess of things for me, as a lot of the content I'm displaying is concatenated strings, which are generated dynamically. In my code, I have to append each tag with a chr(13) line break.

Is this just the way it is, or is there some setting I'm missing that will parse the html correctly without the line breaks?

Flash & HTML Issues
Hi I got a question which is Flash and HTML related.

I have a swf file in a HTML file and the swf file is called in from a folder foldername>flash.swf

and the HTML is in the root.

The flash.swf has buttons which has loadmovienum action on it. Those respective swf files are in the foldername dir.

The problem is when I open the HTML and when I click the button on flash.swf its not calling the loadmovie files which is strange to me!

Can you please help.

Thanks

Issues With TextFormats And Html Fields
I'm attempting to make a widget that lets someone entering text change the styles of what they are entering. I was excited to find the textFormat options that allow me to accomplish this much easier that Flash 5, but I'm running into some issues that seem to be a flawed model that MX is using.

http://www.psychokinetic.com/experiments/fieldEdit.html

1) <b>Flash text looks to the char after the cursor to get style for new text</b>
This is a minor thing, but a userwouldn't expect it to work like that, and I see no way of convincing it to do otherwise...

2) <b>Styles dynamically applied to the field do not show up in the html unless the user types in the field.</b>
This sucks because if the user makes a word bold, the html I get doesn't reflect it. If I start typing somewhere in the field, the html will then appear. Try the show button to see what I mean. (make something bold, click show, then type somewhere in the field, then click show again)

Anyone have any ideas? My next step is to use the XML functions to help me clean up the html so I can store it in a database.

M@

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