How to capture RIGHT_CLICK in FlashDevelop? - actionscript-3

I wish to add an event listener for the MouseEvent.RIGHT_CLICK event in FlashDevelop.
In Flash CS6's editor, I can simply do:
stage.addEventListener(MouseEvent.RIGHT_CLICK, onMouse);
But MouseEvent.RIGHT_CLICK does not seem to exist in FlashDevelop.
I tried 'disabling' the context menu:
stage.showDefaultContextMenu = false;
But still to no avail. How can I get this to work?

Make sure your FlashDevelop project settings target a Flash Player version high enough to support the RIGHT_CLICK event; that being at least Flash Player 11.2.

Related

Seekbar for mp3 player in Actionscript 3.0 Flash CS-6

I'm trying to create a music player in Flash CS6. I'm new to Flash. I have created the play/pause/volume buttons. I have also been able to extract the mp3 information using the id3 tags. So i have the song duration. I now need to create a seekbar/progress bar. I have taken the progress bar from the components, but do not understand how to code it now. Please help!
According to the reference on Sound.play():
public function play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel
where the first argument is
startTime:Number (default = 0)//The initial position in milliseconds at which playback should start.
so you can call
channel.stop();
channel = sound.play(offset);
There is an example in the reference. Hope this helps.
You can get some idea using my audio player on my Github page.Also it's developed using flash CS6 and ActionScript 3.0. Use it, change it and develop your future with ActionScript .

AS3: Custom native cursor [Flash CS4]

I'm currently developing a flash game using Adobe Flash CS4 Professional and AS3.
I have a custom cursor set up in my game, but it only changes position when the game renders a frame, 30 times per second, which could be better, so i want a custom native cursor.
Custom native cursor is a feature of Flash Player 10.2+, but in Flash CS4 i can only publish as Flash Player 10, and i can't have a custom native cursor.
So how do i add a custom native cursor to my game? Any workarounds/hacks appreciated.
I wont be buying a later version of Flash since this will probably by my last Flash game, as i will start to use Unity3D.
EDIT:
I used this tutorial from an answer below. I can now publish as Flash Player 10.2 or any other version i want. But i still can't get a custom native cursor working. I get the following error: VerifyError: Error #1014: Class flash.ui::MouseCursorData could not be found.
How can i make the flash.ui.MouseCursorData class work with Flash Pro CS4?
This is my code:
var bitmapDatas:Vector.<BitmapData> = new Vector.<BitmapData>(1, true);
var bitmapData:BitmapData = new CustomCursor(32,32);
bitmapDatas[0] = bitmapData;
var cursorData:MouseCursorData = new MouseCursorData();
cursorData.hotSpot = new Point(0,0);
cursorData.data = bitmapDatas;
Mouse.registerCursor("MyCursor", cursorData);
Mouse.cursor = "MyCursor";
You need to add a new playerglobal.swc and a new Flash Player target configuration. Here's a tutorial that is specific to Flash CS5 and Flash Player 11, but should work for CS4 and any player you want.

Action Script navigateToURL not working with stage3d

this simple code is not working for me :
stage.addEventListener(MouseEvent.CLICK, OnClick);
protected function OnClick(e:MouseEvent)
{
navigateToURL(new URLRequest("http://www.stackoverflow.com"), "_blank");
}
later i want url to open from flascc but that can be easily done if this works,
if this is because of security reason then is there any other way to do this? i saw in game called decision 2 their urls work even in debug version flash player + in all browsers. so there must be some other way to do this if navigateToURL dosent work.
Add the folder f:\flascc (or all disk f:) to the flash trusted locations in the security panel (you can also open this panel by the right click on any swf opened in the browser)

how do you find error in a SWF?

i feel stupid asking that question, but it seems like i'm unable to find out.
i have a SWF that works perfectly inside flash. once i export as SWF, it doesn't work anymore.
i can't use "trace"
i have tryed that function but it doesn't trigger it for some reason. :
function quikTrace(string:String){
//INIT VARIABLES
var tmpTxtField:TextField;
//TEXTFIELD PROPERTIES
tmpTxtField = new TextField();
tmpTxtField.text = string;
tmpTxtField.x = stage.width / 2;
tmpTxtField.textColor = 0xFFFFFF; //white (black background)
tmpTxtField.y = stage.height / 2;
addChild(tmpTxtField);
}
is there any "outside the box" way to find errors in a SWF?
You can view trace statements in the browser by doing a few quick steps:
Get a debug flash player for your browser. link
Set up mm.cfg to enable flash logging to a file. link
Get a text editor / "tail" viewer and read the flashlog.txt file that is generated. This is where FireBug & Flashbug come in handy, if you're in firefox. You can also try baretail for PC, or regular old "tail -f" on a mac/linux machine.
Good luck.
It's not a stupid question at all! You're just learning how to debug Flash for the first time. You can use "trace" with an exported SWF by doing a debug/test build from Flash IDE or Flash Develop. You can then read these traces with Firefox by using the extentions Firebug combined with the Flashbug extension. Now you're all set for getting feedback using traces.
For this particular problem, it's hard to say. Is this function inside of a class or timeline code? If it's a class, it probably because Stage is not ready yet. You can use the event Event.ADDED_TO_STAGE to know when the Stage reference is ready to be used.
Hope this helps!
Install a debug version of flash player for your browser. It will tell you exactly which line of code is throwing error.
http://www.adobe.com/support/flashplayer/downloads.html

How does one stop a SWF Movie dynamically loaded using the Loader class using ActionScript 3.0?

MovieClip(_loader.content).stop();
this.removeChild(_loader);
_loader.unload();
_loader = null;
I've been trying that, but it doesn't stop the movie. The movie has an embedded voiceover
and that keeps running. thank you.
Flash 10 introduced unloadAndStop(); (_loader.unloadAndStop() if it's named _loader like in your example) and if you are using Flash 10 then you should use this.
But the original idea of what Adobe intended in AS3 for Flash 9 was that the loaded in swf would be self reliant, able to detect when it was removed and stop the sound from within itself. Use this inside the swf that is being loaded in, so that it can detect when it is removed from the stage, and therefore shut down it's own sound:
addEventListener(Event.REMOVED_FROM_STAGE, swfWasRemoved);
function swfWasRemoved(event: Event) : void
{
// inside this function shut down the sound that is inside the swf
}
If the only remaining thing that is playing is the sound, use SoundMixer.stopAll() to stop that as well.
Make sure the embedded voice over is set to stream. If its on event, it will just keep playing until it's done regardless of the playhead of the swf.