« November 2004 | Main | January 2005 »

December 22, 2004

Polaroid image processing with Flash

Ok so someone blogged "Polaroid image processing with GDI+ in ASP.NET" on fullasagoog so for a bit of a laugh I had to do it in Flash.
Just type or copy the URL of an image into the first field, any text into the second field and press the Polaroid! button.



URL
Text 




I know it wasn't really the point but instead of "Skills Required: C#, ASP.NET, GDI+." you now have "Skills Required: Flash (basic)"

It is took about 20 lines of very basic code, of course you could do the same thing with our XPComponents in two lines of code for example:
imgbox.source=myPicURL?myPicURL:"sample.jpg";
lbl.text=myPicText?myPicText:"Another Flash moment";


URL
Text 

Anway here's the code for the basic flash version
var picURL = myPicURL?myPicURL:"sample.jpg";
var picText = myPicText?myPicText:"Another Flash moment";
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.parent=this;
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._x=47;
target_mc._y=95;
target_mc._width=217;
target_mc._height=205;
target_mc._rotation=-15;
this.parent.embed._rotation=-15
this.parent.embed.text = picText;
this.parent.embed._width=217;
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip(picURL, image_mc);


December 21, 2004

Powerpoint to Flash

A part of our business for the last 5 years has been developing technology for Breeze like live online presentations. Starting from a Powerpoint presentation, using Java, HTML, WMA, throwing in audio streaming, q&a sessions, questionaires etc. These are expensive, high end custom events for large corporates who can afford spending lots of $$$ for a 2hr broadcast.

The reason I mention this is that a couple of years back we started a project to make a cheaper more self service like product for volume use based on Flash, a lot of work was done, swf generators, audio recording/editing, chat system, powerpoint addins etc. and we even got as far as commercial demos which were generally well received but Breeze came along and we felt there wasn't really a market for two such similar products so one thing led to another and the project got mothballed.

Well we have been looking over the code recently and thinking of what we can do with the technology. One way or another the technology is going to get used somewhere. We dont really want to try and do a "Breeze" but we wonder whether there is an interest in a very low end quick and simple product. We are not totally convinced at the moment that there is a viable "product" here.

We haven't really made our minds up whether to offer a black box version to end users or to componentise it and market it to developers as a super slideshow viewer.

Because we needed to generate feedback forms or questionaires on the fly in Flash from xml, the technology may also have an application for elearning.

At this stage one thought is we might just take the viewer and the swf generator and package them together in a free beta and see what people do with it.

Not sure where were really headed on this but if you spot something here that you have an interest in then why not drop me a line at robert.edgar@epresenterplus.com , any thoughts or ideas are welcome!

DataBinding and Date/Number Formatting in FMX2004

XPInternational is for xenophobes as well!!

One particularly happy camper suggested we should make it clear to people that XPInternational is actually a generic Date/Number formatting system that installs in to FMX2004 professional as a native formatter supporting the DataBinding API. He was not interested in the internationalization aspect but wanted a more flexible number formatter to use in a DataGrid.

After installation you will find that when using the Bindings tab of the Component Inspector there are two extra options under the format property XPDateFormatter and XPNumberFormatter.

For those of you familiar with Java, the XP Date/Number Formatters use the same syntax as do the Java DateFormat and NumericFormat classes.

We have optimized the formatters for use with the current DataBinding API, as for some reason currently Flash will recreate a formatter every time a value changes for a field, which can be often if it is bound to say a spinner, so we provided our own built in formatter cache to get round this issue and maintain high performance and a low memory footprint.

December 17, 2004

The name of this class conflicts with the name of another class

This isn't really new but it took us a while to resolve the problem so I thought it would be useful to blog it in case others come across the same problem some time.

I fired off some new AS2 class files to a client a few months back, the code had been tested and was OK.

When the client ran the code a few minutes later they got an error "The name of this class, XXX, conflicts with the name of another class that was loaded XXX." Both class names were the same in the error message.

I was stumped as to what the problem was and I just couldn't simulate the problem either. There were no duplicate files, nothing funny about the classpath, deleting the .aso files didn't resolve the issue either.

Well over that weekend the problem just went away.

So we sort of just forgot about it, put it down to the client doing something stupid, but again yesterday we had the same problem this time with another client.

This time we dug a bit deeper and finally uncovered the problem.

We are based in Asia and the client was in the U.S. We produced the files sometime on Wednesday morning and sent to the client where because of the time zone difference he ran them on Tuesday night.
Bingo! The Flash compiler objects to processing files which are dated in the future. If the class file has a timestamp ahead of your own PC clock then you get the error.

Solution for developers:
1) Move to California or better Hawaii so everyone on the planet is behind you.
2) Change your system clock back by 24hrs and work in the past.
3) Wait 24hrs before sending out anything
4) Hope MM fix the compiler some day.
5) Ask the client to edit your files to get the timestamp to change.

Forewarned is forearmed as they say.

December 09, 2004

Internationalization/localization in Flash applications

Weve just released a set of classes to help in the localization of internationalized Flash applications.


Although FlashMX2004 added several new features that greatly enhance the work flow for authoring multiple language Unicode-based applications there was a piece missing, there was no simple way to localize dates or number.

XPInternational makes it easy to:
Format and parse dates in a simple and standard way for any languages or locale.
Format and parse numbers in a simple and standard way for any different language or locale.
Create new locales.

XPInternational comes bundled with an assortment of Locale's more are available on demand.

If you ae interested to learn more then try here http://www.epresenterplus.com/i18n.shtml.




















The pack is priced at only USD5.00 and as ever we welcome all comments, questions, discussions even if you are not interested in purchasing.

Sample Code
import xp.util.Locale;
import xp.util.Locale_zh;
import xp.util.Locale_fr;
import xp.util.Locale_enGB;
import xp.util.DateFormat;
import xp.util.NumberFormat;
Locale.addLocale(new Locale_fr());
Locale.addLocale(new Locale_zh());
Locale.addLocale(new Locale_enGB());

First we add the locale classes we want in this application. This only needs to be done once per application.

var d = new Date();
var dfEn= DateFormat.getDateInstance(DateFormat.MEDIUM);
var dfFr= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("fr"))
var dfZh= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("zh"))
var dfEnGB= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("en_GB"))

fr.text=dfFr.format(d);
zh.text=dfZh.format(d);
en.text=dfEn.format(d);
enGB.text=dfEnGB.format(d);

Next we obtain DateFormat objects, the first format objects doesnt specify a locale so it will use the current default locale.
Without recoding our application dates have been formatted in a locale specific manner.

var nfEn= NumberFormat.getCurrencyInstance();
var nfFr= NumberFormat.getCurrencyInstance(Locale.getInstance("fr"))
var nfZh= NumberFormat.getCurrencyInstance(Locale.getInstance("zh"))
var nfEnGB= NumberFormat.getCurrencyInstance(Locale.getInstance("en_GB"))

var n=19456.789
frNum.text=nfFr.format(n);
zhNum.text=nfZh.format(n);
enNum.text=nfEn.format(n);
enGBNum.text=nfEnGB.format(n);

Then we do the same for NumberFormat.
In this case we want to use a CurrenyFormat and once again for the first one as we dont specify a locale it will use the current default locale.
The currency format will automatically display the localized currency symbol and place it in the correct position all without our having to recode our application.


Regards
Rob

December 06, 2004

XPCharting - new features added

Weve updated the XPCharting set in the last few days to add in some advanced features that are particularly useful for Stock charts.

  • HiLo charts

  • CSV Connector

  • Dynamically add and remove chart series
  • HiLo charts are the traditional stock or forex charts displaying High/Low/Open/Close prices.

    Often the data sources for stock charts is CSV formatted data so we have added a CSVConnector. This is to CSV files what the XMLConnector is for XML files. It makes it trivial to load, parse and use CSV files in your application.

    We then connect the CSV data to our chart through a new component the TimeSeriesDataProvider which handles translating dates in the CSV files into real Date Objects that are need by the charting system.

    The example below shows this all coming together.
    The source is CSV data provided by Yahoo Finance.
    In this example you can also add or remove Moving Average analyses by clicking the buttons. These averages are calculated on the fly and are not part of the original data.

    All this was achived with only 36 lines of code most of which was just event handlers and only 7 lines were directly manipulating the chart.













    FYI. The CSVConnector has also been added in to our XPCompent set which now totals over 40 components and still growing.

    December 03, 2004

    Re: Collection & Iterator and Class(cast)

    Jesse Warden blogged about Class(cast) today

    http://www.jessewarden.com/archives/2004/12/collection_iter.html


    I couldnt get the comment posting to work on his site so here is my comment.

    On the class casting issue:
    I think you maybe are misunderstanding class casting.

    Casting NEVER produces a new object instance. It is only ever a check that an object is of a particular class type or extends from a particular class type.

    So Button(myobj) doesn't cause myobj to change or construct a new object, it simply confirms that myobj is an instance of Button or is a Button subclass.

    With Flash Intrinsic objects like String, Number,Array etc you CANNOT do a cast check. This is because String(myobj) is actually a documented conversion function which takes myobj and constructs a new object instance of a String class.

    var val:NewClass = NewClass(o);
    Doesn't work in Java or any language I know. The fundemental issue here is a Flash one in that the new Cast syntax conflicts with the older conversion syntax.
    Really the problem is that String(myobj) is wrong in doing a conversion and should instead simply do a cast check but that would break backward compatibility I guess. So for one reason or another MM choose to leave it as a bit of a mess where the same syntax means different things depending on the context and leaving some objects not castable.

    I blogged about this from the opposite angle a while back
    http://www.epresenterplus.com/blog/archives/2004_05.html
    (See Casting and Arrays)

    Property Default Value and escaped characters

    In FMX2004 I want to have an Inspectable Property with a default value of "\n".

    Actually it could also be \r or \r\n or anything else for that matter.

    But when I try to create the property with this default value the property never appears in the component definition list once I compile it.

    I sort of see what the issue is but does anyone know of a work around that does not resort to making up some abitrary replacement for the escaping delimiter "\".

    I don’t want to use an enumeration either, as that limits the possible values to whatever I can think of now and I don’t really want to create some special code that "means" the actual value as that is just arbitrary and not partiularly intuitive.

    So any thougts?

    December 01, 2004

    What's happened to FlashCoders?

    Is it me or ....

    I stopped getting email from FlashCoders about 36 hrs ago and can't reach there Chattyfig website either.

    Dont think its me as I can't see there is any other site that I cant reach.

    I haven't seen anyone blog about this but does anyone know what has happened to them?