Monday, November 12, 2007
Is your TabNavigator showing wrong content?
I ran into a very strange problem: sometimes my tab navigator showed the content of a different tab than the selected tab... This happened when the tabs were VDividedBox containers instead of Canvas containers. Putting a Canvas container around the VDividedBox solved the akward problem. I hope it does for you as well.
Friday, September 21, 2007
How to make Adobe Flex compile 60 times faster
Thanks to a collegue I learned how to speed up compilations with a factor 60!!! It's actually very easy: instead of 10 or 15 projects with references to each other put everything in 1 project. I know that it's 'not done' from a structural point of view but if compilations only take 5 seconds instead of 5 minutes...
Saturday, July 28, 2007
Getting .NET datasets in Flex through webservices
The current support in Flex for .NET datasets is rather 'limited' to say the least. This is a pitty because most .NET developers make use of datasets and the missing support currently prevents major adoption of Flex by the .NET community.
Although this solution doesn't add complete dataset support to Flex it at least allows you to get the records of a .NET dataset (or a datatable) in Flex through an easy webservice call.
Up till now the typical suggestion is to create a class in .NET that matches the datatable layout, create an array based on this class and fill the array with the records of the datatable.
There is however a much easier solution. Your WebMethod in .NET should look like this:
[WebMethod]
public XmlDocument GetAllUsers()
{
dsBC dsBC1 = new dsBC();
// here you should fill the datatable with database records
return GetXml(dsBC1.bcUser);
}
public XmlDocument GetXml(DataTable dt)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
dt.WriteXml(sw);
sw.Close();
XmlDocument xd = new XmlDocument();
xd.LoadXml(sw.ToString());
return xd;
}
When calling the GetAllUsers web method from Flex you can simply bind for example a datagrid to the event.result object.
Dates are returned in W3C format by .NET! Therefore you should convert them to 'real' Flex dates by using the DateUtil routines in corelib.
Although this solution doesn't add complete dataset support to Flex it at least allows you to get the records of a .NET dataset (or a datatable) in Flex through an easy webservice call.
Up till now the typical suggestion is to create a class in .NET that matches the datatable layout, create an array based on this class and fill the array with the records of the datatable.
There is however a much easier solution. Your WebMethod in .NET should look like this:
[WebMethod]
public XmlDocument GetAllUsers()
{
dsBC dsBC1 = new dsBC();
// here you should fill the datatable with database records
return GetXml(dsBC1.bcUser);
}
public XmlDocument GetXml(DataTable dt)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
dt.WriteXml(sw);
sw.Close();
XmlDocument xd = new XmlDocument();
xd.LoadXml(sw.ToString());
return xd;
}
When calling the GetAllUsers web method from Flex you can simply bind for example a datagrid to the event.result object.
Dates are returned in W3C format by .NET! Therefore you should convert them to 'real' Flex dates by using the DateUtil routines in corelib.
Labels:
.net,
adobe flex,
dataset,
datasets,
flex,
webservice
Tuesday, June 12, 2007
Exception after TileList resize
Does this exception look familiar to you:
TypeError: Error #1010: A term is undefined and has no properties. at mx.controls.listClasses::TileBase/mx.controls.listClasses:TileBase::scrollVertically() at mx.controls.listClasses::ListBase/set verticalScrollPosition() at AssetViewerListStandardThumbnails/::OnPage() at AssetViewerListStandardThumbnails/__next_click()
I got it when trying to scroll within a TileList after it was resized. Hotfix 2 doesn't fix the problem. The following trick solved the problem for me: calling the executeBindings() method on the TileList component in the resize event. I hope it does the trick for you as well.
TypeError: Error #1010: A term is undefined and has no properties. at mx.controls.listClasses::TileBase/mx.controls.listClasses:TileBase::scrollVertically() at mx.controls.listClasses::ListBase/set verticalScrollPosition() at AssetViewerListStandardThumbnails/::OnPage() at AssetViewerListStandardThumbnails/__next_click()
I got it when trying to scroll within a TileList after it was resized. Hotfix 2 doesn't fix the problem. The following trick solved the problem for me: calling the executeBindings() method on the TileList component in the resize event. I hope it does the trick for you as well.
Wednesday, May 9, 2007
Do you count months from 0 to 11 ???
Just to let you know that for some strange reason Flex dates are a bit 'unusual' (at least to .NET developers like me). When checking the 'month' property of a date it's 1 less than the actual month. Why? Flex assigns 0 to January, 1 to February, 2 to March, ... Easy to get around but rather 'silly', no?
Another unusual thingie is the fact that you need to use the 'date' (!) property in order to get the number of the day in the month (and in this case it is NOT 0-based...).
I assume it's to trick people when doing the brand new Flex2 certification exam :)
Another unusual thingie is the fact that you need to use the 'date' (!) property in order to get the number of the day in the month (and in this case it is NOT 0-based...).
I assume it's to trick people when doing the brand new Flex2 certification exam :)
Monday, May 7, 2007
Dragging and dropping but what about the Z-INDEX ?
I don't know whether you know but dragging components around the screen is sooo easy in Flex. The code below works within an MXML component. If you want it to work in an MXML application then you should replace 'this' by the actual component name.
mouseDown="this.startDrag(); " mouseUp=" this.stopDrag();"
Question is: how to make the component being dragged the top component (make it appear above all other components) ? After some searching I found the following solution:
mouseDown="this.parent.setChildIndex(this,this.parent.numChildren-1); this.startDrag(); " mouseUp=" this.stopDrag();"
mouseDown="this.startDrag(); " mouseUp=" this.stopDrag();"
Question is: how to make the component being dragged the top component (make it appear above all other components) ? After some searching I found the following solution:
mouseDown="this.parent.setChildIndex(this,this.parent.numChildren-1); this.startDrag(); " mouseUp=" this.stopDrag();"
Sunday, March 18, 2007
Namespaces - aarrghhhh
Am I overlooking something or is it just impossible to use an HttpService with resultFormat="e4x" in combination with databinding IF the incoming XML contains a (default) namespace???
Preventing the namespace from being sent to the HttpService seems to solve the problem but isn't really a nice solution...
Suggestions are more than appreciated!
Preventing the namespace from being sent to the HttpService seems to solve the problem but isn't really a nice solution...
Suggestions are more than appreciated!
Subscribe to:
Posts (Atom)
