Does anybody has any suggestion to solve this problem. It is acting as
blocker to moving towards Flex 4 release version.

Please help.

Regards,
Pradeep

On Mon, Apr 12, 2010 at 7:36 PM, prad_ch <[email protected]>wrote:

>
>
> I am getting a null object reference error while trying to instantiate an
> mxml component from actionscript. This same code works if compiled from
> Flash Builder Beta 2 version.
> I am getting the error only if the code is compiled in Flash Builder 4
> (Flex 4 release version).
>
> The problem seems to be related to creation policy of the component but I
> have not been able to figure out how to resolve it. I have already specified
> creation policy as "all".
>
> Please help.
> Pradeep
>
> Following is the prototype example of code.
> ----------------------------------------------------------
> CustomAccountGrid.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:DataGrid xmlns:fx="http://ns.adobe.com/mxml/2009";
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx"
> width="100%" height="100%"
> rowHeight="22" showHeaders="false" x="0" y="20" verticalGridLines="false"
> fontSize="12" fontWeight="normal" borderVisible="false" >
> <mx:columns>
> <mx:DataGridColumn
> dataField="name"
> width="200"/>
> <mx:DataGridColumn id="registerBalance"
> textAlign="right"
> width="100"/>
> </mx:columns>
> </mx:DataGrid>
>
> ----------------------------------------------------------
> AccountView.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009";
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx"
> xmlns:cust="test.custom.component.*"
> width="100%" height="100%"
> cornerRadius="4"
> title="Spending Accounts"
> fontSize="15" fontWeight="bold" creationPolicy="all">
>
> <s:Group height="24" left="10" right="10" top="10" fontSize="12"
> fontWeight="normal" >
> <s:layout>
> <s:HorizontalLayout gap="5" verticalAlign="middle"/>
> </s:layout>
> <mx:LinkButton label="Add" height="24" paddingBottom="2"/>
> <mx:LinkButton label="Manage" height="24" paddingBottom="2"/>
> <mx:LinkButton id="accountTransferLink" label="Account Transfer"
> height="24" paddingBottom="2"/>
> <mx:LinkButton label="Refresh" height="24" paddingBottom="2"/>
> </s:Group>
>
> <mx:Accordion width="100%" height="100%" top="44" fontSize="12"
> fontWeight="normal"
> creationPolicy="all">
> <s:NavigatorContent label="Money" width="100%"
> bottom="0" contentBackgroundAlpha="0xFFFFFF" height="70%">
> <cust:CustomAccountGrid id="moneyAccount" />
> </s:NavigatorContent>
> <s:NavigatorContent label="Credit" width="100%" height="70%">
> <cust:CustomAccountGrid id="creditAccount" />
> </s:NavigatorContent>
> </mx:Accordion>
>
> </s:Panel>
>
> ----------------------------------------------------------
> AccordionTest.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
> xmlns:s="library://ns.adobe.com/flex/spark"
> xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
> xmlns:ui="test.custom.ui.*"
> creationComplete="creationComplete(event)">
>
> <fx:Declarations>
> <!-- Place non-visual elements (e.g., services, value objects) here -->
> </fx:Declarations>
>
> <fx:Script>
> <![CDATA[
> import mx.events.FlexEvent;
>
> import test.custom.ui.AccountView;
> private var _spendingAccount : AccountView;
>
> function creationComplete(event:FlexEvent):void{
> _spendingAccount = new AccountView();
> _spendingAccount.moneyAccount.dataProvider = {};
> _spendingAccount.creditAccount.dataProvider = {};
> }
> ]]>
> </fx:Script>
> <!-- This works fine. creating through script gives error.
> <ui:SpendingAccountView/>
> -->
> </s:Application>
>
>  
>

Reply via email to