Right Click

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


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??

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):


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. :slight_smile:

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.

It is


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 :)).

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().

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:

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:

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

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.

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

And other undocumented features here:

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

Hope it helps.

cheers;
h88 :bandit:

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:


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.

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

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.

“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

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.

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

Thanx for the ASNative bit

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

in the root script i have:


_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 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

OK if i put this in the root script


_root.showMenu = false;

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

and this in the box script:


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

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

Unfortunately, there is not setInterval in flash 5.0.

Ahhh i did wonder thanx