Calling functions from main.asc

Ask a Question related to Macromedia Flash Flashcom, Design and Development.

  1. #1

    Default Calling functions from main.asc

    hi all,
    i'm new to flash com server ... made the following example to explain what i'm
    trying to do... the bottom line is that i want to forexample be able to connect
    to a remote server and after i connected write something to a textbox on the
    page (which is in fla)

    // here is the code in my main.asc which works
    //=============================



    load("components.asc");

    application.onConnect =function(newClient,newUserName) {
    application.acceptConnection(newClient);
    newUserName = "amir";
    gFrameworkFC.getClientGlobals(newClient).username =newUserName;


    //application.clients[application.clients.length - 1].call("testing");
    // if i uncomment the line above, the connection light stays red and
    // my attempt to connect fails

    trace("here");
    // first off no trace is called meaning i dont see
    // "here" printed to the output panel
    // #2 issue is that i want to call that function
    // called "testing" which is in my fla file
    // and not in this main.asc

    }







    // ==============================
    //here is the code in frame one of my flafile

    #include "NetDebug.as"
    myConnection_nc = new NetConnection();
    myConnection_nc.onStatus = function(info) {
    tracebox = "LEVEL: " + info.level + " CODE: "+info.code ;
    };

    testing = function (argument) {
    box2.text = argument;
    }

    myConnection_nc.connect("rtmp://myremoteaddress.com/tokenizer", "token this");

    // the connection light does turn green indicating connection
    // having been made successfully
    connectionlight.connect(myConnection_nc);

    // ==============:brokenheart;

    Tokenizer Guest

  2. Similar Questions and Discussions

    1. Calling other functions
      All, Using .NET 1.1, I have built a custom control, however I am having trouble compiling it. For the on click event of the button, I want it to...
    2. Calling functions between frames...
      JavaScript can not run on server side. You can include it in the output of your PHP script. "Albert Finchly" <Albert_Finchly@Yahoo.co.uk>...
    3. Calling Sub from Main form
      Hello all, Is it possible to call a Subform Event Procedure in a subform, from the Main form. "Example" names: frmMyMainForm frmMySubForm -...
    4. Calling functions?
      Hello, I wrote a jscript function within the HTML window of my webpage and would like to call it from inside the ASPX code-behind page. Any...
    5. calling functions
      how do i call a vbscript function (which is between <%%>) from a vbscript script function (which is between script tags-<script...
  3. #2

    Default Re: Calling functions from main.asc

    >// first off no trace is called meaning i dont see
    >// "here" printed to the output panel
    You won't see "here" on the output panel within flash. You have to load up the
    FlashComm application inspector, click on the instance of your application that
    is running, and select "View Detail". Your trace statements will show up under
    the
    "Live Log" window.
    >// #2 issue is that i want to call that function
    >// called "testing" which is in my fla file
    >// and not in this main.asc
    }
    >In your FLA file, you have to define the function as a function of the
    netConnection.
    > myConnection_nc.testing = function(argument){
    > box2.text = argument;
    }

    Then, on the serverside, the clientSide function can be accessed as a function
    of the newClient:
    ================================================== =========================
    load("components.asc");

    application.onConnect =function(newClient,newUserName) {
    application.acceptConnection(newClient);
    newUserName = "amir";
    gFrameworkFC.getClientGlobals(newClient).username =newUserName;
    trace("here");


    newClient.call("testing","This is a message from the serverside!");

    }




    Cheers,

    FlashTastic





    FlashTastic Guest

  4. #3

    Default Re: Calling functions from main.asc

    thanks flashtastic

    in regards with the locaiton of the trace() output , i see it now .... makes
    sense of course

    however i have no luck with with the newClient.call("testing", "asdfasdf"),

    on the fla side, i did as you said

    my_conn_obj.testing = function(myArg) {
    _root.dynamicTextBox.text = myArg;
    trace("testing is called by server side");
    }

    ... on the asc side, i have

    application.onConnect ... so on so forth:
    newClient.call("testing","print this argument");
    close application.onConnect
    // sorry for my lazy explaination above

    this is what leads to textbox having no text
    and no trace being called

    location of this testing definition in my code is above my_conn_obj.connect()
    .... i did that to make sure that testing function is defined before the
    ..connect

    regards
    Tokenizer








    Tokenizer Guest

  5. #4

    Default Re: Calling functions from main.asc

    Sorry about that, little error in the code there.

    When you call the client side function from the server-side, call it like so.

    ClientObj.call("testing",null,"print this argument").

    The 2nd parameter is reserved to define a result function, if you're expecting
    a return value from the call, so If you're not passing a value back to the
    server-side function, you have to put it as null.

    FlashTastic



    FlashTastic Guest

  6. #5

    Default Re: Calling functions from main.asc

    thanks for your time.... what you told me has been mentioned in identical or
    similar fashions in other tutorials i have looked at, and the fact that i can't
    get it to work hence seems to be a result of configuration of my server or
    something....

    i have the following straight forward code which doesn't work for me... i
    copied and pasted it as one final attempt to get this thing to work before i
    give up on this server....

    can you glance at it and see if i'm not seeing something (it must be something
    small)

    //================
    //code from frame 1 of my FLA file

    #include "NetDebug.as"
    nc = new NetConnection();
    nc.onStatus = function(info) {
    tracebox = "LEVEL: " + info.level + " CODE: "+info.code ;
    };

    nc.sayHelloClient = function(arg) {
    trace("here");
    return (Math.random());
    }


    nc.connect("rtmp://myserver/myapplication", "User Name", "password");

    connectionlight.connect(nc);

    //=========================
    // code in the main.asc

    load("components.asc");

    application.onConnect =function(newClient,newUserName,password) {
    application.acceptConnection(newClient);
    gFrameworkFC.getClientGlobals(newClient).username =newUserName;
    trace(newClient.ip);
    // the above does print the ip when i look at the application inspector
    newClient.call("sayHelloClient", new randHandler());
    }

    randHandler = function(){
    this.onResult = function(res){
    trace(res);
    }
    this.onStatus = function(info){
    trace("failed and got:" + info.code);
    }
    }

    // ============
    // that is it, shouldn't this work? it's not rocket science



    Tokenizer Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139