Content by using AntiAliasType.ADVANCED; - actionscript-3

We are using following code for displaying html text in a dynamic classic text field.
var txtFld = new TextField();
txtFld.x = 10;
txtFld.y = 0;
txtFld.wordWrap = txtFld.multiline = true;
txtFld.width = 1190;
txtFld.autoSize= "left";
txtFld.embedFonts = true;
txtFld.antiAliasType=AntiAliasType.ADVANCED;
txtFld.htmlText = (Dynamic text);
If using "Normal" AntiAliasType instead of Advanced then everything is working fine. But text quality of application is not good, so i have used "AntiAliasType.ADVANCED" to make the text quality better.
We are getting lots of problem by using "AntiAliasType.ADVANCED" like visibility of text with long text, not able to embed the "GGSubscript" font etc.
Also if I user flash player version 10.3 or above then the text is also visible but the fonts are not embedded in it.
I have tried number of flash player version. Please suggest if this can be correctly some how.
Thanks,
Ashmesh Thakur

Related

[UWP][C#] Adding text to RichTextBlock

First of all I am completely new into both XAML and C#, so please forgive me for some stupid errors. An explanation is much more appreciated.
I've been struggling this last hours trying to figure out one of the simplest things: how to add text to a RichTextBlock when a button is pressed. I've tried some solutions that I found on Internet but none of them actually worked.
In particular it seems like there aren't the necessary references. For instance VS does not recognize the following code : Run myrun = new Run(); nor Paragraph mypar = new Paragraph(); or myrichtextblock.document.
What am I missing?
Check this example:
Taken from MSDN documentation
https://msdn.microsoft.com/library/windows/apps/br227565
// Create a RichTextBlock, a Paragraph and a Run.
RichTextBlock richTextBlock = new RichTextBlock();
Paragraph paragraph = new Paragraph();
Run run = new Run();
// Customize some properties on the RichTextBlock.
richTextBlock.IsTextSelectionEnabled = true;
richTextBlock.TextWrapping = TextWrapping.Wrap;
run.Text = "This is some sample text to show the wrapping behavior.";
richTextBlock.Width = 200;
// Add the Run to the Paragraph, the Paragraph to the RichTextBlock.
paragraph.Inlines.Add(run);
richTextBlock.Blocks.Add(paragraph);
// Add the RichTextBlock to the visual tree (assumes stackPanel is decalred in XAML).
stackPanel.Children.Add(richTextBlock);
Just see how to add text in this example and modify the code to put inside of your click event of your button
Please mark this answer if it's useful for you!
Best Regards!

Japanese text in TextField with embedded font

In my ActionScript 3 project I use TextField with embedded font set to true and isHTML set to true. Everything works fine when I display latin characters.
But when I want to display Japanese characters they do not appear. Actually it is expected to be like this because Japanese font is not embedded.
Is there is a way to fall back to system font if embedded font doesn't have glyphs for certain characters?
Try to use hasGlyphs("..."); on a Font instance. I had some problems with it but in general it works alright, hopefully it works for Japanese too. Then you can simply use _sans if there is no japanese glyphs.
Edit:
I have no way to test this now but I assume something like this would work:
import flash.text.Font;
var myFont:Font = new MyFont(); // Embedded font in library, linkage set to 'MyFont'
if(myFont.hasGlyphs("Hello!")) {
field.embedFonts = true; // Not sure whether this is necessary in case of HTML text
field.htmlText = "<p><font color='#ff0000' face='" + myFont.fontName + "'>Hello!</font></p>";
}
else {
field.embedFonts = false;
field.htmlText = "<p><font color='#ff0000' face='_sans'>Hello!</font></p>";
}

How to manage size of image assets in mobile apps with ActionScript?

Due to screen density of iPhone, image assets are developed larger. So, when specifying the icons and images to Flex components takes this form.
<s:ViewNavigator id="tab1" label="Tab1 width="100%" height="100%" firstView="views.Tab1">
<s:icon>
<s:MultiDPIBitmapSource source160dpi="#Embed('assets/tabIcon.png')"/>
</s:icon>
</s:ViewNavigator>
Flex of course renders this correctly and adjusts the size to what it should be.
However, when I load images myself, they appear blown up as they would appear double in size.
This is how I use it when overriding the tab bar.
public class TabbedViewNavigatorTabBarSkin extends ButtonBarSkin
{
[Embed (source="/assets/tabBar.png" )]
private var TabBarPng:Class;
override protected function createChildren():void
{
var bgb:Bitmap = new TabBarPng() ;
addChild(bgb);
}
}
This is when the image appears blown up. What am I doing wrong?
Well I think what you're trying to get it to do can be achieved with the following code, this is basically going to negate the work done internally to scale the asset based on the screen size, while allowing it to scale other components based on the DPI, I'm not sure exactly how this will play out in practice.
import mx.core.mx_internal;
...
var bgb : Bitmap = new TabBarPng();
bgb.scaleX = 1 / systemManager.mx_internal::densityScale;
bgb.scaleY = 1 / systemManager.mx_internal::densityScale;
or another possibility I think is:
var mul : MultiDPIBitmapSource = new MultiDPIBitmapSource();
mul.source160dpi = new TabBarPng();
var bgb : BitmapImage = new BitmapImage();
bgb.source = mul;
var gr : Graphic = new Graphic();
gr.width = 100 / systemManager.mx_internal::densityScale; //not sure if you'd want densityScale being applied here or what? Same below just a matter of testing on more devices
gr.height = 100 / systemManager.mx_internal::densityScale;
gr.addElement(bgb)
addChild(gr);
[From MultiDPIBitmapSource API doc]
This class provides a list of bitmaps for various runtime densities. It is supplied as the source to BitmapImage or Image and as the icon of a Button. The components will use the Application.runtimeDPI to choose which image to display.
I think this documentation:
http://help.adobe.com/en_US/flex/mobileapps/WS19f279b149e7481c682e5a9412cf5976c17-8000.html
is probably still the clearest explanation you'll find though it's not entirely clear how this will affect the application at run-time on different devices. The best option is to just test on as many devices as you can (or need to support).

AS3 Not Adding Sprite to MovieClip

My code is simply looping through an xml file and creating 'pages' (which are later animated).
This has all worked fine but now I want to add a sprite over the entire contents of the page if the contents of the xml contain a URL.
At run-time I can see that the checks for the URL are being processed correctly and that the overlay is being generated, but I cannot "see" it on the page.
The following code is located in a for loop for every page in the xml file:
var page:Page = new Page(); //MovieClip in my library
// ... other stuff
var textMC:FadeText = new FadeText(xml); //load the text from the xml fragment for this page
//if the text contains a URL (using RegExp)
if(textMC.hasLink())
{
var button:Sprite = new Sprite();
button.graphics.beginFill(0x000000);
button.graphics.drawRect(0, 0, 1, 1);
button.name= textMC.getLink();
button.x = button.y = button.alpha = 0;
button.width = rectangle.width;
button.height = rectangle.height;
button.buttonMode = true;
button.addEventListener(MouseEvent.CLICK, goToUrl, false, 0, true);
page.addChildAt(button, page.numChildren);
}
//... more code - such as add page to stage.
From the console (using FireBug and FlashBug) the button is being created, but I cannot see it on screen so I am guessing the addChild bit is at fault.
What is wrong and how do I fix it?
[edit]
Having set the alpha to 1 I can see that the overlay IS being added to the page, but it is not changing my cursor or responding to mouse clicks.
I now believe it is something wrong with the XML. It is correctly parsed XML (otherwise FlashPlayer would throw exceptions in my face) and it appears that this code works on every page except the second. Further more, if the second page is set as visible (a flag in the XML determins if the page is created or not) then none of the other pages overlay works.
Sorry to necro this thread but one thing I can think of is that because you specify a z-position to place your page it might be that the z-position generated by (i+1) is not the next one in line. AS3 doesn't allow display-objects to be placed on 'layers' with empty 'layers' between them which was allowed in AS2.
My guess is that during the loop at one point or another the loop doesn't generate a page which leaves an empty layer. The reason why the stage.addChild(page) actually works is because it simply searches for the next empty layer in that stack because you don't specify it.
button.x = button.y = button.alpha = 0;
set alpha to 1
button.alpha = 1;
and check for rectangle.width , rectangle.height
last thing, check for textMC.hasLink() if its true or not. If its true, there is another problem with your code that is not related to this sample code.
Illogical answer:
Replaced stage.addChildAt(page,i+1); with stage.addChild(page);.
I was clutching at straws. Have spent FAR too long working on this blip, but it works! I don't know WHY it works, and at this point I don't care; IT WORKS!!! (sorry for the unprofessionalism however I have spent two and a half days working on this and have just got it working!)
If someone wants to explain why it works, feel free. I would VERY much prefer to learn why this occurs that struggle to work around it.

Can't embed multiple fonts and use them in same textfield - cs5, as3

having a bit of trouble getting embedded fonts to work. The inconsistency with this is driving me crazy. I've gotten this to work before but not since going to cs5.
My set up is as follows:
I have a dynamic textfield on stage named "tf".
The following code populates the textfield and attempts to style one word, "love" in the sentence with a different font.
_style = new StyleSheet();
var styleObj = new Object();
styleObj.color = '#FF0000';
styleObj.fontFamily = 'Futura Bold Oblique';
_style.setStyle('.otherText', styleObj);
tf.styleSheet = _style;
tf.htmlText = 'I <span class="otherText">love</span> it when stuff works!';
The font is embedded and set to export for actionscript with the export name Font1. The word "love", which is supposed to be displayed as the font Futura Bold Oblique just disappears. It makes no difference if I use the font screen name listed in the properties panel for that font or if I use the export instance name I gave it.
My sentence looks like : I it when stuff works! As you can see, "love" is gone. Come on people, show me some love! lol.
Anyone have an idea why this isn't working. This is highly essential to my daily work and its driving my crazy!! Thx!
I have been playing around with this since posting, hoping that maybe that specific font was causing the trouble, but its not the font. I tried using different styles of Helvetica Neue as separately embedded fonts and got the same result.
Fixed it, sort of. using enumerateFonts. This lists the fonts' names as Flash sees them. Copy and paste from the output window, and use that for the stylesheet fontFamily property. It still seems that Flash thinks some different styles from the same family, like Futura Bold and Futura Bold Oblique are the same; in my case it listed them both as Futura Book. In order to get the Oblique text in there I had to embed two separate versions of the font, Futura and Futura BT.
private function getFontNames():void
{
var fontArray:Array = Font.enumerateFonts(false);
fontArray.sortOn("fontName", Array.CASEINSENSITIVE);
for(var i:int = 0; i<fontArray.length; i++)
{
trace(fontArray[i].fontName);
}
}