The following code doesnt work:
<s:TextArea name = "Desc1" id="Desc1" x="8" y="233" width="162" height="369" restrict="^&"/>
im trying to not allow the user to input de "&",in flash it works well but in textarea of flash builder it gets me an error.
Try writing "^&". The & character in an mxml tag must be html-escaped. It's the same if you try to write an AND condition in a bound property (text="{bool1 && bool2?'ok':'ko'}"), it's highly unreadable but useful.
Related
I'm new at working with Flex, and I can't figure out how to reuse a specific ID.
So I'm doing an application where you can customize a product. First you choose the product, and then you can add custom text to it.
I can get it to add the text, I add an ID, and when I click on the text I can move it and edit it. My problem is that I can't figure out how to save the edit.
I put the text ID in a hidden field, but I can't use it to replace the text in my field. How could I do that ?
Here's part of my code :
<s:TextInput includeIn="modifierTexte" x="24" y="39" width="599" id="idTextePersonnalise"/>
<mx:RichTextEditor id="persoContentModifier"
backgroundColor="#ccffcc"
title="Texte personnalisé"
x="23.8" y="62.2" width="768" height="200" chromeColor="#A6A3A3" verticalAlign="top"
creationComplete="removeMiscButtons()"
dropShadowVisible="false" includeIn="modifierTexte"/>
<s:Button x="571" y="269.4" width="221" height="34" fontFamily="Georgia" fontSize="15" color="#404040" chromeColor="#A8D009" focusColor="#3F9020" id="editTxtToBathtub" label="Modifier le texte" includeIn="modifierTexte" click="editTextToBathtub()"/>
So the textinput contains my text id, richTextEditor gets the custom text and you click the button to save.
My function looks like this :
private function editTextToBathtub():void{
var idDeMonTexte:String = idTextePersonnalise.text;
//I'ld like to do something like idDeMonTexte.text = persoContentModifier.text;
}
Everytime I try to use my var to put my richtext back in my custom text, it gives me an error of course...
Anyone know how to work with this ?
Thanks for your help !
2 problems.. You say you want to do something like idDemonText.text = personContentModifier.text, but you have no component with an id of idDemonText. (at least not in your example).
The other is you've named your private function the same as the id of your button. That's probably gonna cause your error. What is your error?
You can't do what you want.. Like RIAstar says, you're trying a horrible html hack which isn't supported. You should consider an alternative approach.
Why don't you change your function to this?:
private function editTextToBathtub():void{
persoContentModifier.text = idTextePersonnalise.text;
}
I have a GridView in a windows store app that has an ItemContainerStyleSelector. Within the style is an Image control that has a custom dependency property to set the source (This is so I can get a handle on the Image and hook up to the unloaded event).
My issue is the Image is never unloaded and seems to be reused. This means that when I set the source, the image is set on other items in the GridView as well (For Example I have an object which has no image but after scrolling away and then back again it has an image from another object).
I've tried to set virtualization mode to standard where I can but it doesn't help. Any ideas would be greatly appreciated.
Here is the Image that is contained in the style. This is passed to a method "OnRemoteURISourceChanged" when set. I'd expect a different image control whenever the method is called but this is not the case.
<Image x:Name="BackgroundImage" DataContext="{Binding CurrentBackdrop}" helpers:ImageExtensions.RemoteURISource="{Binding Uri}" Stretch="UniformToFill"/>
And here is my GridView
<GridView x:Name="ItemsGrid" Grid.Row="1" ItemsSource="{Binding BrowseResults}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Margin="20,0,20,0"
IsItemClickEnabled="True" ItemClick="ItemsGrid_ItemClick" VirtualizingStackPanel.VirtualizationMode="Standard">
<GridView.ItemContainerStyleSelector>
<controls:UPnPCDStyleSelector CDObject="{StaticResource somestyle1}" Container="{StaticResource somestyle2}" Item="{StaticResource somestyle3}"/>
</GridView.ItemContainerStyleSelector>
<GridView.ItemsPanel>
<ItemsPanelTemplate VirtualizingStackPanel.VirtualizationMode="Standard">
<WrapGrid Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Standard"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
UPDATE: The issue appears to be the WrapGrid. If I change this to a VirtualizingStack Panel and set the VirtualizationMode to Standard then everything works as expected but obviously my items then only appear on one line and not multiple lines as I wish.
How do I set the virtualization mode of a WrapGrid?
Is there a chance your helpers:ImageExtensions.RemoteURISource doesn't clear the Image.Source when either your CurrentBackdrop property or its Uri property value is null?
Are you sure the task which is loading the img source returns to default ui context when awaiting? I don't think it is a good idea to set Image.Source property form code. The better solution would be to create a custom observable task class and bind im source to it's result. In the background you can call the task. Do you need the control to be Image? Because if it would be a control with template, it would be easier for you to do that. I can send you the class which does that if you want to.
I'm writing a veeeeeeeery simple code where a Spark TextArea is in a TabNavigator and I want to write something into it dynamically. The problem is: when I try to do it the TextArea stays white until clicking on it makes the text appear magically.
The mxml is this:
http://pastebin.com/7WqvXuH2
and very simple code to write is this:
xmlError.text += error+"\n\n";
I also tried this but with the same result
xmlError.appendText(error+"\n\n");
Hope I've been clear.
As a work-around I've used the code below, there are multiple input fields on this view setting the focus on just one of the text inputs causes all of them to render the text correctly.
The only really relevant "property" is the creationComplete handler.
<s:TextInput autoCapitalize="none"
autoCorrect="false"
creationComplete="{tiFirst.setFocus()}"
id="tiFirst"
prompt="{data.firstName}"
text="{data.firstName}"
width="300"
tabIndex="0"/>
In my code I have defined the following:
<s:Image id="test" x="50" y="50" width="30" height="30" click="onClick_clickHandler(event)" smooth="true" smoothingQuality="high" source="#Embed('icons/myImage_60_off.png')"/>
What I want is to be able to change the source of the image every time the user clicks on the image - similar to the way favourites work on a browser.
I have no idea how to change the source of the image from my code.
Thank you
I had a hidden datagrid with my solution, because it started off with a visible one.
The image looked like this:
<mx:Image top="153" left="10" right="10" bottom="5" source="{dgpick.selectedItem.ImageFile}" />
Every time someone clicks on the image, I would increase the selected index of the datagrid, and the labels will display the corresponding data, as they are also bound to its data.
The image can also have a link to an XML file that you can load like this:
<s:HTTPService id="Config"
url="config.xml"
result="resultHandler(event)"/>
private function resultHandler(event:ResultEvent):void
{
ImagesURL = event.result.images.ImagesURL[iCounter];
}
Every time someone clicks on the image, you can increase the counter, and so forth.
Hope this gives you some ideas.
There are 20 ways to do this.
If you need more code, add a comment, with what you need.
I finally did it!
public var image_loader:Loader; // define a new loader
image_loader = new Loader(); // create the new loader at the desired location (in my case in the initialization method of the page
image_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); //add a listener and a function to assign to the listener
depending on where the command has to be executed
image_loader.load(new URLRequest('location of the image')); //this will load the image dynamically
function imageLoaded(event:Event):void {image_Id.source = image_loader;} //where image_Id is the id of the s:Image tag to be modified
also, I had to remove the source from the s:Image tag previously posted
The rest is just logic of the way the application needs to implement the functionality, so it's pretty much left to the developer's desires
I am working as a developer on a Flex/Air application and we are using the buggy Flex RTE (RichTextEditor) to let the user manage his notes. At the moment I am trying to evaluate how costly it would be for us to build a new text component using the TLF (Text Layout Framework).
Really important is the question if we can import the HTML text, produced by the RTE straight away. I know that there are some limitations regarding lists with TLF 1.1, but does it work in general?
I have just tried to grab some HTML formatted text from RTE like:
var htmlText:String = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="defaultFont" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">1hr run on Wednesday - feeling ok!</FONT></P></TEXTFORMAT>'
when I pass this to the TextConverter like this:
var textFlow:TextFlow = TextConverter.importToFlow(htmlText, TextConverter.HTML_FORMAT);
The Flash Player throws an exception. I also tried to wrap the text with
<html><body></body></html>
, but same issue. So it does not seem to work straight away. What are you experiences? This is really critical to us.
UPDATE 1:
When I try to import the HTML like above (same variable declaration) I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flashx.textLayout.formats::TextLayoutFormatValueHolder/apply()[C:\Vellum\branches\v1\1.0\dev\textLayout_core\src\flashx\textLayout\formats\TextLayoutFormatValueHolder.as:357]
at HtmlImporter$/parseTextFormat()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\HtmlImporter.as:307]
at BaseTextLayoutImporter/parseObject()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\BaseTextLayoutImporter.as:464]
at BaseTextLayoutImporter/parseFlowGroupElementChildren()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\BaseTextLayoutImporter.as:419]
at HtmlImporter$/parseHtmlContainer()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\HtmlImporter.as:269]
at BaseTextLayoutImporter/parseObject()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\BaseTextLayoutImporter.as:464]
at HtmlImporter/importFromXML()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\HtmlImporter.as:142]
at HtmlImporter/importFromString()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\HtmlImporter.as:130]
at BaseTextLayoutImporter/importToFlow()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\BaseTextLayoutImporter.as:73]
at flashx.textLayout.conversion::TextConverter$/importToFlow()[C:\Vellum\branches\v1\1.0\dev\textLayout_conversion\src\flashx\textLayout\conversion\TextConverter.as:87]
at TLFTestApp/init()[/Users/Arne/Documents/Adobe Flash Builder 4/TLFRichTextEditor/src/TLFTestApp.mxml:29] <-- // executing TextConverter.importToFlow(htmlText, TextConverter.HTML_FORMAT);
Meanwhile I removed the tags and it works, but the question still remains.
Thanks in advance!
Take a look at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/conversion/TextConverter.html
There are three constants for the format, none of which seems to be what you used:
PLAIN_TEXT_FORMAT
TEXT_FIELD_HTML_FORMAT
TEXT_LAYOUT_FORMAT
Also, the format of the following "html" code looks more like TLF-formatted XML than HTML.
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="defaultFont" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">1hr run on Wednesday - feeling ok!</FONT></P></TEXTFORMAT>