what line code does it stop at or what section

----- Original Message ----
From: John <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, January 22, 2008 7:43:17 PM
Subject: [flexcomponents] TypeError: Error #1009: Cannot access a property or 
method of a null object refe

Hello, 
First off, im new to flex, this is my first app im trying to put into
production. 

Im trying to put this upload 
http://weblog. cahlan.com/ 2006/09/uploadin g-files-with- flex-and- php.html
into a state other then the beginning state and im getting:
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
at main/onSelectFile( )

Heres the as:
[code]====== ========= ========= ========= ========= ========= ========
import mx.controls. Alert;
import mx.collections. XMLListCollectio n;
import mx.collections. ArrayCollection;
import mx.rpc.events. ResultEvent;
import mx.rpc.events. FaultEvent;
import mx.utils.ObjectUtil ;
import flash.events. *;
import mx.controls. *;
import mx.managers. *;
import mx.events.*;
import flash.events. *;
import flash.net.*;

private const _strUploadDomain: String =
"http://data/";;
private const _strUploadScript: String = _strUploadDomain +
"upload.php" ;

private var _arrUploadFiles: Array;
private var _numCurrentUpload: Number = 0;
private var _refAddFiles: FileReferenceLis t; 
private var _refUploadFile: FileReference;

private var _winProgress: winProgress;

private function initApp():void {
Security.allowDomai n("*");
_arrUploadFiles = new Array();
} 

// Called to add file(s) for upload
private function addFiles():void {
_refAddFiles = new FileReferenceList( );
_refAddFiles. addEventListener (Event.SELECT, onSelectFile) ;
_refAddFiles. browse();
}

// Called to remove selected file(s) for upload
private function removeFiles( ):void {
var arrSelected: Array = listFiles.selectedI ndices;

for (var i:Number = 0; i < arrSelected. length; i++) {
_arrUploadFiles[ Number(arrSelect ed[i])] = null;
}
for (var j:Number = 0; j < _arrUploadFiles. length; j++) {
if (_arrUploadFiles[ j] == null) {
_arrUploadFiles. splice(j, 1);
j--;
}
}
listFiles.dataProvi der = _arrUploadFiles;
listFiles.selectedI ndex = 0;
if (_arrUploadFiles. length == 0) {
btnUpload.enabled = false;
} else {
btnUpload.enabled = true;
}
}

// Called when a file is selected
private function onSelectFile( event:Event) :void {
var arrFoundList: Array = new Array();
// Get list of files from fileList, make list of files already on
upload list

for (var i:Number = 0; i < _arrUploadFiles. length; i++) {
for (var j:Number = 0; j < _refAddFiles. fileList. length; j++) {
if (_arrUploadFiles[ i].label == _refAddFiles. fileList[ j].name) {
arrFoundList. push(_refAddFile s.fileList[ j].name);
_refAddFiles. fileList. splice(j, 1);
j--;
}
}
}
if (_refAddFiles. fileList. length >= 1) {
for (var k:Number = 0; k < _refAddFiles. fileList. length; k++) {
_arrUploadFiles. push({label: _refAddFiles. fileList[ k].name,
data:_refAddFiles. fileList[ k]});
}
listFiles.dataProvi der = _arrUploadFiles;
listFiles.selectedI ndex = _arrUploadFiles. length - 1;
} 
if (arrFoundList. length >= 1) {
Alert.show(" The file(s): \n\n• " + arrFoundList. join("\n• ")
+ "\n\n...are already on the upload list. Please change the
filename(s) or pick a different file.", "File(s) already on list");
}
if (_arrUploadFiles. length == 0) {
btnUpload.enabled = false;
} else {
btnUpload.enabled = true;
}
}


// Cancel and clear eventlisteners on last upload
private function clearUpload( ):void {
_numCurrentUpload = 0;
_refUploadFile. removeEventListe ner(ProgressEven t.PROGRESS,
onUploadProgress) ;
_refUploadFile. removeEventListe ner(Event. COMPLETE, onUploadComplete) ;
_refUploadFile. removeEventListe ner(IOErrorEvent .IO_ERROR,
onUploadIoError) ;

_refUploadFile. removeEventListe ner(SecurityErro rEvent.SECURITY_ ERROR,
onUploadSecurityErr or);
_refUploadFile. cancel();
}

// Called to upload file based on current upload number
private function startUpload( booIsFirst: Boolean): void {
if (booIsFirst) {
_numCurrentUpload = 0;
}
if (_arrUploadFiles. length > 0) {
_winProgress = winProgress( PopUpManager. createPopUp( this,
winProgress, true));
_winProgress. btnCancel. removeEventListe ner("click" ,
onUploadCanceled) ;
_winProgress. btnCancel. addEventListener ("click", onUploadCanceled) ;
_winProgress. title = "Uploading file to " + _strUploadDomain;
_winProgress. txtFile.text = _arrUploadFiles[ _numCurrentUploa d].label;
_winProgress. progBar.label = "0%";
PopUpManager. centerPopUp( _winProgress) ;

// Variables to send along with upload
var sendVars:URLVariabl es = new URLVariables( );
sendVars.action = "upload";

var request:URLRequest = new URLRequest() ;
request.data = sendVars;
request.url = _strUploadScript;
request.method = URLRequestMethod. POST;
_refUploadFile = new FileReference( );
_refUploadFile = _arrUploadFiles[ _numCurrentUploa d].data;
_refUploadFile. addEventListener (ProgressEvent. PROGRESS,
onUploadProgress) ;
_refUploadFile. addEventListener (Event.COMPLETE, onUploadComplete) ;
_refUploadFile. addEventListener (IOErrorEvent. IO_ERROR,
onUploadIoError) ;

_refUploadFile. addEventListener (SecurityErrorEv ent.SECURITY_ ERROR,
onUploadSecurityErr or);
_refUploadFile. upload(request, "file", false);
}
}

// Called on upload cancel
private function onUploadCanceled( event:Event) :void {
PopUpManager. removePopUp( _winProgress) ;
_winProgress == null;
_refUploadFile. cancel();
clearUpload( );
}

// Get upload progress
private function onUploadProgress( event:ProgressEv ent):void {
var numPerc:Number = Math.round(( Number(event. bytesLoaded) /
Number(event. bytesTotal) ) * 100);
_winProgress. progBar.setProgr ess(numPerc, 100);
_winProgress. progBar.label = numPerc + "%";
_winProgress. progBar.validate Now();
if (numPerc > 90) {
_winProgress. btnCancel. enabled = false;
} else {
_winProgress. btnCancel. enabled = true;
}
}

// Called on upload complete
private function onUploadComplete( event:Event) :void {
_numCurrentUpload+ +;
PopUpManager. removePopUp( _winProgress) ;
if (_numCurrentUpload < _arrUploadFiles. length) {
startUpload( false);
} else {
Alert.show(" File(s) have been uploaded.", "Upload successful") ;
}
}

// Called on upload io error
private function onUploadIoError( event:IOErrorEve nt):void {
Alert.show(" IO Error in uploading file.", "Error");
PopUpManager. removePopUp( _winProgress) ;
_winProgress == null;
_refUploadFile. cancel();
clearUpload( );
}

// Called on upload security error
private function onUploadSecurityErr or(event: SecurityErrorEve nt):void {
Alert.show(" Security Error in uploading file.", "Error");
PopUpManager. removePopUp( _winProgress) ;
_winProgress == null;
_refUploadFile. cancel();
clearUpload( );
} 
[/code]===== ========= ========= ========= ========= ========= =========

Anyone have any ideas, im racking my brain trying to grasp this. 






      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Reply via email to