A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: How to create custom links in the viewers right click menu ?

  1. #1
    Senior Member
    Join Date
    May 2009
    Posts
    213

    How to create custom links in the viewers right click menu ?

    Ive noticed a lot of flash websites have user defined items/links added to the default flash right click settings menu. In other words when we right click on such flash websites it shows links to the designers home page or associated site etc. Can i know how this is done please ?

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    something like this:

    PHP Code:
    function customLink() {
        
    getURL("http://www.someaddy.com"_blank);
    }
    MENU = new ContextMenu();
    MENU.hideBuiltInItems();
    menuLink = new ContextMenuItem("link text here"customLink);
    MENU.customItems.push(menuLink);


    this.menu MENU
    Evolve Designs Interactive Media
    the natural selection

  3. #3
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    This is beautiful. Been wanting to get this info.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  4. #4
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi Ryan,

    PHP code meaning this has to be done within PHP ?
    Or do i use this code within the Flash Interface in an action keyframe ?
    I dont know PHP . I know this is going to sound extremely dumb. But is PHP a software i have to install and learn like flash ? Or is it just something like a plugin ?

    Thank You.

  5. #5
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    I could be wrong, but he just used the PHP tags in here to highlight the various syntax in his code. This code should be placed within Flash.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  6. #6
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi,

    I tried the code as actionscript and it worked !

    Thanks Ryan.

    I wonder what i should do to have 2 or more links ?
    Last edited by plainman007; 12-19-2011 at 08:38 AM.

  7. #7
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    hi again!

    Here's an example of two menu items, you should get the idea. Don't mind my lame names, you can name your custom items whatever.

    PHP Code:
    function customLink() {
        
    getURL("http://www.google.com"_blank);
    }
    function 
    customLink2() {
        
    getURL("http://www.ebay.com"_blank);
    }
    MENU = new ContextMenu();
    MENU.hideBuiltInItems();
    menuLink = new ContextMenuItem("google"customLink);
    menuLink2 = new ContextMenuItem("ebay"customLink2);
    MENU.customItems.push(menuLinkmenuLink2);


    this.menu MENU
    "But is PHP a software i have to install and learn like flash ? Or is it just something like a plugin ?"

    It's a programming language used to make standard HTML more dynamic (that's how i see it anyways hehe).. It runs on your server (server side code) so unless you run your own server you don't install anything. The more you use Flash, the more likely it is that you'll need some php to send data to/from a database from flash or pulling xml from a remote server etc. Probably did nothing to answer your question but provide more nerdy confusion hahah but there yo u have it!


    ps yeah i always wrap code in php tags because of the color formating as samac1068 said
    Last edited by EvolveDesigns; 05-22-2009 at 05:02 PM.
    Evolve Designs Interactive Media
    the natural selection

  8. #8
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi Ryan, Thank you for your help.

    Your description of PHP was far from nerdy. Its the easiest kind i understand.
    I grasp thats its a language that helps retrieve and post data into a database located on a server , maybe an SQL database.

    So when a hosting company says PHP is offered along with the services provided it means we can use their provided PHP to write a program that we need for our own website needs by logging into the hosting control panel.

  9. #9
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hello Ryan,

    I tried the double link code and it works flawlessly. Thanks to you.
    May i ask if its possible to also have a command instead of only a URL ?
    I mean is it possible to have a link that says "contact us" on the menu and when the user clicks it opens a mailto: instruction like we do with a mailto: text ? So when they click this link it would probably open outlook express or so with our mail id prefilled ?

  10. #10
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    Yup you can do anything you can normally do with flash. Notice this line:

    menuLink = new ContextMenuItem("google", customLink);

    It puts the word google on your menu and when clicked it runs the function customLink so you can change google to anything such as contact us. so now let's look at customLink:

    function customLink() {
    getURL("http://www.google.com", _blank);
    }

    anything between the {} brackets will be ran when 'google' is clicked so that can also be something like

    function customLink() {
    getURL("mailto:you@somedomain.com");
    }

    or

    function customLink() {
    trace("hey look a button was clicked!");
    }

    or

    function customLink() {
    gotoAndPlay(4);
    }
    Evolve Designs Interactive Media
    the natural selection

  11. #11
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi Ryan,

    This is fabulous. I cant wait to try that first thing tomorrow.
    Will let you know how it goes.
    I cant thank you enough !!!

  12. #12
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi,

    Thanks. All these worked well for me. Sorry to revive this thread after so long, But ive been travelling and couldnt log on here for awhile. I have one more question to ask.

    Is it possible when a right click is done for just a warning box to appear saying "Right Click Deactivated" with an ok button to click and dismiss the warning ? I saw this also on one site and just wanted to know.

    Thanks a lot.

  13. #13
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    Technically, you can't disable the right-click menu. I can envision some tricky use of javascript to bring up that sort of prompt upon right-clicking, but i've never played with anything like that. If you can find it, post an example link, I'd enjoy checking it out.
    Evolve Designs Interactive Media
    the natural selection

  14. #14
    Senior Member
    Join Date
    May 2009
    Posts
    213
    Hi Ryan,

    Unfortunately now i dont remember the url of the site which i saw. Pretty dumb of me i know. lol. I will try remembering or im sure will find some site like this and i will defnitely point you to the link so you can see for yourself.

    Thanks and Regards

  15. #15
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    Hey I did some tests for this and I don't think it's possible. Even when using javascript, it only works when not right-clicking the swf itself. You can test this by replacing <body> in your html with <body oncontextmenu="return false;">

    If you do find something that seems to work please do post back
    Evolve Designs Interactive Media
    the natural selection

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