Action Script 3 TextArea Component in IntellijIdea - actionscript-3

I need TextField with scroll. I've found example: https://help.adobe.com/ru_RU/FlashPlatform/reference/actionscript/3/fl/controls/TextArea.html#htmlText
First error was fl.controls not found.
I`ve added "d:\Program Files\Adobe\Adobe Animate 2020\Common\Configuration\Component Source\ActionScript 3.0\User Interface\" folder as source.
After that if I run example:
package {
import fl.controls.TextArea;
import flash.display.Sprite;
public class Test_AdobeAnimateComponents extends Sprite {
public function Test_AdobeAnimateComponents() {
var myText:String = "";
myText += "<p>You can use the <b> tag to create <b>bold</b> text.</p>";
myText += "<p>You can use the <i> tag to create <i>italic</i> text.</p>";
myText += "<p>You can use the <u> tag to create <u>underlined</a> text.</p>";
myText += "<p>You can use the <a> tag to create <a href='http://www.adobe.com'>links to other sites</a>.</p>";
myText += "<p>You can use the <br> tag to create<br>new lines of text<br>whenever you want.</p>";
myText += "<p>You can use the <font> tag to specificy different font <font color='#FF0000'>colors</font>, <font size='16'>sizes</font>, or <font face='Times New Roman'>faces</font>.</p>";
myText += "<p>You can use the <img> tag to load images or SWF files:<br><img src='http://www.helpexamples.com/flash/images/logo.png'>.</p>";
var myTextArea:TextArea = new TextArea();
myTextArea.setSize(320, 100);
myTextArea.move(10, 10);
myTextArea.htmlText = myText;
addChild(myTextArea);
}
}
}
Error is now in drawLayout() of TextArea.as: background is null. It's because previous drawBackground() wants to find "upSkin". In defaultStyles upSkin is "TextArea_upSkin". Looks like I need some graphic file also.
"d:\Program Files\Adobe\Adobe Animate 2020\Common\Configuration\Component Source\ActionScript 3.0\User Interface\ComponentShim.fla" in same folder doesn't helped.

Related

ASP-DropDownList CodeBehind images

All I ever wanted is my DropDownList to be special. :(
I can write just names, but that won't be as intresting. So I tried to add images, like so:
// Somewhere in the code...
ListItem item = new ListItem();
item.Value = // something
item.Text = "<img src=\"" + <AnImagePathIGetFromTheDatabase> + "\">";
<MyDropDownlist>.Items.Add(item);
However the evil thing escapes the text in a list automatically, like so:
<img src="https://41.media.tumblr.com/bcb96f4a4c46a1001118ee216d7abacf/tumblr_mgfhbngsDl1r58qimo1_500.png">
So I get text instead of an image. How can I overcome this?
EDIT: Using Lajos' solution, I've got to a situation where I inspect the selection element, And I get the following :
<img src="http://i.somethingawful.com/u/robtg/Fiesta/f05.jpg" alt="monster" height="42" width="42">
Which is pretty much what I was looking for. Sadly, in the page source, I get the following:
<option value="MeaninglessImp" class="imageconverter">http://i.somethingawful.com/u/robtg/Fiesta/f05.jpg</option>
The list itself shows 2 empty cells. The inspector says the pictures have been scaled down to 0x0.
Fiddle: here.
Why does that happen?
You can set the Text to contain the source and not show them until the page is loaded. You can implement a Javascript library which replaces src text with images in your list. That should solve the problem.
// Somewhere in the code...
ListItem item = new ListItem();
item.Value = // something
item.Text = <AnImagePathIGetFromTheDatabase>;
listItem.Attributes.Add("class", "imageconverter");
<MyDropDownlist>.Items.Add(item);
And in Javascript you need something like:
$(function() {
$(".imageconverter").each(function() {
$(this).html('<img src="' + $(this).text() + '">');
});
});

Showing html text in FlowDocumentReader

I have a FlowDocumentReader control in my application.
<FlowDocumentReader Document="{Binding FlowDocument}" Style="{DynamicResource FlowDocumentStyle}" />
And here's how I set the text to the FlowDocumentReader:
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some <b>book</b>");
FlowDocument.Blocks.Add(paragraph);
The problem is that 'book' isn't shown like html, the tags are visible in the wpf application.
I tried using this converter:
http://code.msdn.microsoft.com/windowsdesktop/XAML-to-HTML-Conversion-ed25a674/view/SourceCode
but then the text shown in my wpf application looks like this:
<FlowDocument xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph>some <Run FontWeight="bold">book</Run></Paragraph></FlowDocument>
and again it's not bold. How can I do this?
Use UI Elements to show formatted text and them to InlineUIContainer of Paragraph.
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("some");
Label lb = new Label();
lb.FontWeight = FontWeights.Bold;
lb.Content = " Book";
paragraph.Inlines.Add(new InlineUIContainer(lb));
this.Doc.Document = new FlowDocument();
this.Doc.Document.Blocks.Add(paragraph);

img tag is not working properly in actionscript3 TextField

I have a TextField.
Here is a snippet:
this.textField = new TextField();
this.textField.defaultTextFormat = font.format;
this.textField.selectable = true;
this.textField.border = true;
this.textField.wordWrap = true;
this.textField.multiline = true;
And here is the method to add new line to the textField box:
this.textField.htmlText = 'some text <IMG SRC="http://gravitatestudio.com/wp-content/themes/gravitate/images/facebook.png">';
The issue is that an image is always placed UNDER text instead of the END OF THE TEXT.
Here is the trace(this.textField.htmlText) after html text has been added:
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">some text <FONT SIZE="2"><IMG SRC="http://gravitatestudio.com/wp-content/themes/gravitate/images/facebook.png"> </FONT></FONT></P>
Also I need to add an image to any side of the text like a chat message using smiles (left, middle, right side of the text).
Any suggestions?
TextField html text is very limited and thats why Adobe released TLFTextFields which will give you much more control over the layout of elements in the field. I have personally used it and have made entire chats out of one textfield with images, links etc.
resource:
adobe: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/text/TLFTextField.html
tutorial:
http://flashsimulations.com/2010/09/10/handling-image-loading-in-tlf-textflow-and-textfield/

How to convert Html text into normal plain text?

I have html text which is coming from backend and i need to convert it into normal text to show up in TextArea.
Is there any way to convert Html text into normal plaintext by usingFlex framework`?
You will have to use Regexp to remove tags.
From here:
var myString:String = "<p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>";
trace(myString)
var removeHtmlRegExp:RegExp = new RegExp("<[^<]+?>", "gi");
myString = myString.replace(removeHtmlRegExp, "");
trace(myString);
// OUTPUT
// <p><b>bold</b> <i>italic</i> <a href='#'>link</a> <br>linebreak</p>
// bold italic link linebreak
In case I got you wrong and you want to display HTML tags in textarea, use escape() function

How to assign a class property to textarea tag?

I have a text area tag, wanted to write water mark functionality. So, i have assigned a class (css) to that tag. but it is not getting recognised. if i write css style for the textarea ID it is working.
function renderhtml(subgrid_id, row_id) {debugger;
var script = "<div style='margin-left:10px; margin-top:10px; margin-bottom:10px;'>";
script += "<textarea cssClass=watermarkOn cols=20 id=txtCommentSection name=txtCommentSection rows=2>Type your comments here</textarea>";
script += "<input type='image' id='image' src='../../Content/Images/commentIcon.png'/>";
script += "</div>";
return script;
}
This is the css style:
.watermarkOn{color: #CCCCCC; font-style: italic;width:800px; height:30px; }
i have tried changing the class from "cssClass" to just "class" but still the style is not getting affected.
Please help.
This line is the culprit.
script += "<textarea cssClass=watermarkOn cols=20 id=txtCommentSection name=txtCommentSection rows=2>Type your comments here</textarea>";
It should be:
script += '<textarea class="watermarkOn" cols=20 id="txtCommentSection" name="txtCommentSection "rows=2>Type your comments here</textarea>';
Use textarea class="watermarkOn" instead of textarea cssClass=watermarkOn