Hi Clint,

I've just this very moment solved that one!  :-)  I couldn't get what was going on either, but this is what I did:
For the sake of trying it out a created a new application to do it.
I left all the imports and var declarations where they were, but put all the rest of the method calls and functions inside another function and then called that function using the creationComplete application tag attribute.
see below
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApplication()">
    <mx:Script>
        <![CDATA[
            import flash.net.FileFilter;
            import flash.net.FileReference;
            import flash.net.URLRequest;

            public var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *jpeg, *.gif, *.png)","*.jpg; *jpeg; *.gif; *.png");
            public var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *rtf)","*.txt; *.rtf");
            public var allTypes:Array = new Array(imageTypes, textTypes);
            public var myFileRef:FileReference = new FileReference();
           
            public function initApplication(): void
            {
                myFileRef.addEventListener(Event.SELECT, selectHandler);
                myFileRef.addEventListener(Event.COMPLETE, completeHandler);
                myFileRef.browse(allTypes);
                try {
                    var success:Boolean = myFileRef.browse();
                } catch (error:Error) {
                    trace("unable to browse for files");
                }
           
                function selectHandler (even:Event):void
                {
                    try {
                        var params:URLVariables = new URLVariables();
                        params.date = new Date();
                         var request:URLRequest = new URLRequest("http://www.myplace.com/FlexImageUpload.php");
                        request.method = URLRequestMethod.POST;
                        request.data = "">                          myFileRef.upload(request, "fileField");
                    } catch (error:Error) {
                        trace("Unable to upload file");
                    }
                }
           
                function completeHandler(event:Event):void
                {
                    trace("Uploaded");
                }
            }
        ]]>
    </mx:Script>
</mx:Application>


Clint Tredway wrote:
code from the docs. I am just trying to get a file upload working so I can make sure I understand it correctly.

On 7/5/06, Carson Hager < [EMAIL PROTECTED]> wrote:

What code are you referring to?
 
 
 
Carson

____________________________________________
 
Carson Hager
Cynergy Systems, Inc.
http://www.cynergysystems.com
 
Email:  [EMAIL PROTECTED]
Office:  866-CYNERGY
Mobile: 1.703.489.6466

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Clint Tredway
Sent: Tuesday, July 04, 2006 11:32 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] file uploads

I am using the code from the docs and Flex Builder is telling this 1120: Access of undefined property fileRef.   and that the selectHandler and completeHandler are undefined properties as well. I am declaring the var fileRef, so i dont get why its doing this... very frustrating...


--
diabetic? http://www.diabetesforums.com
Bill Cosby - A word to the wise ain't necessary - it's the stupid ones that need the advice.




--
diabetic? http://www.diabetesforums.com
Bill Cosby - A word to the wise ain't necessary - it's the stupid ones that need the advice.

-- 
______________________________________________________________ 
Phil Marston 
Learning Technologist
Learning Technology Unit 
Edward Wright G33, University of Aberdeen, Aberdeen, AB24 3QY, UK
[EMAIL PROTECTED] Tel: +44(0)1224 273329 / +44(0)7798 723660 
http://www.abdn.ac.uk/diss/ltu/pmarston/
http://www.abdn.ac.uk/diss/ltu/
______________________________________________________________

The University of Aberdeen Open Day 29th August 2006
Booking is essential
www.abdn.ac.uk/openday
email [EMAIL PROTECTED]
or call 0800 027 1495
__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

Reply via email to