Skip to main content
March 3, 2009
Question

error : Severity and Description Path Resource Location Creation Time Id

  • March 3, 2009
  • 66 replies
  • 11254 views

i have this error :
Severity and Description Path Resource Location Creation Time Id
invalid character or markup found in script block. Try surrounding your code with a CDATA block. essai/src essai.mxml Unknown 1236103965593 182


my source is attach code


Many thanks for your help , 


Lionceau,

    This topic has been closed for replies.

    66 replies

    Participating Frequently
    March 6, 2009
    Lionceau,
    this is being shown becuase your code is throwing an exception on the line fileRef.browse();
    To find out what, you should either use the Flex debugger, or extend the output of your Alert box to include error.message, eg
    Alert.show("Unable to browse for files: message " + error.message);
    That will give you a reason for the exception. You should then check the documentation for ways to resolve that problem.
    Richard
    March 6, 2009
    I have these warnings: "Unable to browse for files"
    "uploaded"
    "11111onUploadClick()"
    "onUploadClick()"

    Why? "Unable to browse for files"
    I am in a good way ?

    this is good ? URLRequest(" http://connectnow.acrobat.com/lionceau01/essai/fileUploadScript.cfm")


    Look i make this code :

    private function onUploadClick():void
    {
    Alert.show("onUploadClick()") ;

    var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
    var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf,*.odt)", "*.txt; *.rtf,*.odt");
    var allTypes:Array = new Array(imageTypes, textTypes);
    var fileRef:FileReference = new FileReference();
    fileRef.browse(allTypes);

    Alert.show("11111onUploadClick()") ;

    fileRef.addEventListener(Event.SELECT, selectHandler);
    fileRef.addEventListener(Event.COMPLETE, completeHandler);
    try {
    var success:Boolean = fileRef.browse();
    } catch (error:Error) {
    Alert.show("Unable to browse for files.");
    }
    function selectHandler(event:Event):void {
    var request:URLRequest = new URLRequest(" http://connectnow.acrobat.com/lionceau01/essai/fileUploadScript.cfm")
    try {
    fileRef.upload(request);
    } catch (error:Error) {
    Alert.show("Unable to upload file.");
    }
    }
    function completeHandler(event:Event):void {
    Alert.show("uploaded");
    }





    Lionceau,
    March 6, 2009
    yes , i find here documentation and example , thar right :
    I must do this :
    I am in a good way?


    var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
    var textTypes:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)", "*.txt; *.rtf");
    var allTypes:Array = new Array(imageTypes, textTypes);
    var fileRef:FileReference = new FileReference();
    fileRef.browse(allTypes);

    When the user has selected the files and clicked the Open button in the OS file picker, the Event.SELECT event is dispatched. If the FileReference.browse() method was used to select a file to upload, the following code is needed to send the file to a web server:

    var fileRef:FileReference = new FileReference();
    fileRef.addEventListener(Event.SELECT, selectHandler);
    fileRef.addEventListener(Event.COMPLETE, completeHandler);
    try {
    var success:Boolean = fileRef.browse();
    } catch (error:Error) {
    trace("Unable to browse for files.");
    }
    function selectHandler(event:Event):void {
    var request:URLRequest = new URLRequest(" http://www.[yourdomain
    try {
    fileRef.upload(request);
    } catch (error:Error) {
    trace("Unable to upload file.");
    }
    }
    function completeHandler(event:Event):void {
    trace("uploaded");
    }





    look more here :
    http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001936.html





    Lionceau,
    Participating Frequently
    March 6, 2009
    Lionceau,
    When you say that it doesn't run, what do you mean? Are you getting runtime errors? Are you simply not seeing any results? What efforts have you put in to debugging in the ways we talked about yesterday? Are you seeing either or both of your alert boxes?
    Two thoughts about your code:
    1) I presume you have somewhere a button that is calling the onUploadClick() event handler? If not, then the code inside that block simply will not run.
    2) In your latest attempt you have added the Event.SELECT event to the Array filterArray. An Array will simply never call this event so you should not expect anything. previously you had added the event to the FileReference object which made sense.
    Lionceau, you must read the documentation for what events etc can be used with what objects. At present it feels like you are just guessing what might go with what - even if something does work that means you will not really advance your understanding of the problem and how to solve a similar one another day.
    Richard
    March 6, 2009
    March 6, 2009
    hi ,

    look , i make this :

    private function onUploadClick():void
    {
    Alert.show("onUploadClick()") ;

    var filterArray:Array = [new FileFilter("*.*", "*.*")];

    filterArray.addEventListener(Event.SELECT, handleFileSelected);

    _filePublisher.browse(UIDUtil.createUID());

    Alert.show("2onUploadClick()") ;
    }







    private function handleFileSelected(event:Event):void
    {
    if(event.target is FileReference)
    {
    var filterArray:FileReference = event.target as FileReference;
    logData("Selected file " + filterArray.name);
    filterArray.removeEventListener(Event.SELECT, handleFileSelected);
    }
    }




    private function logData(str:String):void
    {
    msgBox.text += str + "\n";
    msgBox.verticalScrollPosition = msgBox.maxVerticalScrollPosition;
    }








    Yes i make this , but don't run , why?

    Lionceau,

















    Participating Frequently
    March 6, 2009
    Lionceau,
    that code snippet looks fine so far as it goes: of course you will need an event handler for the SELECT event (otherwise it will look as though your code is doing nothing). I assume you are familiar with writing event handlers: if not there are masses of examples in the Adobe documentation.
    Richard
    March 5, 2009
    I find here more information for browse and download/share a file : http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#load()


    look this, it is good : http://sujitreddyg.wordpress.com/2008/11/04/filereference-in-flash-player-10/

    private function selectFileForUpload(event:Event):void
    {
    var fileRef:FileReference = new FileReference();
    var fileFilter:FileFilter = new FileFilter("Text File","*.txt");
    fileRef.addEventListener(Event.SELECT, handleFileSelected);

    try
    {
    fileRef.browse([fileFilter]);
    }
    catch(error:Error)
    {
    logData("Problem displaying file browse window. Event type - " + event.type);
    }
    }



    I must do this ?
    I am in a good way?


    Lionceau,
    March 5, 2009
    i think that : i don't record file in a server

    I want to stock file in my computer and share with other computer , you understand this ?

    Lionceau,
    March 5, 2009
    but sorry ,this don't help me because I don't know where to start !

    I already watched it before.


    I would like a source, who help me for start !!!


    Lionceau,