A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [RESOLVED] [F8] Mission Possible ??

  1. #1

    [RESOLVED] [F8] Mission Possible ??

    Hi there im may serve you a very tricky mission !

    im making a interface, that will receive dynamic info from a jsp file
    this works, on tests i have run. Heres the code:

    jsp file:

    ticker1=bla bla not in use yet.
    &time=00.01
    &next=12
    &following1=15.44
    &following2=15.33
    &numvars=5

    heres the actionscript
    code:
    loadVariables("http://www.domain.com/web.jsp", "", "POST");



    QUESTION: it is needed that when the variable "next" has a value of "0"
    a specific textmessage "zero" will appear in the textbox that receives these values

    also its needed when the variable has a value of "0" that a MC instancename:"player"on the root starts to play, this MC i will play 600 (10 fps) frames so it will play a minute
    then goes to stop where its invisible, and awaits instructions to start and play again from the script

    is i this possible

    any comment appreciated !!
    Attached Files Attached Files
    -frgst

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    best to scrap loadVariables and use loadvars for this mission

    Code:
    lv = new LoadVars();
    lv.onLoad = function(){
    trace(unescape(lv)); // output all variables from jsp
    if(lv.next == "0"){ // variables received as "strings"
    _root.myText.text = "zero"; // output to textfield
    _root.player.play(); // start movieclip
    } // end if
    }; // end onLoad
    
    lv.load("http://www.domain.com/web.jsp");
    
    // if sending variables, use -
    // lv.varToSend = "test";
    // lv.sendAndLoad("http://www.domain.com/web.jsp", lv, "POST");

  3. #3

    mission

    Hi a_modified_dog, thanks !

    i tried to implement it, no luck,
    ive modified the movie so the MC player is on the root...(so this function can be tested)
    also : an absolute url is not needed now so i cant test localy, and see if all the text is loading..
    ive sending this modified test2 and hope if you please could implement this code so these functions actually work localy..for that i would be really happy


    you write:

    if sending variables, use -
    // lv.varToSend = "test";
    // lv.sendAndLoad("http://www.domain.com/web.jsp", lv, "POST");
    is this function needed in this current movie for solving the problem, or is this a supplementary function ?
    Attached Files Attached Files
    -frgst

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    cannot open your fla in Flash 7,

    your web.jsp is received by the LoadVars object as -
    Code:
    _level0.lv = [object #1, class 'LoadVars'] {
        onLoad:[function 'onLoad'],
        ticker1:"bla bla.not in use yet\n",
        time:"00.00\r\n",
        next:"4\n",
        following1:"15.44\n",
        following2:"15.33\n\n\n\r\n",
        numvars:"5"
      }
    in order for the code to work you have two options -

    1) get the jsp to output a closing ampersand (&)-
    &ticker1=bla bla.not in use yet&
    &time=00.00&
    &next=4&
    &following1=15.44&
    &following2=15.33&
    &numvars=5&

    or 2) adjust the if(condition) to encompass the "\n" -

    if(lv.next == "4\n"){
    _root.myText.text = "four";
    _root.player.play();
    }

  5. #5

    mission

    OK,

    i send over a mx version, im relatively new to this, so reverse engineering is the way for me in this case, still learn much from this !
    Attached Files Attached Files
    -frgst

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    file attached
    the method assumes that the format of the jsp file will never vary

  7. #7

    mission NOT impossible III

    TONS of thanks man

    it works like rock solid!!

    you really did solve this seemingly impossible issue !

    ------

    only numbers are dynamic the format is frozen and will be

    is this ASscripting in the movie compatible with an error script if jsp is not loaded?
    the message "offline" is needed to appear in a textbox "offline_tex"
    and message "online" will appear in textbox "online_tex"
    maybe something like this code ?

    code:
    var my_lv:LoadVars = new LoadVars(); 
    my_lv.onLoad = function(success:Boolean) {
    trace("LoadVars loaded successfully: "+this.loaded);
    if (success) {
    _root.user1Text.text= this.user;
    } else {
    _root.user2Text.text = "Error!";
    }
    };

    -frgst

  8. #8

    mission

    OK this errorscript i now implemented succesfully - not need help

    ---

    ive now tested this movie online on domain, and there is 2 issues i observed:

    online testing proove that it works !


    when remote jsp file is unaccessable, all textfields shows text: "undefined" this is unwanted, and not prett to look at

    so what can i do just get blank text fields (nothing) when the remote jsp i offline?
    -frgst

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    control textfield output from the onLoad function -
    Code:
    lv.onLoad = function(success){
    if(success){ // data has loaded
    // fill all of the textfields with received variables
    } else { // data has failed
    // fill all of the textfields with blanks
    time = "";  next = ""; // and so on ...
    }
    }

  10. #10

    mission

    Thanks for code and good expl.

    so how will the syntax be?

    sending you what i have now, so how will the whole code look like including your last code? tried ti implement, but got some unexpected results

    code:
    function loadJSP(){
    lv = new LoadVars();
    lv.onLoad = function(){
    trace(unescape(lv));
    str = unescape(lv).split("\n").join("");
    arr = str.split("&");
    for(var n=0;n!=arr.length;n++){
    arr[n] = arr[n].split("=");
    }
    time = arr[4][1];
    next = arr[3][1];
    following1 = arr[2][1];
    following2 = arr[1][1];
    if(arr[3][1] == "0"){
    next = "";
    _root.player.play();
    }

    };

    lv.load("web.jsp");
    };

    loadJSP();

    -frgst

  11. #11
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    function loadJSP(){
    lv = new LoadVars();
    lv.onLoad = function(success){
    if(success){
    trace(unescape(lv));
    str = unescape(lv).split("\n").join("");
    arr = str.split("&");
    for(var n=0;n!=arr.length;n++){
    arr[n] = arr[n].split("=");
    }
    time = arr[4][1];
    next = arr[3][1];
    following1 = arr[2][1];
    following2 = arr[1][1];
    if(arr[3][1] == "0"){
    next = "";
    _root.player.play();
    } else {
    time = "";
    next = "";
    following1 = "";
    following2  = "";
    } // end if/else
    }; // end onLoad
    
    lv.load("web.jsp");
    };
    
    loadJSP();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center