Widget type casting in SFV 2.0

434
2
08-10-2010 06:43 AM
JamesPosnick
New Contributor
In SFV 1.3, you could get the search widget from the application as a IBaseWidget and then re-type it as a search widget (this was shown in the postings for passing url parameters to your application). When I try to do this in SFV 2.0, I can get the searchwidget typed as a IBaseWidget, but get a null value when trying to retype it as a search widget. Has anyone be able to do this in 2.0? Here is the snippet of code with the variable values I get in the Flash builder debugger:

var bw:IBaseWidget = WM.widgetTable.toArray()[0];
value of bw = widgets.Search.SearchWidget (@9049ae1) //from the debugger

var sw:SearchWidget = bw as SearchWidget;
value of sw = null // if I try to directly declare it, it says it cannot by cast as a search widget.

Re-casting the base widget as a search widget works in SFV1.3.
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
James,

   I ran into this also and found that you can not do the cast to searchwidget like we did in 1.3. The work around is to just define sw as type object and it works, you just will not get the autocomplete or intellisence in the ide.
0 Kudos
JamesPosnick
New Contributor
Thanks Robert. Defining it as an object seems to work fine.
0 Kudos