dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Can someone help me debug this script

  1. #1
    Junior Member
    Join Date
    May 2001
    Posts
    24
    start = 0;
    string_length = trivia_contents.length;
    while (start <= string_length) {
    start = start+1;
    trivia_fragment = trivia_contents.substr(start,1);
    if (trivia_fragment eq '*') {
    trivia_rebuild = trivia_rebuild && '&';
    } else {
    trivia_rebuild = trivia_rebuild && trivia_fragment;
    }
    }

    _________________
    the gist of it is that i'm rebuilding the variable 'trivia_contents' into 'trivia_rebuild' while changing the character '*' into '&'.

    but it doesn't seem to work...can someone find what's wrong?

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    Well I'm not going to debug it, but I can give you a much simpler way of replacing "*" with "&".

    trivia_rebuild = trivia_contents.split("*").join("&");

  3. #3
    Junior Member
    Join Date
    May 2001
    Posts
    24
    oh, ok thankx...

    i guess i haven't learned the new deals with mx...i'm still stuck at a flash 4 mindset :P

    thankx, it works

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    If you want the corrected script, it would be something like this:

    trivia_contents = "*THIS IS A TEST! -> * * * *";
    trace("STARTING STRING: "+trivia_contents);

    start = 0;
    string_length = trivia_contents.length;

    while (start <= string_length) {
    trivia_fragment = trivia_contents.substr(start,1);
    if (trivia_fragment == '*') {
    trivia_fragment = "&";
    trivia_rebuild += trivia_fragment;
    } else {
    trivia_rebuild += trivia_fragment;
    }
    start +=1;
    }

    trace ("NEW STRING: "+trivia_rebuild);

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