A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: custom trace class ??

  1. #1
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165

    custom trace class ??

    hello

    I am trying to do this thing entirely in actionscript, and hence have to use mtasc to compile it.......

    the problem i have with doing this entirely in actionscript and hence not having to use the IDE, is how do I receive any trace statements ??

    I've seen mentions of using a custom trace class

    but I can't find an example of such a thing

    can anyone please explain to me how it works, and possibly how to make one ??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  2. #2
    Junior Member
    Join Date
    Apr 2007
    Posts
    20
    perhaps haXe is usefull for you..

  3. #3
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    I might have a look at that one day when I have some time on my hands ....

    but meanwhile i currently have this project entirely in actionscript and it'd be so very helpful if I could quickly add trace capabilities to it to make debugging slightly easier now that i'm not using the IDE..

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  4. #4
    Member
    Join Date
    Aug 2007
    Posts
    61
    Download the debug player from adobe and follow these instructions

    All trace will then be sent to a file which you can monitor.

  5. #5
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    thankyou

    one problem, where can I find a debug player for linux??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  6. #6

  7. #7
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    thankyou

    though one problem, with my project, none of the buttons work in that player

    it does in the browser player, but not that one

    is it possible for a firefox plugin for the debugger player?

    (my project can be found here http://delfick.storage.googlepages.com/flashbsm.zip)

    thnx....
    if you find some of my ideas weird, look at my avatar for the reason

  8. #8
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    this might be an alternative: I usually replace all trace() calls by _root.mytrace() [if you can #define that, it certainly helps]
    The mytrace function uses localconnection to send to a second browser window. The process is somewhat slow (adding lots of text to a scrolling text field in flash compared to adding the text to a native window or a file)
    It might be helpful to add a button to the trace window that sends the textfield contents to a file on the server

    Musicman

  9. #9
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    ok then....

    are you able to give an example of that please ??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  10. #10
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    that's the code I use for thze movie:
    Code:
    function mytrace(text) {
            var lc = new LocalConnection();
            lc.send('tracelog', 'text', text);
    }
    and that's the receiver:
    Code:
    function mytrace(txt)
    {       log += txt + '\n';
            log.scroll = log.maxscroll;
    }
    receiver = new LocalConnection();
    receiver.text = function(txt)
    {       mytrace(txt);
    };
    receiver.connect('tracelog');
    Musicman

  11. #11
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    cool, i think i can sort of understand that, but it isn't working.....

    attached is what i've quickly made up, and i open the reciever swf up and then the client.swf but nothing happens in the reciever.swf

    thnx for your help (and patience )
    Attached Files Attached Files
    if you find some of my ideas weird, look at my avatar for the reason

  12. #12
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    I cannot open your fla, only look inside the swf. You are using theText as an instance name where I used log as a variable name. So the code should change to
    Code:
    function mytrace(txt)
    {       theText.text += txt + '\n';
            theText.scroll = theText.maxscroll;
    }
    receiver = new LocalConnection();
    receiver.text = function(txt)
    {       mytrace(txt);
    };
    receiver.connect('tracelog');
    Musicman

  13. #13
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    hmmm, it still doesn't want to connect to each other

    I have
    code:
    function mytrace (text)
    {
    var lc = new LocalConnection ();
    lc.send ('tracelog', 'text', text);
    }
    for (i = 0; i < 30; i++)
    {
    mytrace (i);
    }


    in the client.fla

    and
    code:

    this.createTextField("theText", 9, 10, 10, Stage.width-20, Stage.height-20);
    theText.border = true
    function mytrace (txt)
    {
    this.theText.text += txt + '\n';
    this.theText.text.scroll = this.thetext.text.maxscroll;
    }
    receiver = new LocalConnection ();
    receiver.text = function (txt)
    {
    mytrace (txt);
    };
    receiver.connect ('tracelog');



    in the reciever.fla

    .... and nothing ever happens...
    Last edited by delfick; 08-26-2007 at 08:59 PM.
    if you find some of my ideas weird, look at my avatar for the reason

  14. #14
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    YAY!

    thnx to this here http://kb.adobe.com/selfservice/view...liceId=2#lcas2

    I've changed them to be this in the client.fla
    code:
    var lc = new LocalConnection ();
    function mytrace (text)
    {
    lc.send ('tracelog', 'tracer', text);
    }
    for (i = 0; i < 30; i++)
    {
    mytrace (i);
    }



    and this in the reciever.fla

    code:
    this.createTextField ("theText", 9, 10, 10, Stage.width - 20, Stage.height - 20);
    theText.border = true;
    function mytrace (txt)
    {
    this.theText.text += txt + '\n';
    this.theText.text.scroll = this.thetext.text.maxscroll;
    }
    var receiver = new LocalConnection ();
    receiver.connect ('tracelog');
    receiver.tracer = function (txt)
    {
    mytrace (txt);
    };



    and it works

    thankyou very much for your help
    if you find some of my ideas weird, look at my avatar for the reason

  15. #15
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    so the next question becomes, how do i use this #define thing you mentioned ??

    and is it possible to use different textFormats on different parts of the same text field ??

    thnx
    if you find some of my ideas weird, look at my avatar for the reason

  16. #16
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    and i've managed to create this nice little trace window
    (unfortunately the code it uses is from my aforementioned project, and it's fairly messy code, but it seems to work )
    Attached Files Attached Files
    if you find some of my ideas weird, look at my avatar for the reason

  17. #17
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    so then, I've made it all very much better now

    can be found here http://flashbsm.googlecode.com/svn/testing/tracer/
    to download it all, have subversion installed, and with the command
    svn checkout http://flashbsm.googlecode.com/svn/testing/tracer/

    my problem is though, that I want to make it slightly better in that when I call the trace function, I can also set a particular colour for the next line of text.

    So I'm wondering if it's possible for a text field to hold different coloured lines of text ?

    the code in question is in ui/windows.as (after following that link above) lines 240-246

    code:
    if (colour != undefined)
    {
    logger += "***** I want the next line of text to be of the colour : " + colour + "\n";
    }
    logger += text + "\n";
    container.canvas.tracer.tracer_txt.text = logger;
    addItem ("scroller");



    ...

    thnx
    Last edited by delfick; 01-05-2008 at 11:29 AM.
    if you find some of my ideas weird, look at my avatar for the reason

  18. #18
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    don't worry about it

    found the solution

    seeing as all my colours in my code are already as numbers, I changed it so that it accepts numbers and changed the above code to read

    code:
    if (colour != undefined)
    {
    logger += "<font color='#" + colour.toString(16) + "'>" + text + "</font>\n";
    }
    else
    {
    logger += "<font color='#000000'>" + text + "</font>\n";
    }
    container.canvas.tracer.tracer_txt.htmlText = logger;
    addItem ("scroller");



    problem solved
    if you find some of my ideas weird, look at my avatar for the reason

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