Blog has moved

August 18, 2008

The blog has moved to: http://mitek.id.au/blog

Data binding will not be able to detect assignments to “SOME_STATIC_VARIABLE”.

August 18, 2008

If you want to bind in MXML to some static variable compiler will warn you that data changes to the value will be unnoticed with the following warning:
Data binding will not be able to detect assignments to "SOME_STATIC_VARIABLE".

I don’t like compiler errors and don’t like compiler warnings as well. So, to avoid this warning you can do the following:

Instead of:

    <mx:TextInput enabled="{iUserAccessId == GLOBAL.m_iAllowTextInput}" />

you can do this:

    <mx:Script>
        <![CDATA[
             [Bindable]
            private var iCanEdit:uint = GLOBAL.g_iAllowTextInput;
        ]]>
    </mx:Script>
    <mx:TextInput enabled="{iUserAccessId == iCanEdit}" />

Voilà!

UPD: Blog has moved: http://mitek.id.au/blog/2008/08/18/binding-to-static-variables-in-mxml/

ComboBox selectedItem problem

August 18, 2008

ComboBox is definitely one of the lousiest Flex components.
First, you can’t customise the itemRenderer for the main control (not the drop-down list).
Second, it has very uncertain behaviour with item selection.

Problem 1:
setting ComboBox.selectedItem = null does not do anything. Logically, it should be equivalent to setting selectedIndex=-1. But it does not work.
There is Flex bug registered and it is marked as Fixed in Flex 3 (Released), which is a bullshit. It is still there.

Problem 2:
The whole Flash/Flex framework is event-driven thing. But sometimes developers forget about it. Unfortunately, including the framework designers.
Somehow, someone thought that dataProvider property will be always set first, and selectedItem second. This is wrong. Here is an example how it could be in a real world:

A multi-state Panel has Combobox. The Panel is cached (after creation it is saved to be reused in later calls).

Here is the sequence of events:
1. Already cached Panel is opened up by PopUpManager
2. Panel is initialised with new data
3. selectedItem property is getting initialised first (by data binding)
4. Panel performs the state change
5. Panel in new state initialises ComboBox by setting the dataProvider (by databinding)

Because there are no new dataChange events coming after this point, selectedItem won’t be set.

Touché!

Here is the overridden class which addresses both problems.

package
{
    import mx.controls.ComboBox;

    public class RightComboBox extends ComboBox
    {
        public function RightComboBox ()
        {
            super();
        }

        override public function set selectedItem(value:Object):void
        {
            if (value == null)
            {
                super.selectedIndex = -1;
            }
            else
            {
                super.selectedItem = value;
            }
        }
        
        override public function set dataProvider(value:Object):void
        {
		var l_savedSelectedItem:Object = super.selectedItem;
        	super.dataProvider = value;
        	super.selectedItem = l_savedSelectedItem;
        }
        
    }
}

call validateNow() on parent for correct results

August 2, 2008

It is never too late to learn. After a lot of time spent on fixing the mighty “Flex Printing Engine”(tm), I’ve learnt an important lesson: you have to call validateNow() on parent component as well to get child component properly measured and rendered.

Midnight Commander under Cygwin/Vista

August 2, 2008

For many years I’ve been using Far Manager which is really great commander for Windows.
It has many useful plugins like SCP/SFTP, Network Browser, reasonably good editor with Colorer, PocketPC connection etc.

On the downside FAR editor has a couple of problems which bothered me a lot:
– Internal editor which is quite powerful, sometimes starts using Windows line endings (CRLF) and because I am working in a mixed environment I had to run the dos2unix utility on the routine basis to convert all the files into the UNIX format.

– FAR has a mysterious feature of changing file permissions or file sharing by adding user “None” with special permissions which were preventing files from to be executed. I.e. you’ve download ZIP file using FAR’s FTP browser, unpack it, try to run EXE file, Windows says:"You don't have permissions to run the file". So you have to Explorer->Security settings and kill this None user.

After my recent upgrade from XP to Vista these problems became even worse.
So, I tried to start using the Midnight Commander, which I’ve been using for ages in Unix environment.
But under Cygwin/Vista it behaves quite differently.

Problems I’ve met so far are:

– no mouse support under Vista.
I’ve even tried to use Cygwin’s SSH port with PuTTY and then run MC – no way to have mouse working in Cygwin window.

– I am unable to browse/open any .zip files.
MC says: ./file.zip: ./file.zip: cannot execute binary file.
What the heck? Somehow it opens the TAR files, but only by F4(Edit) command. If you try to open TAR file it writes similar bullshit about running a binary file.

-And the last thing which drives me mad – I am unable to save some of the MC’s config files, such as .mc/bindings. Every time it accesses it, it sets up the sharing, adding this infamous user None with special permissions and this file becomes read-only for MC.

PS While writing this post, I have found that you can get a Midnight Commander’s subshell working under Cygwin – you have to explicitly enable the subshell support via parameter (even if it is a default):
#> mc.exe -U

Flex debugging session is stuck at the loading stage (IE only)

August 2, 2008

I’ve found that when you start debugger from Flex using IE, in most of the cases the debugging session is stuck at the stage when Flash Player shows Loading/Initialising progress bar.
I can’t recall this happening in the Firefox. I still have got intermittent problem with debugging in both browsers but at the later stages, when I load and initialise dynamically SWFs and loading/screen update is stuck.

To overcome this I used to a trick: right-click to get into the Flash Player menu -> click “Play” to shove the debugging session. Sometimes it worked, sometimes it was crashing in the guts of the SystemManager. So I had to restart the whole thing all over again.

It is appeared that the culprit for this freezing is an Anti-Phishing filter.
As soon as added my sites to the Trusted domain and in the IE settings disabled the anti-phishing filter it immediately stopped doing this nasty thing.

svn: This client is too old to work with working copy; please get a newer Subversion client

July 11, 2008

I’ve bumped into this problem again – Subclipse was refusing to do anything (Share the project, update, commit, etc) with the source files.

It is appeared that the culprit was a Tortoise SVN – it is already built on subversion 1.5, while Subclipse is using 1.4.x.

The problem appears everytime when you do anything using newer client, like Tortoise SVN.  Newer client  leaves a different footprint, so Subclipse is getting upset with that fact.

To overcome the problem I’ve added subversione client into the Cygwin port – it is still some relatively old version (1.4.6-3). Then I checked out the project via cygwin version of svn.

It also helps when only a part of the source tree is damaged by a newer client, so you can simply overwrite these bits from an tree checked out using older version.  Just be sure to copy modified files to some safe location first.

UPD  The final solution is to upgdade to Subclipse >=1.4.2 as it is using Subversion 1.5.x. The problem will be completely fixed.

To do this you have to simply add new remote site in Eclipse:
Name: Subclipse 1.4.x (Eclipse 3.2+)
URL: http://subclipse.tigris.org/update_1.4.x

and remove the old one which refers to Subclipse 1.2.x.

The full installation instructions could be found here:
http://subclipse.tigris.org/install.html

UPD: Blog has moved: here

“She’ll be right!”

June 11, 2008

Just after I wrote a previous post I realised that when Adobe is committed to bug fixing it does not bring much excitement as well.

My first bug submitted to Adobe was that one: the last comment on the page

Guess what happened in the next Flex2 hotfix? This bug was fixed. In the shortest period of time.
Was it mentioned in the Release Notes? No, it wasn’t.
As the result my app started to crash on List selection as if you process selected cells you have to rely on the order of indices.

ComboBox selection behavior was fixed in Flex3. Perfect!
Was it mentioned in the Release Notes? Nope. Crash, crash and one more crash!
Who cares?

Do you need to mention everything you fix in the Release Notes?
No. She’ll be right!

PS This is how losers do – they put every bug fixed in the Release Notes

This is so boring to read! It is much better to read some overexcited evangelist’s diary about new cool features.

[UPD] Looks like this thing bothers some other people as well.

Security.loadPolicy() doesn’t support error recovery

June 11, 2008

Flash Player does not support error recovery when it comes to loading policy file.
If for some reason socket policy server does not respond on the first call of Security.loadPolicy(url) there is no way to recover from this situation. All subsequent call to Security.loadPolicy() will be in vain.

I’ve submitted this bug in January 2008 and after 2 FlashPlayer releases there is no sign of a progress on this issue. FP 10 beta does not show any signs of the addressed problem either.

https://bugs.adobe.com/jira/browse/FP-67
https://bugs.adobe.com/jira/browse/SDK-14483

Adobe’s attitude is well described by Screenivas

Version 1.0 release : We are releasing a great product which would help our users in a great way by boosting their productivity. We would fix all serious bugs soon.

Customer: Great. Let me use it.

Version 2.0 release : We have lot of new features for you. In this release we have addressed all serious bugs (read it as bugs reported by great partners and volume customers) in the previous release.

Customer: But what about other serious bugs faced by me?

Company: We would fix all bugs soon.

Customer: They are only fixing bugs for the new features and few more bugs from volume customers.

Version 3.0 release : We have lot of new features. We have revelutionized the workflow. We have rewritten many parts of the code to boost performance. etc… Of-course now we are open-source !

Customer: Now it is Open-source ? Great! But what about bugs which were in 1.0 release?

Company: Oh! our customers have lived with these bugs for more than 2 years, now they have almost stopped complaining…..they can live with it! If they complain more, let us ask them to upgrade to the new version and follow a new workflow/API for the same feature which we have introduced. And anyway we are open-source let them grab the source and fix the bug themselves. We can’t spend our precious development time over fixing those old bugs.

Customer: Where I can find a developer and time to study this piece of open-source product and fix bugs for me? …?….?

There are 6385 unresolved or deferred bugs in the Flex bugs database. And they are now actively working on Flex4. This is so great! I could not wait for another version for Flex – this so exciting!

Date & daylight savings

June 11, 2008

Date class has a bug related to the daylight savings.

If you want to change the date using number of seconds it will cause a problem going over the dates when daylight savings change.

E.g.

private var mydate:Date = new Date(2008, 3, 4, 0, 0, 0, 0);
mydate = new Date (mydate.getTime() + 1000 * 60 * 60 * 24)
mydate = new Date(mydate);

If it goes over the date when daylight savings is changed, instead of adding 24 hours it will add 23 or 25 hours (depending on the time of the year – summer or winter)

So, to do perform Date manipulation correctly you have to use date field, i.e.:
mydate.date +=1;

This method correctly handles the daylight savings and it will keep initial 00:00:00 time.

PS https://bugs.adobe.com/jira/browse/SDK-14983