# Right Click

**URL:** <https://forum.kirupa.com/t/right-click/9373>\
**Category:** flash\
**Created:** [December 10, 2002, 4:27pm UTC](https://forum.kirupa.com/t/right-click/9373 "2002-12-10T16:27:44Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dravos](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Dravos](https://forum.kirupa.com/u/Dravos)\
**Post date:** [December 10, 2002, 4:27pm UTC](https://forum.kirupa.com/t/right-click/9373/1 "2002-12-10T16:27:44Z")

</div>

I found this code but dont fully understand it, it is supposed to enable right mouse clicking and using flash studio pro by mdm u can remove the rioght hand click menu

```php

Stage.showMenu = false;
this.rObj ={
onRightKlick:function(){
this.rKlick=ASnative(800,2)(2);

this.rKlick? (testme._alpha-=10):undefined; 
}
}
setInterval(this.rObj,'onRightKlick',70);

```

now does this code work in flash mx or is it ssomething to do with flash studio pro??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 1:14am UTC](https://forum.kirupa.com/t/right-click/9373/2 "2002-12-11T01:14:50Z")

</div>

That code looks mixed up a bit.

The img src… tags shouldn’t be there. I think the code should read like this (line numbers added for clarity):

```php

1) Stage.showMenu = false;
2) this.rObj ={
3) onRightKlick:function(){
4) this.rKlick=ASnative(800,2)(2);
5) this.rKlick? (testme._alpha-=10):undefined; 
6) }
7) }
8) setInterval(this.rObj,'onRightKlick',70);

```

As far as deciphering what that means, you’re on your own. 🙂

I understand all the lines, except line 4. ASnative is an undocumented AS method in Flash MX, but I don’t know what it does. You probably should do a search for that online. As far as I can tell, the code above won’t do much on it’s own.

I don’t think it makes a difference which version of Flash MX you are using. AS is the same across them all. I could be wrong on this, though.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 4:09am UTC](https://forum.kirupa.com/t/right-click/9373/3 "2002-12-11T04:09:13Z")

</div>

It is

```auto

Stage.showMenu = false;
this.rObj = {onRightKlick:function () {
	this.rKlick = ASnative(800, 2)(2);
	this.rKlick ? (testme._alpha -= 10) : undefined;
}};
setInterval(this.rObj, 'onRightKlick', 70);

```

But there are a lot of things missing in this code. Dravos must not have posted the whole thing, just part.

And I don’t think there is a way to have a right click menu come up in Flash.

This code is a bit advanced. Not many people know how to use (or even about) the ?: operators as if/else statements (gotta love obfuscated code :)).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 4:14am UTC](https://forum.kirupa.com/t/right-click/9373/4 "2002-12-11T04:14:23Z")

</div>

Oh yeah and ASNative is like the same as Math.random(), but there is no benefit to using ASNative… I guess just to look cooler and more advanced. ASNative is no faster than Math.random().

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 5:58pm UTC](https://forum.kirupa.com/t/right-click/9373/5 "2002-12-11T17:58:55Z")

</div>

Actually Lost, ASNative() is not Math.Random.

> ASNative() is available in Flash 5, but may not exist in future versions.

In general, ASNative (i, j) returns a function reference. It’s like all the Flash functions are stored in a spreadsheet, and you can access them by rows and columns with ASNative. A convenient way to work with ASNative functions is to assign the result to a variable, and then execute the variable as a function.

Example:

t = ASnative(100, 4); // trace function  
t(“hi”); // output: hi

Some other math commands using ASNative:

```php
ASnative(200, 0 ) // [[Math] abs 
ASnative(200, 1) // [[Math] min 
ASnative(200, 2) // [[Math] max 
ASnative(200, 3) // [[Math] sin 
ASnative(200, 4) // [[Math] cos 
ASnative(200, 5) // [[Math] atan2 
ASnative(200, 6) // [[Math] tan 
ASnative(200, 7) // [[Math] exp 
ASnative(200, 8) // [[Math] log 
ASnative(200, 9) // [[Math] sqrt 
ASnative(200, 10 ) // [[Math] round 
ASnative(200, 11) // [[Math] random 
ASnative(200, 12) // [[Math] floor 
ASnative(200, 13) // [[Math] ceil 
ASnative(200, 14) // [[Math] atan 
ASnative(200, 15) // [[Math] asin 
ASnative(200, 16) // [[Math] acos 
ASnative(200, 17) // [[Math] pow

```

The reason why ASNative is used because it’s much faster than the direct commands. Also, Flash AS for end users isn’t as powerful as we’d like it to be.

Dravos actually used ASnative(800, 2) // [[Key] isDown, but as the quote says, ASNative **may** not exist in future versions.

h88 :bandit:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:04pm UTC](https://forum.kirupa.com/t/right-click/9373/6 "2002-12-11T18:04:55Z")

</div>

Hey h88, I’d love to know where you found that info. I’m looking for info on other undocumented AS commands (such as ASconstructor, etc.). Also, when you say that using ASnative(100,4), which is the trace() command is _faster_ than just using trace(), how much faster do you mean? Is it worth our while to use ASnative (ignoring the fact that it may disappear in future versions of flash)? I’d like to optimize and streamline my code as much as possible, and if ASnatvie gives a big enough performance boost, I think I’ll try it.

Also, where would I find a list of all the ASnative commands?

TIA.  
-Al

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:09pm UTC](https://forum.kirupa.com/t/right-click/9373/7 "2002-12-11T18:09:01Z")

</div>

If you’re manipulating XML then AS Native can be very noticeably (as in several seconds) faster. Also the XML nitro function strips whitespace in all F5players not just version30.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:22pm UTC](https://forum.kirupa.com/t/right-click/9373/8 "2002-12-11T18:22:06Z")

</div>

Yup jsk, your right on that one, alethos, Yeah, It is worth our while to use ASnative, but i personally don’t use them, u can find ASNative commands here:

[http://chattyfig.figleaf.com/flashcoders-wiki/index.php?full=ASNative](http://chattyfig.figleaf.com/flashcoders-wiki/index.php?full=ASNative)

And other undocumented features here:

[http://chattyfig.figleaf.com/flashcoders-wiki/index.php?Flash%20MX%20features%202](http://chattyfig.figleaf.com/flashcoders-wiki/index.php?Flash%20MX%20features%202)

Hope it helps.

cheers;  
h88 :bandit:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:27pm UTC](https://forum.kirupa.com/t/right-click/9373/9 "2002-12-11T18:27:41Z")

</div>

I haven’t worked wih XML yet, although I have a project in mind that will use it. What’s this nitro function you speak of, and isn’t integrated XML support new to F6 and it’s players?

As for the code posted initially by Dravos, it sort of makes sense now. Keycode 2 is not listed in Macromedia’s site, so I’m guessing it’s linked to the right mouse button. So basically, the idea of having your own context-sensitive menu pop up with a right click might be possible. This is what you’d need, Dravos, according to your code:

```php

Stage.showMenu = false; // This disables the regular right-click menu, but leaves Macromedia's "about" option when u right click.
this.rObj = {onRightKlick:function () {
	this.rKlick = ASnative(800, 2)(2); // This is checking to see if key code #2 (I assume this is right-click) is pressed.
	this.rKlick ? (testme._alpha -= 10) : undefined; // This is a conditional statement that basically fades out the MC called testme. Why you'd fade out a MC, I don't know.
}};
setInterval(this.rObj, 'onRightKlick', 70); // This basically keeps running "onRightKlick" every 70ms to see if the user has right clicked.

```

The code is incomplete as has been mentioned before. You could put the Key.isDown event inside an on enterFrame event handler and pop that into a MC. Then if Key.isDown(2), you fade in or pop-up a MC drawn to look lie a context sensitive menu, and have it relocate to the mouse position. That would work IF keycode 2 is in fact the right mouse button. I think I’ll give this a try when I get home from work today. I’ll tell you how it goes, Dravos.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:30pm UTC](https://forum.kirupa.com/t/right-click/9373/10 "2002-12-11T18:30:25Z")

</div>

Ooo, thanks h88! I will definitely check those out!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 6:57pm UTC](https://forum.kirupa.com/t/right-click/9373/11 "2002-12-11T18:57:03Z")

</div>

Hey h88, thanks for the info on ASNative. I didn’t read up too much on undocumented AS, so I was just going by memory, and for some reason that was all I remembered about it.

Thanks for clearing that up though.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 9:47pm UTC](https://forum.kirupa.com/t/right-click/9373/12 "2002-12-11T21:47:10Z")

</div>

“Branden Hall’s XML Nitro routine, […]makes use of an undocumented AS function to parse XML objects and makes the ignoreWhite property of the XML object available in all versions of the Flash 5 player.”

source [http://www.macromedia.com/desdev/articles/tools\_xmlobject.html](http://www.macromedia.com/desdev/articles/tools_xmlobject.html)

Basically it’s a quick way of cleaning up a XML source ready for parsing without having to rely on the ignoreWhiteSpace() function which is only implemented in later versions of the F5 player.

Flash has a non-validating parser and doesn’t discrininate cdata from tags - it assigns each one a node. Without the ignoreWhiteSpace() function flash generates a load of empty nodes for carriage returns, linebreaks, etc.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 11, 2002, 11:22pm UTC](https://forum.kirupa.com/t/right-click/9373/13 "2002-12-11T23:22:57Z")

</div>

Well, Dravos, I tried it, and here’s what happens. Keycode 2 is in fact the right mouse button, and when I right click, me custom menu MC does pop up next to the mouse, but so does Macromedia’s built-in menu, but all options are gone except SETTINGS and the ABOUT option. This built-in menu floats above my custom one. If i try to click a button on my custom menu, all that happens is the built-in menu disappears and I have to click again on my button for it to register. So obviously this solution will not work, since the built-in menu will capture the next left click once it is up. In my opinion it would be too confusing to the average user to have to right click, then left click to remove the built in menu, then left click the button on your custom menu.

On the plus, side, this DOES teach us the keycode for right-click, opening the doors for some fun stuff, especially if I can get ahold of the keycodes for the middle mouse button and the wheel some mouses (It’s “mice” for the animals, but “mouses” for the device, right?) have!!

-Al

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2002, 3:15pm UTC](https://forum.kirupa.com/t/right-click/9373/14 "2002-12-12T15:15:41Z")

</div>

Thanx for the ASNative bit

I have now modified it and created a movieclip called box.

in the root script i have:

```php

_root.onLoad=function()
{
	Stage.showMenu = false;
	box.rObj ={
		onRightKlick:function(){
			box.rKlick=ASnative(800,2)(2);
			box.rKlick? (box._alpha-=10):undefined; 
		}
	}
	setInterval(box.rObj,'onRightKlick',70);
}

```

so this is supposed to fade the box out when you right click

I cant actually get it to work though

Any thoughts???

And if you go to [www.multidmedia.com](http://www.multidmedia.com) they have a program called Flash Studio plus which is free for non commercial use, it converts swf into exe and can completely remove the right click menu. it also allows the background to be tranparent, ME XP only ithink

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2002, 3:40pm UTC](https://forum.kirupa.com/t/right-click/9373/15 "2002-12-12T15:40:34Z")

</div>

OK if i put this in the root script

```php

_root.showMenu = false;

function rightKlick(obj)
{
	rKlick=ASnative(800,2)(2);
	rKlick? (obj._alpha-=10):undefined;
}

```

and this in the box script:

```php

onClipEvent(enterFrame)
{
	_root.rightKlick(this);
}

```

So this works but i dont like the on enter frame bit, how can i get the setInterval to work?? Is it available in flash 5?? i cant find it in the as dictionary

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2002, 3:42pm UTC](https://forum.kirupa.com/t/right-click/9373/16 "2002-12-12T15:42:29Z")

</div>

sorry forgot to disable smilies again but you know what i mean

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2002, 3:43pm UTC](https://forum.kirupa.com/t/right-click/9373/17 "2002-12-12T15:43:28Z")

</div>

Unfortunately, there is not setInterval in flash 5.0.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2002, 4:21pm UTC](https://forum.kirupa.com/t/right-click/9373/18 "2002-12-12T16:21:42Z")

</div>

Ahhh i did wonder thanx
