Solved

private function works only without TabNavigator?

Posted on 2014-09-07
3
321 Views
Last Modified: 2014-09-08
Hello,
with PHP and MySql i output some data in a grid, everything works perfect.
These two grids are VBoxes. Now if i try to put these VBoxes in a TabNavigator i get an error. Anything does not work in my private function. Without the TabNavigator everything works.
Please can somebody help me?

Thanks

private function calcSumEK():void {
            	var amount:Number = 0;
				if(produkteGrid.dataProvider) {
					for(var i:int = 0; i<produkteGrid.dataProvider.length; i++) {
						amount += Number(produkteGrid.dataProvider.getItemAt(i).EK) * Number(produkteGrid.dataProvider.getItemAt(i).Vorrat);
					} 
					sumEK.text = roundDecimal(amount,2).toString() + " Euro";
				}
            }
            
            private function roundDecimal(num : Number, decimals : Number):Number {
				var tempNum1 : Number = Number((1 <<decimals).toString(2));
				var tempNum2 : Number = Number((1 <<decimals).toString(2));
				return Math.round(tempNum1*num)/tempNum2;
			}

<mx:HTTPService id="produkteListe" useProxy="false" url="{parentApplication.phpURL}" method="POST" result="calcSumEK()">
		<mx:request>
		  <getProdukteEditListe>true</getProdukteEditListe>
		</mx:request> 
	</mx:HTTPService>

<mx:TabNavigator width="100%" height="100%" id="nav2" selectedIndex="0">
	
	<!--   Leistungen   -->
	
		<mx:VBox label="Leistungen" height="100%" width="100%"  paddingLeft="8" paddingTop="8" paddingRight="8" paddingBottom="8" backgroundColor="#f8f8f8" borderColor="#e0e0e0" borderThickness="1" borderStyle="solid">
			<mx:Text text="Leistungen" fontWeight="bold" fontSize="14" color="#3D98FF"/>
			<mx:DataGrid variableRowHeight="true" editable="true" height="100%" itemEditEnd="updateLeistung(event)" id="leistungenGrid" wordWrap="true" dataProvider="{leistungenListe.lastResult.leistungen.leistung}" width="100%">
				<mx:columns>
					<mx:DataGridColumn dataField="ID" editable="false" width="35"  />
					<mx:DataGridColumn dataField="Name" />
			        <mx:DataGridColumn dataField="Preis" width="60" textAlign="right" labelFunction="formatPreis" />
				</mx:columns>
			</mx:DataGrid>
			<mx:HBox width="100%">
				<mx:Spacer width="100%" />
				<mx:Button label="-" click="loescheLeistung.send()" />
			</mx:HBox>
			<mx:VBox width="100%" paddingTop="10" height="130" horizontalAlign="left" verticalAlign="bottom">
				<mx:Text text="Neue Leistung" fontWeight="bold" width="100%"/>
				<mx:HBox width="100%">
					<mx:Label text="Bezeichnung:" width="100" />
					<mx:Spacer width="20" />
					<mx:TextInput id="neueLeistungName" width="100%" />
				</mx:HBox>
				<mx:HBox width="100%">
					<mx:Label text="Preis:" width="100" />
					<mx:Spacer width="20" />
					<mx:TextInput id="neueLeistungPreis" width="100%" />								
				</mx:HBox>
				<mx:Spacer height="100%" />
				<mx:Button label="+" click="neueLeistung.send(); neueLeistungName.text=''; neueLeistungPreis.text=''" />
			</mx:VBox>
		</mx:VBox>
	
	<!--   Produkte   -->
			
		<mx:VBox label="Produkte" height="100%" width="100%"  paddingLeft="8" paddingTop="8" paddingRight="8" paddingBottom="8" backgroundColor="#f8f8f8" borderColor="#e0e0e0" borderThickness="1" borderStyle="solid">
			<mx:Text text="Produkte" fontWeight="bold" fontSize="14" color="#3D98FF"/>
			<mx:DataGrid variableRowHeight="true" editable="true" height="100%" itemEditEnd="updateProdukt(event)" id="produkteGrid" wordWrap="true" dataProvider="{produkteListe.lastResult.produkte.produkt}" width="100%">
				<mx:columns>
					<mx:DataGridColumn dataField="ID" editable="false" width="30"  />
					<mx:DataGridColumn dataField="Kategorie" />
			        <mx:DataGridColumn dataField="Artikelnummer" width="60" />
			        <mx:DataGridColumn dataField="Bezeichnung" />
			        <mx:DataGridColumn dataField="Inhalt" />
			        <mx:DataGridColumn dataField="VE" width="30" textAlign="right" />
			        <mx:DataGridColumn dataField="EK" width="50" textAlign="right" labelFunction="formatPreis" />
			        <mx:DataGridColumn dataField="VK" width="50" textAlign="right" labelFunction="formatPreis" />
			        <mx:DataGridColumn dataField="Vorrat" width="50" textAlign="right" />
			        <mx:DataGridColumn dataField="Verkauf" itemRenderer="com.renderers.dataGridCheckBox" rendererIsEditor="true" width="60" textAlign="center" />
				</mx:columns>
			</mx:DataGrid>
			<mx:HBox width="100%">
				<mx:Label text="(EK) Waren im Gesamtwert von"  fontWeight="bold"/>
				<mx:Label id="sumEK"  fontWeight="bold"/>
				<mx:Spacer width="100%" />
				<mx:Button label="-" click="loescheProdukt.send()" />
			</mx:HBox>
			<mx:VBox width="100%" height="160" paddingTop="10" horizontalAlign="left" verticalAlign="bottom">
				<mx:Text text="Neues Produkt" fontWeight="bold" width="100%"/>
					<mx:HBox width="90%" height="100%">
						<mx:VBox width="260">
							<mx:HBox width="100%">
								<mx:Label text="Bezeichnung:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktBezeichnung" width="160" />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="Kategorie:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktKategorie" width="160" />								
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="Inhalt:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktInhalt" width="160"  />
							</mx:HBox>
						</mx:VBox>
						<mx:Spacer width="15" />
						<mx:VBox width="140">
							<mx:HBox width="100%">
								<mx:Label text="A-Nr.:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktArtikelnummer" width="80" />								
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="EK:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktEK" width="80"  />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="VK:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktVK" width="80" />
							</mx:HBox>
						</mx:VBox>
						<mx:Spacer width="15" />
						<mx:VBox width="130">
							<mx:HBox width="100%">
								<mx:Label text="VE:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktVE" width="50" />								
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="Vorrat:" />
								<mx:Spacer width="100%" />
								<mx:TextInput id="neuesProduktVorrat" width="50"  />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label text="zum Verkauf:" />
								<mx:Spacer width="100%" />
								<mx:CheckBox id="neuesProduktForSale" selected="false" />
							</mx:HBox>
						</mx:VBox>
					</mx:HBox>
					
						
						
						<mx:Button label="+" 
							click=" neuesProdukt.send(); 
									neuesProduktKategorie.text=''; 
									neuesProduktArtikelnummer.text='';
									neuesProduktBezeichnung.text='';
									neuesProduktInhalt.text='';
									neuesProduktVE.text='';
									neuesProduktEK.text='';
									neuesProduktVK.text='0.00';
									neuesProduktVorrat.text='';
									neuesProduktForSale.selected=false;" 
						/>
				</mx:VBox>
		</mx:VBox>

Open in new window

Error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at verwaltung/calcSumEK()[/Users/XXX/Documents/Flex Builder 3/Kundenverwaltung/src/verwaltung.mxml:167]
	at verwaltung/__produkteListe_result()[/Users/XXX/Documents/Flex Builder 3/Kundenverwaltung/src/verwaltung.mxml:239]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]
	at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:193]
	at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
	at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
	at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/onComplete()

Open in new window

0
Comment
Question by:druplash
3 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 40309264
What's in the file "verwaltung.mxml" at line 167? Can you post it?
There you have an object that is null where your code doesn't expect it.
0
 
LVL 19

Accepted Solution

by:
Gary Benade earned 500 total points
ID: 40309330
Hi Druplash

Your script is accessing a tab navigator page before it has been created. By default the tabNavigator component only creates children as then are needed (deferred instantiation)

You can change the behavior and create all children by specifying the creationPolicy:

<mx:TabNavigator width="100%" height="100%" id="nav2" selectedIndex="0"  creationPolicy="all">

Regards
Gary
0
 

Author Closing Comment

by:druplash
ID: 40309674
Thanks a lot, that works perfect and now i understand the issue.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML 5 or Flash 7 491
Download slideshow or picture elements 16 440
Adobe Flex - Combobox - Disable Editing 15 835
How to convert image files to a movie file 6 113
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question