A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: copy paste text

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    6

    copy paste text

    I have a flash presentation with lots of slides having dynamic text in it. Basically there will be 3 tools :copy: :Paste: :Notepad:.Once the user selects the text and clicks on copy tool it should copy the text and simultaneously the custom notepad tool will be activated by the user which opens an input field. User clicks on the input field and by using the paste tool he will paste the copied content to the input field

    Is there any function through which flash remembers the copied highlighted text on a click event? If yes which is that function?

    how can i paste the same on a click of a button to any text field?

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    look into getBeginIndex/getEndIndex

    create a textField on the stage: (output_txt);

    and try this code:
    PHP Code:
    output_txt.text "wer j34o85 94o57 oiu 5yp988uvoiun p9875t 987t98 7n09v87n0987 n9870987 987t";
    var 
    selectionString:String;
    function 
    copySelected():Void {
        var 
    startIndex:Number Selection.getBeginIndex();
        var 
    endIndex:Number Selection.getEndIndex();
        
    selectionString output_txt.text.substring(startIndexendIndex);
        
    trace("SELECTED TEXT: " selectionString);
    }
    ///*
    var mouseListener:Object = new Object();
    mouseListener.onMouseDown = function () {
        
    };
    mouseListener.onMouseUp = function () {
        
    copySelected();
    };
    Mouse.addListener(mouseListener); 
    should capture the selected text from the dynamic textField and store it in a variable.. you can just 'paste' the data form that var into another textfield..

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    6
    Quote Originally Posted by whispers
    look into getBeginIndex/getEndIndex

    create a textField on the stage: (output_txt);

    and try this code:
    PHP Code:
    output_txt.text "wer j34o85 94o57 oiu 5yp988uvoiun p9875t 987t98 7n09v87n0987 n9870987 987t";
    var 
    selectionString:String;
    function 
    copySelected():Void {
        var 
    startIndex:Number Selection.getBeginIndex();
        var 
    endIndex:Number Selection.getEndIndex();
        
    selectionString output_txt.text.substring(startIndexendIndex);
        
    trace("SELECTED TEXT: " selectionString);
    }
    ///*
    var mouseListener:Object = new Object();
    mouseListener.onMouseDown = function () {
        
    };
    mouseListener.onMouseUp = function () {
        
    copySelected();
    };
    Mouse.addListener(mouseListener); 
    should capture the selected text from the dynamic textField and store it in a variable.. you can just 'paste' the data form that var into another textfield..
    hey tat was a cool one.
    But i have 100s of field.. i have to give instance name to all the fields. Can this be avoided??

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    1.) you should ALWAYS give everything, including textField instance names..its just proper technique... if they dont have instance names and are dynamic as you stated..how are you populating them with text?

    anyways.. in the above... just add a line or so.. to change the instance name above.. to use what textField has current focus..

  5. #5
    Junior Member
    Join Date
    Dec 2008
    Posts
    6
    thnx for reverting

    they r namesake dynamic. its as good at static fields. I hv populated them manually.

    Is there a solution??

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    nope..not that I know of.. maybe look into the snapshot of textField/movieClips..

    Ive never used it before.

  7. #7
    the cheesy child bounceboy's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    323
    what you can do is
    on(press){
    variable1 = variable2;
    }
    if you want whatever is in the clipboard to paste into the button, i'm not sure if that works. the best you can do is set what the clipboard is without pressing control+c (copying) like this:
    on(press){
    System.setClipboard(variable1);
    you may be able to do this:
    variable2 = System.setClipboard();
    }

  8. #8
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Im curious as to how this helps anything?

    how is going to get the selected text from with a dynamic text field, that doesnt have an instance name, with what youve posted??

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