A Flash Developer Resource Site

Page 3 of 4 FirstFirst 1234 LastLast
Results 41 to 60 of 64

Thread: My right click menu FK tute is finally done. Would you try to break it for me?

  1. #41
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,979
    what I'm using similar code for - this came MONTHS after I started to figure it out - it did help with the XSL though - that was actually kicking my behind if I did not plan ahead for enough entities - a dynamic site. The tables are basically queried from SQL 2k, and saved down to a temp XML file... which is then parsed using the XSL, and a CSS on top of that to maintain levels and icons.

    However, the right click context part is what you are interested in... my levels are way more similar than you probably need. btw, not truly my idea... I was drinking a similar beverage, and got upset about the current look of the project I'm working on - now that code, I can not divulge.

    the right click (or control click for macs - you gotta plan for that one), if you warn the users, will be used. I mean... tell them, for extra options, use right click.

    btw, I totally agree with you. good luck... if I can help, I'll try.

    but I'm SO code weary at the moment

    Originally posted by Sem
    <spraying current beverage all over screen> OMG! Let's find a way!! This is über-cool. When I am less buzzed (consumption due to a long day at work), I plan on devouring this idea. You don't mind do you (your idea, after all)? I just want to see it happen. I believe the context menu should live up to it's adjective - it should provide additional options for the currently selected item, which should include web pages. No one seems to get angry with context menu changes when they click it over an icon, or on an application's window, right? Why should it be different for a web site? As long as the developer uses it responsibly, and designs the context menu to make the user's surfing experience easier for the particular page, what is wrong with that? Erm, time to step off my soap box What do you think, gerbick?

  2. #42
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by gerbick
    now that code, I can not divulge.
    I'm totally hip. All of my good Flash work is blanketed by that nasty word "propriety" and won't see the light of day

    Thanks for the offer, I may pester you for XML pointers, be warned..

    Sem.




  3. #43
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,979
    Originally posted by Sem
    Thanks for the offer, I may pester you for XML pointers, be warned..
    LOL! if you only knew... I've had an issue with XML.load in Flash for like the last two months... been too busy with work to sort it out... and what's worse... I truly don't think I can... anyway, if I can... I'll try...but understand if I say I can not... I'm only being truthful.

    good luck with your endeavors... I'll be watching.

  4. #44
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by gerbick
    Originally posted by Sem
    Thanks for the offer, I may pester you for XML pointers, be warned..
    LOL! if you only knew... I've had an issue with XML.load in Flash for like the last two months... been too busy with work to sort it out... and what's worse... I truly don't think I can... anyway, if I can... I'll try...but understand if I say I can not... I'm only being truthful.

    good luck with your endeavors... I'll be watching.
    If you can describe what you are trying to do - generally - maybe I can indirectly help you out. I haven't dabbled with XML, but I've found that the quickest way I learn is to have a problem I need to figure out and can research (that's why I originally joined FK - skulking around in the Help forums helped me grow). Hell, make something up just to get me started...

  5. #45
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    by Sem
    Yeah, Stickman found out that if you click on the gray areas (the part of the flash movie that actually has graphics), the Flash context appears, and if you click on the transparent background the custom menu appears.
    In fact (credit where it's due!) it wasn't me that pointed it out first, it was bvgroote -- I just offered an explanation.

    Good luck sorting out the probs.

  6. #46
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by Stickman
    by Sem
    Yeah, Stickman found out that if you click on the gray areas (the part of the flash movie that actually has graphics), the Flash context appears, and if you click on the transparent background the custom menu appears.
    In fact (credit where it's due!) it wasn't me that pointed it out first, it was bvgroote -- I just offered an explanation.

    Good luck sorting out the probs.
    Thanks for the help. Gerbick has got me started on an XML/XSL mission - I'm not sure if it will work with Flash, but it will sure be fun trying (and I'll come out knowing at least a little bit about XML and XSL). Not sure, but the method may help with the following quote:


    Originally posted by Ekostudios

    Tips:
    If the context window ONLY popped up when right clicking on the .swf and not when clicking elsewhere it would solve Johnie's issue with loosing the normal context window.
    We'll see - could be a wild goose chase...

    Sem.
    [Edited by Sem on 10-19-2001 at 04:30 AM]

  7. #47
    Senior Member
    Join Date
    Jul 2000
    Posts
    5,087
    Originally posted by Sem
    BTW, would a mod mind editing the post in the thread that displays this source code? It's not that I want to keep it a secret or anything, it's just that the version posted is a hybrid version of robert penner's code. I'd like permission from him before it gets posted on a public forum. It's the polite thing to do

    Sem.
    I editted out the source code.

  8. #48
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by johnie
    Originally posted by Sem
    BTW, would a mod mind editing the post in the thread that displays this source code? It's not that I want to keep it a secret or anything, it's just that the version posted is a hybrid version of robert penner's code. I'd like permission from him before it gets posted on a public forum. It's the polite thing to do

    Sem.
    I editted out the source code.
    Thanks, johnie

    Sem.

  9. #49
    cheese me. TrIzKuT's Avatar
    Join Date
    May 2001
    Posts
    771
    cool....
    hold control and click somewhere on the page...

    You'll get a kick out of it

  10. #50
    Senior Member
    Join Date
    Mar 2000
    Posts
    177
    Great work, Sem.

    Stickman, Flash can detect mouse right-click, although it's not a widely-known technique.

    Paste this code onto a movieclip instance:
    Code:
    onClipEvent (enterFrame) {
    	rButton = Key.isToggled(2);
    	if (rButton != old) {
    		// put your right-click actions here
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    Sem, this may just solve the problem you were running into. Javascript no longer has to capture the right-click. All it has to do is position the DHTML menu (and the back button stuff).

  11. #51
    Senior Member
    Join Date
    Mar 2000
    Posts
    177
    Originally posted by robertpenner
    Code:
    onClipEvent (enterFrame) {
    	rButton = Key.isToggled(2);
    	if (rButton != old) {
    		// put your right-click actions here
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    An explanation of the above code--

    The Key object is used to detect keyboard interaction. For some reason, Flash treats the right mouse button as "key 2" (and the left mouse button as key 1).

    The Key object has two methods that are useful here:
    Key.isDown(2)
    Key.isToggled(2)

    Whenever you press the right mouse button, the value of Key.isToggled(2) toggles from true to false or vice versa. Thus, if you compare the values of Key.isToggled(2) from one frame to the next, and they're different, you know the button was pressed.

    Also, Key.isDown(2) will return true if the right mouse button is currently being held down.

    One last thing--you can do these things also with the scroll-wheel button by using Key.isToggled(4) on PC and (I think) Key.isToggled(3) on Mac.


  12. #52
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by robertpenner
    Great work, Sem.

    Stickman, Flash can detect mouse right-click, although it's not a widely-known technique.

    Paste this code onto a movieclip instance:
    Code:
    onClipEvent (enterFrame) {
    	rButton = Key.isToggled(2);
    	if (rButton != old) {
    		// put your right-click actions here
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    Sem, this may just solve the problem you were running into. Javascript no longer has to capture the right-click. All it has to do is position the DHTML menu (and the back button stuff).
    You just saved me two weeks of perplexed stares and furious nail-biting. You are my hero. Thanks for the large tip.

    Sem.

    P.S. Robert, how on Earth do you discover the things you do?



    [Edited by Sem on 10-20-2001 at 06:06 AM]

  13. #53
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by robertpenner
    Great work, Sem.

    Stickman, Flash can detect mouse right-click, although it's not a widely-known technique.

    Paste this code onto a movieclip instance:
    Code:
    onClipEvent (enterFrame) {
    	rButton = Key.isToggled(2);
    	if (rButton != old) {
    		// put your right-click actions here
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    Sem, this may just solve the problem you were running into. Javascript no longer has to capture the right-click. All it has to do is position the DHTML menu (and the back button stuff).
    Thanks, this just saved me two weeks of perplexed stares and furious nail-biting. You are my hero.

    Sem.

    P.S. Where [i]do[/] you discover these things?



    ...

  14. #54
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Originally posted by robertpenner
    Great work, Sem.

    Stickman, Flash can detect mouse right-click, although it's not a widely-known technique.

    Paste this code onto a movieclip instance:
    Code:
    onClipEvent (enterFrame) {
    	rButton = Key.isToggled(2);
    	if (rButton != old) {
    		// put your right-click actions here
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    Sem, this may just solve the problem you were running into. Javascript no longer has to capture the right-click. All it has to do is position the DHTML menu (and the back button stuff).

    Strange, the third page of my thread won't display unless these duplicate posts are present. As soon as I delete one, page three is no longer available. Mods, any ideas?

    Sem.

  15. #55
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    Code:
    Stickman, Flash can detect mouse right-click
    Humbly, I stand corrected.

    After all the years I've been working with Flash, I'm still hearing about new undocumented features on a regular basis. Sometimes I wonder if there's some sort of secret cabal you have to be indicted into to get told this sort of thing...

  16. #56
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    Just to be nit-picky...

    You'll need to add the following code to your movie clip, otherwise you'll get the 'if' condition triggered the first time the code is run:

    Code:
    onClipEvent (load) {
        old = Key.isToggled(2);
    }

  17. #57
    Senior Member
    Join Date
    Mar 2000
    Posts
    177
    Good catch, Stickman. I rejigged it so you don't need the load initialization:
    Code:
    onClipEvent (enterFrame) {
    	rButton = !Key.isToggled(2);
    	if (rButton ^ old) {
    		trace ("right click detected");
    	}
    	old = rButton;
    }
    The ^ is the bitwise XOR operator. So exotic! =]

    BTW, the secret cabal is called Flashcoders. http://www.chattyfig.figleaf.com

  18. #58
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    The ^ is the bitwise XOR operator. So exotic! =]
    Now you're just showing off!

    BTW, the secret cabal is called Flashcoders.
    Thanks for the tip. I tried it before but never had the time to keep up. Maybe I should give it another go...

  19. #59
    Firmly Fastened to the Milk Sac of Misanthropy
    Join Date
    Aug 2000
    Posts
    463
    Robert,

    So, how did you find out the key code for the mouse buttons? Sitting down on the crossroads around midnight? The MM's AS Ref Guide makes no mention of it under Key.isToggled. I tried to squeeze the information out by using Key.getCode, but it only seems to recognize keyboard action. I'm going to have to pop off to Flashcoders and sift through the avalanche...

    Hmmm.

    Sem.
    [Edited by Sem on 10-21-2001 at 04:10 PM]

  20. #60
    Senior Member
    Join Date
    Jul 2000
    Location
    Not on the dole any more
    Posts
    1,040
    I'm afraid I'm going to nit-pick again...

    There seems to be a small problem with Robert's revised code (with XOR). It would appear that the isToggled state of the right mouse button persists from one execution of the code to another.

    Take this scenario:

    - launch the code
    - press the right mouse button once
    - reload the code
    - a right mouse button press event is triggered, even though the right mouse button hasn't been pressed

    This remains the case until the right mouse button is pressed again.

    The solution I suggested above (using onLoad) seems to partially fix the problem -- it sometimes resets immediately, sometimes takes a couple of reloads (in a browser). Any suggestions as to why this might be the case would be appreciated.

    Of course it's not a major problem -- the worst that will happen is that the right-click code might get executed erroneously under some circumstances.

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