dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Self replicating program

  1. #1
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441

    resolved [RESOLVED] Self replicating program

    Can anyone use AS3 (or AS2 I suppose) to write a script that can reproduce itself? Successful program should export code (into a TF or the output panel) that can be copied into a new flash file and run to repeat the same output indefinitely.

    I've seen this posed for other languages but I'm not sure how to tackle it in AS3...yet.

  2. #2
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    I think I'll give it a shot.

  3. #3
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    Alright, I made one that works:

    AS2:
    Code:
    function selfReplicate(){ var quote=chr(34); var string = codeString+quote+codeString+quote+';'+'selfReplicate();'; System.setClipboard(string); trace(string); } var codeString="function selfReplicate(){ var quote=chr(34); var string = codeString+quote+codeString+quote+';'+'selfReplicate();'; System.setClipboard(string); trace(string); } var codeString=";selfReplicate();

    AS3:
    Code:
    function selfReplicate(){ var quote=String.fromCharCode(34); var string = codeString+quote+codeString+quote+';'+'selfReplicate();'; System.setClipboard(string); trace(string); } var codeString="function selfReplicate(){ var quote=String.fromCharCode(34); var string = codeString+quote+codeString+quote+';'+'selfReplicate();'; System.setClipboard(string); trace(string); } var codeString=";selfReplicate();
    It traces itself and sets the clipboard to itself, so it can be pasted again right away.
    Last edited by Schfifty Five; 06-30-2008 at 01:47 AM.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Damn...nicely done!

  5. #5
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    And here's one that's written in... English (found it with Google):

    Let the following text, enclosed in double quotes, be called Text A.
    (You can really ignore Text A. Just take note of the three dollar
    signs it contains.)


    "Let the following text, enclosed in double quotes, be called Text A.
    (You can really ignore Text A. Just take note of the three dollar signs
    it contains.) $$$ Take pencil and paper, and write the following three
    things down, separated as paragraphs. (That's just boring copying.
    You needn't be interested in the text you're handling.) First, all
    of Text A that precedes the three dollar signs. Second, the whole of
    Text A, enclosed in double quotes. Third, all of Text A that follows
    the three dollar signs. Now step back and try to interpret what you
    have just written."


    Take pencil and paper, and write the following three things down,
    separated as paragraphs. (That's just boring copying. You needn't
    be interested in the text you're handling.) First, all of Text A that
    precedes the three dollar signs. Second, the whole of Text A, enclosed
    in double quotes. Third, all of Text A that follows the three dollar
    signs. Now step back and try to interpret what you have just written.

  6. #6
    He has risen! lefteyewilly's Avatar
    Join Date
    Mar 2001
    Posts
    2,597
    wrong forum...even if it is solved.

    moved.

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