Solved

private function works only without TabNavigator?

Posted on 2014-09-07
3
301 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to display a webpage in a flash 10 356
bandwidth 5 67
Java and adobe flash updates 4 44
Flash ActionScript 6 42
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now