alpha & rotation issue for textArea with htmlText
September 28, 2009 at 10:01 AM | In Adobe, Flex / AS, Programming | 1 CommentTags: alpha, bug, embed, flex, font, htmltext, limitation, rotation, sdk, textarea
I had been playing with this for one of a project requirement.
Description of scenario:
- Embedded fonts ‘Times New Roman’ both, using default font manager (Batik) as well as AFE
- The application consists of two text area components
- For 1st textarea, I am setting text using ‘text’ property and setting font family, size and color using setStyle().
- For second, I am providing text related information via ‘htmlText’ property.
- Using a slider I should be able to change alpha value of both textArea components.
Behavioral problems:
- When I change value using slider, the alpha effect is applied and visible for 1st textarea, but in case of second, alpha value gets applied but text has no visible impact of alpha.
- When I rotate both textArea components using, 1st gets rotated, but not second. In case of both textareas, I am referring and using embedded font only. (font family ‘TNR’ in example)
I expect both textAreas behave identical.
As far as I know and received primary feedback from a famous flexer guy, my code is right. If I consider this, there is definitely a limitation / bug in flex SDK. Hence I suggested a new task in SDK.
Here is a code I had written to simulate the SDK limitation / bug:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Style>
@font-face
{
src: url('/assets/fonts/times-new-roman.ttf');
fontFamily: "TNR";
font-weight:normal;
font-style:normal;
advancedAntiAliasing: true;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.SliderEvent;
private function init():void
{
basicTxt.text = "This is a sample text!";
}
private function onChange(event:SliderEvent):void
{
basicTxt.alpha = event.value;
htmlTxt.alpha = event.value;
}
private function doRotate(event:MouseEvent):void
{
basicTxt.rotation = 20;
htmlTxt.rotation = 20;
}
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:HBox width="70%" height="50%">
<mx:TextArea id="basicTxt" width="80%" backgroundColor="blue" fontSize="36" height="100%" fontFamily="TNR"/>
<mx:TextArea id="htmlTxt" width="80%" backgroundColor="blue" height="100%">
<mx:htmlText>
<![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="TNR" SIZE="36" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is a sample text!</FONT></P></TEXTFORMAT>]]>
</mx:htmlText>
</mx:TextArea>
</mx:HBox>
<mx:HSlider minimum="0" maximum="1" value="1" change="onChange(event)" />
<mx:Button label="Rotate" click="doRotate(event)" />
</mx:VBox>
</mx:Application>
I will appreciate if anyone can give some ideas / pointers to work around.
Flex application & new fonts
June 30, 2009 at 5:21 PM | In Flex / AS, Internet, Programming | Leave a CommentTags: dynamic font, embed, flex, font, recompile, swf
A typical requirement was to provide some means so that anyone can upload / add new font(s) and the same can be used by Flex application. The Flex project should not require recompilation process.
Font, as a TTF or FON file cannot be used unless embedded, but that requires recompilation.
Searching around net gave me a way to solve this gave me a reasonable good solution.
Instead of specifying external styles such as <mx:Style source=”assets/styles/fonts.css”/> I used StyleManager.
Any change in fonts.css requires project recompilation to get the change in effect.
So, I compiled fonts.css using mxmlc fonts.css . This compiled CSS to SWF.
Then I loaded fonts at runtime using StyleManager.loadStyleDeclarations(“fonts.swf”, true, true);
And that’s it….! The font(s) inside fonts.swf can be used and that gives the same effect as embedded.
Font transcoding error – specify font style
February 5, 2009 at 11:46 PM | In Flex / AS, Programming | 1 CommentTags: css, embed font, embedded font, flex, font, font-style, transcode, transcoding error
Flex SDK has rich set of font managers. Those 3 (Batik, AFE, JRE) manage and transcode to flash player fonts.
However, using following code in CSS caused comile time exception.
“exception during transcoding: Font for alias ‘Arial Bold’ with plain weight and style was not found at…”
@font-face
{
src: url('/assets/fonts/arial-bold.ttf');
fontFamily: "Arial Bold";
}
@font-face
{
src: url('/assets/fonts/arial-bold-italic.ttf');
fontFamily: "Arial Bold Italic";
}
The perfect solution that I could find was that I also need to specify font weight & style in CSS, as per the type of font, I am embedding.
Here is the perfect solution:
@font-face
{
src: url('/assets/fonts/arial-bold.ttf');
fontFamily: "Arial Bold";
font-weight:bold;
}
@font-face
{
src: url('/assets/fonts/arial-bold-italic.ttf');
fontFamily: "Arial Bold Italic";
font-weight:bold;
font-style:italic;
}
Flex SDK is really very smart in this case. It actually detects that the font supplied is of which type effect – bold, italics or both.
More on font managers is here.
Navigate
-
Recent Posts
-
Top Posts
- alpha & rotation issue for textArea with htmlText
- Font transcoding error - specify font style
- Ad Hoc Wireless Networking with Ubuntu
- Simple solution to a complex problem - customized Rich Text Editor
- AXIS Bank website & services – reviews & suggestions
- Online Forms : Wufoo v/s Google Forms
- Happy & Safe Diwali
- 3 ways to get control in Flex over user input through Keyboard
- Low Vision
- Flex (Flash Player) - DPI and input/output
Blogroll
Gujarati
RSS
Visitors
Archieves
Tags
actionscript adobe ahmedabad bihar bsnl bug Camera celebration code css digital eclipse email firefox flex flex 3 flex 4 flex sdk font fwd Google gujarat harit kothari home icici image India Internet ip IT jain jharkhand magazine Management mozilla network Photography Programming sdk Security sms Story twitter university VacationCategory Cloud
-
Recent Comments
‘Post’ Calendar
November 2009 M T W T F S S « Oct 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -
Blog Stats
- 10,410 hits
Current Visitor Count

Tweets
- @abhishekdesai if it is so, they will pay cost.... in fact from day before yesterday it's slowly started! written 1 day ago
- @abhishekdesai i have little respect for the company so dont want to show naked thief in open! written 1 day ago
- ahmedabad's 'biggest' IT company breaches contract (with employee)! #alert #IT #ahmedabad #fail written 1 day ago
- experiencing gmail very slow with standard view! :( written 3 weeks ago
- wishing all netizen friends a very happy diwali! :) written 3 weeks ago
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.
