Display HTML text in the Adobe Air Label - apache-flex

I am trying to display HTML text inside the Label in my Adobe Air mobile application, so far
I realized that Label doesn't support HTML, I went through the few solutions I found so far on the web:
Instead of Label - User TextArea and then use:
StyleableTextField(message.textDisplay).htmlText = messageText;
and in the TextArea declaration - specify mobile skin
<s:TextArea editable="false" selectable="false" skinClass="spark.skins.mobile.TextAreaSkin" id="message" x="0" y="0" width="100%" height="100%" paddingLeft="5" paddingRight="5" textAlign="left"/>
First of all, HTML still doesn't work, instead of converted HTML it just shows me ..... garbage, but even if it would have worked - TextArea component looks different than Label and doesn't feet in the design I am implementing.
User RichText component - unfortunately it's not supported in mobile apps
Any other ideas?

Yes, HTML is not supported in the Label and TextArea components for Spark (it was supported in Halo, or the mx components).
The only Flex components that officially do support it are RichText and RichEditableText. The skins for these components are not mobile optimized, but they run on mobile just fine. You may run into some speed issues when using massive amounts of it, but you can still use them (as you can with most, if not all, other components that aren't mobile optimized).

Related

GroubBox in Flex 3 with heading

I need to have a group box in flex 3 - simple border with a heading at the top but the heading at the top should not have any border line through it.
I searched on the Net and the closest that I could get with source is
http://keg.cs.uvic.ca/flexdevtips/titledborder/srcview/
But the problem with this is that I can’t view in design mode what is on the group box. Does anyone know how to fix this?
Then I decided to go with canvases and an input box
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:TextInput
text="This should be my label"
x="124" y="72"
width="166" height="32"
borderStyle="solid"
fontWeight="bold"
color="#003366" backgroundColor="#D81010"/>
<mx:Canvas x="107" y="88" width="263" height="200" borderStyle="solid" label="Testst">
</mx:Canvas>
</mx:Application>
But I can't seem to get the Textinput to be ontop of the canvas. There is a line through the box as in the below picture
Does anyone know how to resolve this or have a better idea?
thanks
What you are looking for is a component equivalent to "fieldset" in HTML. It would be easier to use create component for better styling control. For Flex 2/3, you may use jwopitz-lib; but if you could use Flex 4 or above, try the ShinyLib component (specifically the FieldSet class and FieldSet skin). It would be easier if you could migrate the application to Flex 4 or the latest Flex, you would be exposed to a lot more components.
To get a custom component to work in design mode, you need to compile the code into a SWC library. Then reference the SWC library in your application project. I've never bothered to do this, I imagine you may get mixed results. I haven't bothered w/design mode in over 5 years :)
The reason the "window" component (in the URL that you linked to in the question) works in design mode is that it extends the Flex component TitleWindow. Since it extends an existing Flex component, I am assuming design mode knows how to render it.

How to embed html5 webpage in flex

Using flex mx HTML component we can preview the website at AIR, however it seems did not support all features(audio,video) of html5. such as the following example:
<mx:HTML location="http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_video_bear" width="100%" height="100%"/>
when you running application, the video can not be displayed in AIR windows.
Video/Audio HTML5 tags are currently disabled in AIR.
Here's article about items that are and aren't supported in AIR right now.

What is the state of a TextArea in the Flex when we could not enter the cursor in it and no text is passed into it

I need to know that what is the state or property of text-area in the flex when we could not enter the text in it, my concern is that whether the text has entered(may after it deleted) or not.
(I think i try my best to explain my problem)
Thanks
Thanks of all of you that you provide the solution/answer
Both MX and Spark TextAreas supports editable and selectable properties. The first one prevent user to change text, the second - to select it:
<mx:TextArea editable="false" selectable="false"
text="Sample Text"/>
<s:TextArea editable="false" selectable="false"
text="Sample Text"/>
I am not sure if I understand your problem, but it sounds like it could be the Safari 5.1 / Flash Debug player bug. Try switching to another browser when debugging/testing your project. If you get the same behaviour, forget everything I just said.
Read more here:
https://discussions.apple.com/message/15666579#15666579
"I also don't think this was intentional at all.  I think it was just a bit careless (Apple pushing out Safari 5.1 before it being thoroughly tested - the flash problem is only one of several issues I've noted with the new browser.  Very dissapointing.)."
If you're talking about MX TextArea you can disable component:
myTextArea.enabled = false;
If you're using Spark TextArea you can use editable property.

Flex UI Inconsistencies

I am having some issue with consistency across different machines with my flex application.
There are three things that I have noticed with my application. On my development machine (Windows XP) I can not reproduce these issues.
I have noticed them on a Windows Vista machine as well as a Windows 7 machine.
The three things that I have found are:
Label's will be truncated with '...'
Tabs in a tab navigator will be truncated with a '...'
Some Images will be rendered with an inconsistent width and height
My labels are defined pretty simply
<mx:Label x="261" y="15" text="Date Prepared" fontWeight="bold" width="113"/>
Tabs are custom components but defined in a pretty standard format:
<mx:TabNavigator borderStyle="solid"
x="10" y="10" width="665" height="450" id="tabs" creationPolicy="all">
<local:FormPanel id="formPanel" name="formPanel"
label="Incident Details "
width="665" height="450"/>
</mx:TabNavigator>
You may notice extra white space following the label in the custom FormPanel, I have found that this might help solve a subset of the truncation issues (not 100% sure).
As for my images, again, I am not doing anything to amazing:
<mx:Image id="vehicle_image"
source="#Embed(source='../../../../../images/icons/basic/vehicles.swf')"
height="45" width="45" toolTip="Vehicles"
toolTipShow="handleToolTipShow(event)"
click="showBar(event, vehicle_bar)" enabled="true" x="47" y="0"/>
The image is contained in a canvas and I will have about 10 of these images all sized 45x45. On certain machines I will see 3 of the 10 images rendered smaller what would appear about 30x30 relative to the other 45x45 sized images.
The problem I am having is that I can not reproduce these issues on my development machine, and do not have any clue on how to fix these issues. I would expect that the things I am seeing are bugs in the FlexSDK, but even if they are bugs I do need a temporary work around.
Any ideas?
For some reason it won't let me add a comment, but..
This sounds a lot like some of the changes (CSS fixes) put in from Flex 2 to 3 (maybe 3 to 4 as well?) (Button components can do this too if the width is a fixed size.)
Are you absolutely sure that your development machine is running the same version of the app as the others? If you're using Flex/Flash Builder's "run" functionality to run on the dev machine, but building and deploying with Flex Ant tasks or some kind of separate build for the others, it's possible to have this happen by using different SDKs even though the code hasn't been changed at all.

displaying HTML inside a Flex application

I have some HTML that is generated via a Rich Text Editor outside of my Flex application but would like to display it inside Flex.
The HTML is simple HTML tags, things like styles, anchors, and possibly image tags, is there a control that would let me render this HTML in flex or am I going to have to roll up my sleeves and roll my own?
Any ideas appreciated...Thanks.
If the HTML is really simple, you can display it in a normal label or textarea component, If it is more complex, I'll quote what I answered in this question. The discussion there also has a little more info.
If it is complex HTML and Javascript, one possible way is HTMLComponent, a method that uses an iframe over your flash to make it appear like the HTML is in your app. There are a few downsides to this method however - most of them described in detail at Deitte.com.
If this can move offline, you could use Air (it has an mx:HTML component built in). Deitte.com has a detail of this technique as well.
Check out the documentation on mx.controls.Label and flash.text.TextField (which is what displays the text in a Text or Label control in Flex). The TextField documentation states that
The <img> tag lets you embed external image files (JPEG, GIF, PNG), SWF files, and movie clips inside text fields. Text automatically flows around images you embed in text fields. To use this tag, you must set the text field to be multiline and to wrap text.
Which means that you can display an image in a Text component in Flex by setting its htmlText property to some HTML which contains an <img> tag. You can't use Label, because it is not multiline.
I've noticed that text fields have trouble with properly measuring their heights if the images displayed in them are left or right aligned with text flowing around them (e.g. align="left"). You may have to add some extra spacing below to counter that if you plan to use aligned images.
You will have to use flex iFrame control.
It is not an 100% flash solutions, and combines a bit of js calls but works perfectly for me.
You can grab latest source code from github https://github.com/flex-users/flex-iframe
Here is some sample code from the component author.
<!---
A basic example application showing how to embed a local html page in a Flex application.
#author Alistair Rutherford
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:flexiframe="http://code.google.com/p/flex-iframe/"
horizontalAlign="center"
verticalAlign="middle"
viewSourceURL="srcview/index.html">
<!-- Example project presentation -->
<mx:ApplicationControlBar dock="true">
<mx:Text selectable="false">
<mx:htmlText><![CDATA[<font color="#000000" size="12"><b>flex-iframe - Simple html example</b><br>This example shows how to embed a simple Html page in a Flex application.</font>]]></mx:htmlText>
</mx:Text>
</mx:ApplicationControlBar>
<!-- HTML content stored in a String -->
<mx:String id="iFrameHTMLContent">
<![CDATA[
<html>
<head>
<title>About</title>
</head>
<body>
<div>About</div>
<p>Simple HTML Test application. This test app loads a page of html locally.</p>
<div>Credits</div>
<p> </p>
<p>IFrame.as is based on the work of</p>
<ul>
<li>Christophe Coenraets</li>
<li>Brian Deitte</li>
</ul>
</body>
</html>
]]>
</mx:String>
<!-- Example using the 'source' property -->
<mx:Panel title="A simple Html page embedded with the 'source' property"
width="80%"
height="80%">
<flexiframe:IFrame id="iFrameBySource"
width="100%"
height="100%"
source="about.html"/>
</mx:Panel>
<!-- Example using the 'content' property -->
<mx:Panel title="A simple Html page embedded with the 'content' property"
width="80%"
height="80%">
<flexiframe:IFrame id="iFrameByContent"
width="100%"
height="100%"
content="{iFrameHTMLContent}"/>
</mx:Panel>
</mx:Application>
#mmattax
Indeed you can display images in a TextArea component. The approach is not entirely without problems though...

Resources