A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Context Menu -add Copy to standard menu choice?

    Hi,

    Im working on a flash project and was wondering if its possible to change the standard context menu to include the "copy" function of the edit context menu. Basically, I would like my static text to be able to be copied with the right click menu choice "copy" that would come up for editable text. Is this possible?

    Thanks,
    Yvette
    Last edited by yvillicana; 03-05-2006 at 03:25 AM.

  2. #2
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Thats already built into flash.

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Built into Flash?

    Hi Corky,

    Built into Flash where? It's my understanding that there are two menus-A standard context menu with options such as Zoom, Quality, Play, etc.
    And an edit context menu which shows up for dynamic or input text with options such as Copy, Paste, etc. What I need is to add the copy option to the standard menu so that static text can be copied with a right click.
    If I'm missing something please help.

    Thanks,
    Yvette

  4. #4
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    If you make the static text selectable, then yes, it does appear when you select the text.

  5. #5
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Ooh, my bad. Use this script.

    function copy() {
    System.setClipboard(_root.myInstanceBox);
    }
    MENU.customItems.push(Functioned1);
    MENU = new ContextMenu();
    MENU.hideBuiltInItems();
    Functioned = new ContextMenuItem("Copy text", copy);
    MENU.customItems.push(Functioned);
    MENU.customItems.push(Functioned2);
    _root.menu = MENU;

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Thanks again,

    However, it doesnt quite work-Menu displays the correct options but what it copies to the clipboard is _root.myInstanceBox not the contents of the box.

    Yvette

  7. #7
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Hi Corky,

    I found that if I put the actual text I want copied in quotes inside the copy function line:
    System.setClipboard("text I want copied");
    It will work.
    However, I need it to work for a few instances which appear on the stage simultaneously. Im thinking I can create a string variable to use which changes on rollover. Is there an easier way?

    Thanks again,
    Yvette

  8. #8
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Hi Corky,

    I found another work around.
    If I put this in the function
    System.setClipboard(_root.myInstanceBox.text);
    and define what _root.myInstanceBox.text equals it ll work.

    Is this the way to go?

    Thanks,
    Yvette

  9. #9
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Yes. Sorry. I was in a rush and didnt test the code.

    _root.myInstanceBox.text would be correct.

    Ask for more help if required

    Mike

  10. #10
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Works but not in my project

    Hi Mike,

    Thanks a lot. It works fine if I make a little flash movie to test it, but when I go to test it in my project it doesnt. I have no idea why as I removed nearly all my project's code and layers to test it and it still doesnt work. Is there anything that might prevent it from working that you are aware of. The project Im working on doesnt reference the context menu at all. I'm perplexed.

    Thanks,

    Yvette

  11. #11
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Using the code
    Stage.showMenu=false
    might prevent it from showing.
    Make sure you use the menu script on frame 1.

  12. #12
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Everything is removed, but it still wont work

    Hi Mike,

    Thanks for all your help. I actually deleted everything in the fla and just drew a rectangle on the stage and it still doesnt work.


    www.mpendragon.com/test.fla

    Here's the fla maybe you can figure it out. I cant.

    Thanks,
    Yvette

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