error 1009: cannot access method of a null object reference - apache-flex

I am doing a flex blazedDS project via spring and hibernate. I have error 1009 "cannot access property or method of a null object reference" when I switch between canvases of a view stack.
How can I avoid this error any help would be appreciated.
<mx:VBox height="244.55" y="219.45" width="624.01514" x="10">
<mx:LinkBar dataProvider="{myViewStack}" enabled="true" activate="true"/>
<mx:ViewStack id = "myViewStack" width="624" height="212" enabled="true">
<mx:Canvas id="canvas3" label="Financement" enabled="true" enterState="true" >
<mx:Label x="38" y="10" text="Code Fin."/>
<mx:Label x="19" y="36" text="Fond propre" enabled="true"/>
<mx:TextInput x="119" y="34" id="fondprofin"/>
<mx:TextInput x="119" y="8" id="codefin"/>
<mx:Label x="100" y="10" text="*" width="11" color="#E0391E"/>
</mx:Canvas>
<mx:Canvas id="canvas1" label="Investissement" enabled="true" enterState="true" >
</canvas>

Related

Enabling component error 1009

I want to enable a linkbar component. When I run the application and try to look for data into the linkbar I get error 1009: impossible to acess property or method of a null object reference. How can I enable a component in flex so that to avoid error 1009? Any help would be appreciated...
<mx:LinkBar dataProvider="myViewStack" enabled="true" activate="true"/>
<mx:ViewStack id = "myViewStack" width="624" height="212" enabled="true">
<mx:Canvas id="canvas3" label="Financement" enabled="true" >
<mx:Label x="38" y="10" text="Code Fin."/>
<mx:Label x="19" y="36" text="Fond propre" enabled="true"/>
</mx:Canvas>
</mx:ViewStack>
Check if "myViewStack" is initialized or not
<mx:LinkBar dataProvider="{myViewStack}" enabled="true"/>

Why I get "Error #1069: Property softKeyboardRect not found on flash.display.Stage and there is no default value." when I add a DateField component?

I am trying to add a DateField component to my flex application but when I click on it I get this runtime error:
[Fault] exception, information=ReferenceError: Error #1069: Property softKeyboardRect not found on flash.display.Stage and there is no default value.
It works ok if I do in a simple application and I add the DateField on it but it does not work when I add it on another application.
<mx: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"
color="#333333"
creationComplete="init()">
.... action script code.....
<fx:Declarations>
.............
</fx:Declarations>
<mx:Panel id="MainPanel" title="MyApp" height="1000" width="1100" layout="horizontal" verticalScrollPolicy="auto" >
<mx:HBox id="HBoxHeader" >
<mx:DateField id="StartDate">
</mx:DateField>
</mx:HBox>
<mx:VBox id = "VBoxGroupHeader_LB" height="950" width="250" verticalScrollPolicy="on" visible="true" horizontalAlign="center">
<mx:Label id="groupLable_LB" text="GROUPS" />
<mx:LinkBar id="linkBarGroup" direction="vertical" horizontalAlign="center" itemClick="getMembers(String(event.label))"/>
</mx:VBox>
<mx:VBox id = "VBoxMembersHeader_LB" height="950" width="250" verticalScrollPolicy="on" visible="true" horizontalAlign="center">
<mx:Label id="memberLabel_LB" text="MEMBERS" />
<mx:LinkBar id="linkBarMember" direction="vertical" horizontalAlign="center" itemClick="getMemberTypes('stats.' + activeGroup + '.' + String(event.label))"/>
</mx:VBox>
<mx:VBox id = "VBoxGraphs" height="950" width="580" verticalScrollPolicy="on" visible="true">
</mx:VBox>
</mx:Panel>
Any idea of what might cause this problem?
Thanks
you are targeting older flash player, if you are using SDK 4.6 you need at least flash player 11.1.

Flex - Typed ArrayCollection as Horizontallist's dataprovider

I have an ArrayCollection of objects.
I'm passing this array to a horizontallist as a dataprovider and I'm using a custom itemRenderer.
When executing the application, the horizontallist is displaying
[object CustomClass][object CustomClass][object CustomClass][object CustomClass]
I've tried casting each object in the itemrenderer as following:
<mx:Label text="{(data as CustomClass).label1}"/>
But it's not working...
Thanks for any help you can provide.
Regards,
BS_C3
Edit - 09 March 2010
Let's go for some more code =)
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Component id="Item">
<mx:VBox width="180">
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="x"/>
</mx:HBox>
<mx:Image id="thumbnail"/>
<mx:Label width="100%" horizontalCenter="0" text="Collection"/>
<mx:HBox width="100%">
<mx:Label width="100" text="GIA"/>
<mx:Label text="{data.charg_st}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Finger Size"/>
<mx:Label text="xxxxxx"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Carat"/>
<mx:Label text="{data.carats}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Color"/>
<mx:Label text="{data.color}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Clarity"/>
<mx:Label text="{data.clarity}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Shop"/>
<mx:Label text="{data.lgort_fp}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Resizing"/>
<mx:Label text="{data.resizing}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Price Excl. VAT"/>
<mx:Label text="{data.net_price_fp}"/>
</mx:HBox>
</mx:VBox>
</mx:Component>
<mx:HorizontalList
dataProvider="{GlobalData.instance.tray}"
columnCount="4"
rowCount="1"
horizontalScrollPolicy="off"
itemRenderer="{Item}"
/>
</mx:Canvas>
FYI, the horizonalList dataprovider is an ArrayCollection of objects.
Now, the horizontallist is displaying empty items... with the correct width...
The arraycollection is not empty (I'm using an alert on the click event on an item, and I do retrieve the expected data).
Hope this will help >_<
Regards,
BS_C3
Have you tried
<mx:Label text="{data.label1}"/>
? (label1 being a property of your objects)
Use the labelField field within your list, see here
<mx:List dataProvider="{myDataProvider}" labelField="label1"/>
Try declaring your custom class as a variable somewhere in your component. Once you declare an instance of the class, Flex might have more success identifying the properties of the class.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private var myClass:CustomClass;
]]>
</mx:Script>
<mx:Component id="Item">
<mx:VBox width="180">
...
thelost had it right with his code too. You should be able to use
<mx:Label text="{data.label1}"/>
to access your class's properties in your itemRenderer.
Edit: I'm sure you've done this, but also double check that you've set the dataProvider in your HorizontalList to a [Bindable] declaration of your CustomClass.
I managed to resolve my issue.
When I removed the width property of the itemrenderer's vbox, all data appeared in the horizontalList.
Why? I wouldn't know why but it seems like it was positionning the data somewhere out of the visible scope of the horizontallist (huh??).
The thing is that everything is working now. And for the final code, there you have:
HorizontalList:
<mx:HorizontalList id="hlist"
dataProvider="{TrayData.instance.itemsCollection}"
columnCount="{TrayData.instance.hlistColumns}"
rowCount="1"
itemRenderer="components.TrayItem"
horizontalScrollPolicy="off"
horizontalCenter="0" verticalCenter="0"
borderStyle="none"
horizontalScrollPosition="{TrayData.instance.hsPosition}"
/>
ItemRenderer:
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="x"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Spacer width="15%"/>
<mx:VBox width="70%">
<mx:Image id="thumbnail" horizontalAlign="center"/>
<mx:Label width="100%" textAlign="center" text="Collection"/>
<mx:HBox width="100%">
<mx:VBox id="labelBox" width="100">
<mx:Label width="100" text="GIA"/>
<mx:Label width="100" text="Finger Size"/>
<mx:Label width="100" text="Carat"/>
<mx:Label width="100" text="Color"/>
<mx:Label width="100" text="Clarity"/>
<mx:Label width="100" text="Shop"/>
<mx:Label width="100" text="Resizing"/>
<mx:Label width="100" text="Price"/>
</mx:VBox>
<mx:VBox id="dataBox" width="100%" horizontalAlign="left">
<mx:Label text="{data.resizingCode + ' ' + data.charg_st}"/>
<mx:Label text="{data.fingerSize}"/>
<mx:Label text="{((new Number(data.carats))/100).toString()}"/>
<mx:Label text="{data.color}"/>
<mx:Label text="{data.clarity}"/>
<mx:Label text="{data.lgort_fp}"/>
<mx:Label text="{data.net_price_fp}"/>
</mx:VBox>
</mx:HBox>
<mx:Button label="Order" enabled="{data.product_type == 'C'}" width="50%"/>
</mx:VBox>
<mx:Spacer width="15%"/>
</mx:HBox>
</mx:VBox>
Regards,
BS_C3

how to freeze a label in flex?

I want to have the title of my application to be freezed, that is, even if I scroll down the page, I want the label name to be in focus, at the top always.. Is that possible?
Now if I scroll down , the screen name disappears. Instead, can it be freezed like freezing columns or rows in excel?
Run this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="My Label!" />
<mx:VBox width="100%" height="100%" minWidth="0" minHeight="0">
<mx:CheckBox label="1" />
<mx:CheckBox label="2" />
<mx:CheckBox label="3" />
<mx:CheckBox label="4" />
<mx:CheckBox label="5" />
<mx:CheckBox label="6" />
<mx:CheckBox label="7" />
<mx:CheckBox label="8" />
<mx:CheckBox label="9" />
<mx:CheckBox label="10" />
<mx:CheckBox label="11" />
<mx:CheckBox label="12" />
<mx:CheckBox label="13" />
<mx:CheckBox label="14" />
<mx:CheckBox label="15" />
<mx:CheckBox label="16" />
<mx:CheckBox label="17" />
<mx:CheckBox label="18" />
<mx:CheckBox label="19" />
</mx:VBox>
<mx:Label text="Bottom label here!" />
</mx:VBox>
</mx:Application>
Set minWidth=0 and minHeight=0 so Vbox is not going to expand.
Have you tried ApplicationControlBar - use it with dock set to true.
Quoting from the linked page:
Docked mode: The bar is always at the top of the application's drawing area and becomes part of the application chrome. Any application-level scroll bars don't apply to the component, so that it always remains at the top of the visible area, and the bar expands to fill the width of the application. To create a docked bar, set the value of the dock property to true.
I don't know if I understand you correct, but I would make it the following way:
<mx:VBox width="100%" height="100%" verticalScrollPolicy="off">
<mx:Label label="My Title" />
<mx:VBox name="content">
...
</mx:VBox>
</mx:VBox>
So you'll be scrolling just the second VBox and the outer VBox with the title keeps always on top.

Send data between pages in view stack [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
My language is not the best, so try to understand me.
I have a login page (that working), if details is correct, i want to go to welcome page, and display the first name and last of the user.
Is ok to access to the label in the another page, and how can i do that
please?
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
[Bindable] public var user:User;
private function resultHandler(event:ResultEvent):void
{
// Is corroect to that :
welLabel.text ="Hello "+ event.result.firstName +" "+ event.result.lastName + ", Welcome to BSRM";
myApp.selectedChild=welcomePage;
}
private function faultHandler(event:FaultEvent):void
{
myApp.selectedChild=errorPage;
}
]]>
</mx:Script>
<mx:RemoteObject id="ro" destination="loginService" fault="faultHandler(event)">
<mx:method name="Login" result="resultHandler(event)"/>
</mx:RemoteObject>
<mx:VBox label="Login Page" width="325" height="220" x="210" y="157">
<mx:ViewStack id="myApp" height="206" width="100%">
<mx:Canvas label="Login Page" width="100%" height="100%">
<mx:Label text="User Name" fontWeight="bold" x="24" y="44"/>
<mx:Button label="Login" id="login" width="76" x="202" y="124" click="ro.Login(userName.text,password.text)"/>
<mx:TextInput id="userName" x="118" y="42"/>
<mx:Label text="Password" fontWeight="bold" x="31" y="83"/>
<mx:TextInput id="password" width="160" x="118" y="81"/>
<mx:LinkButton x="54.5" y="124" label="Forget my password" click="myApp.selectedChild=forgetPassword;"/>
<mx:LinkButton x="206" y="163" label="New user" click="myApp.selectedChild=registerPage;"/>
</mx:Canvas>
<mx:Canvas id="forgetPassword" label="forgetPassword" width="100%" height="100%">
<mx:Label x="2" y="76" text="your email" fontWeight="bold" textAlign="center"/>
<mx:TextInput x="74" y="74" width="241"/>
<mx:Text x="50.5" y="23" text="Forget My Password" fontWeight="bold" color="#F19114" width="224" height="26" fontSize="18"/>
<mx:Button x="252" y="104" label="Send" color="#F9AD0B"/>
</mx:Canvas>
<mx:Canvas id="welcomePage" label="Welcome Page" width="100%" height="100%">
<mx:Label id="welLabel" x="116" y="81"/>
</mx:Canvas>
<mx:Canvas id="errorPage" label="Error Page" width="100%" height="100%">
<mx:Label text="Invalid user name or password" x="82" y="85"/>
</mx:Canvas>
<mx:Canvas id="registerPage" label="Register Page" width="100%" height="100%">
<mx:TextInput x="140" y="29"/>
<mx:TextInput x="140" y="59"/>
<mx:TextInput x="140" y="89"/>
<mx:TextInput x="140" y="119"/>
<mx:TextInput x="140" y="149"/>
<mx:Label x="50" y="33" text="User name:"/>
<mx:Label x="50" y="61" text="Password :"/>
<mx:Label x="50" y="91" text="User name:"/>
<mx:Label x="50" y="121" text="First name:"/>
<mx:Label x="50" y="151" text="Last name:"/>
<mx:Button x="140" y="176" label="Send"/>
</mx:Canvas>
</mx:ViewStack>
</mx:VBox>
</mx:Application>
Just give the label you want to access an ID:
<mx:Label text="User Name" fontWeight="bold" x="24" y="44" id="lblUName/>
Then you can access it in any other part of your app:
<mx:Label id="welLabel" x="116" y="81" text="{lblUName.text}"/>

Resources