Flex: Normal Distribution Chart

Just in case you need this chart for a fancy report for your boss :)

I was looking for something like this for a while now and couldn’t find anything. The thought part was how to split that area chart in individual pieces so I can display the standard deviation chunks. So the only way I could do it was to use Normal Distribution (Gaussian distribution) bell  to hide the standard deviation chunks.

Here is more about Normal Distribution (Gaussian Distribution).

Well here is the example and here the source.

Have fun.

Flex: Export valid HTML from RichTextEditor and back

I’ve been looking for a RichTextEditor valid HTML parser for long time. I’ve seen all this regexp solutions but is not working all the time specially if you try to send an email with this RTE or to convert from HTML to RTE.

The solution to this problem is a XML approach. Maybe is a little messy but it’s working, I have tested with all kinds of emails like Exchange(Browser and Outlook), Yahoo, MSN. Also tested on IE6, IE7, FF, Opera. The HTML code looks good.

This code was inspired from Antoni Jakubiak’s post on some blog somewhere.

Here are some nice stuff you can do with this parser:

  • <TEXTFORMAT> will be completely removed,
  • <p> tag can be replaced with any tag you like, the default is <div>
  • <font> tag can be replaced with any other tag, default is <span>
  • <li> can be replaced, default is <li>
  • <li> will be inside <ul> by default but it can be replaced with anything else (e.g. <ol>, <dir> etc.)
  • <br/> tag added when you want a space between paragraphs
  • the ability to convert back to RTE valid XML from HTML

You can give it a try and please let me know how did it work. Suggestions are always welcome.

Here is a live example and source(rar) or source(zip) files.

UPDATE:

After K.A. noticed the space problem when parsing from RTE to HTML and back I had to escape the content text using XMLDocument and then parse it to XML witch has a better element management.

There is a catch when using both XML and XMLDocument. In XML the white space is ignored at the beginning and the end of the text node. In XMLDocument all the special characters like ‘ (apostrophe) will be changed to &apos; and it’s a big problem with parsing to CSS, like style=”font-family:’Times New Roman’;” will be style=”font-family:&apos;Times New Roman&apos;;”.

That’s why when parsing to RTE and Back the string that is passed should be plain string with no indent or line brakes (e.g. /n), otherwise the indent will show up in the RTE as space.

UPDATE:

I made an update so if you want to completely remove a TAG then simply set it to null.

UPDATE:

New property added ‘ignoreParagraphSpace’, the default value is false. If set to true this will ignore any space at the beginning or at the end of the paragraph.

Custom scroll box with mouse wheel scroll (AS2)

Recently I was working in a project where I needed a scroll box with dynamic content and the ability to attach movies, to create empty movie clips, load external .swf files, to play movies etc. I looked around some time in order to find a shell that is easy to insert into my project. I could not find something like this and I start developing one from scratch.

This is a “component” – class that is able to load anything inside and use scroll bar or mouse wheel to scroll the content.

Here is the live example and the source files.

dynamic text field bold and italic tags with embedded font problem (flash 8)

I’ve struggled a lot with this problem in the past. So I have decided to assemble a full example for those who are having the same problem. The whole problem is how to add the font names in the library and how to embed fonts for each tag.

So for bold you need to embed the font with the bold check on, for bold and italic check both bold and italic in a separate embed and so on. But nothing is better then an example and source files to better clear this problem as it can be very confusing.

Live example and source files.

better looking embedded font for input, radio, button, check box and combo box components (Flash 8)

For dynamic Flash pages, you might need to add a component with action script and if you embed the fonts all you will see is a blurry text hard to read and not attractive at all. This will ruin your page look!

The only solution for this problem is to set the anti-alias of the component. But you will not going to find in AS docs a way to do this so all you have to do is to go inside component, find that text field and set the anti-alias.

Here are the paths for this components:

  • TextInput.label
  • RadioButton.labelPath
  • Button.labelPath
  • CheckBox.labelPath
  • ComboBox.text_mc.label (not for the dropdown, but it is possible to add anti-alias to it)

Here is an live example with font embedded and here are the source files.