This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
AS3.0 Replay the whole movie (*SWF file)
I made a small game in Actionscript 3.0 and flash.
When the player wins the game or is 'game over' my player should have 2 options. Besides replay i want the player to be able to quit the game from wihin the game. So there a way to close/quit/kill the flash player with actionscript ?
Well, you have 2 options:
System.exit
fscommand("quit")
If you want to kill the flash object inside the web page, that would be possible using JavaScript, using swfobject.removeSWF. There is a sample here.
No. You cannot kill the VM with actionscript. There are some AS3 commands to pause/resume (sleep) the flash player VM but these ONLY work in debug mode, which can only be launched locally from the IDE. It may be possible to remove the item using some server side or client side HTML/JS or something but absolutely not from within the VM itself.
Well, yes, you could use Flash to call JavaScript and remove the div/span which is holding it (see fscommand and ExternalInterface), but I don't think that is your best option -- it is too prone to failure and it is too subject to its environment.
If you can, just navigate away from that page using navigateToUrl(new URLRequest(<ip>), "_self")
Related
I am basically looking for a way to use multiple mouse plugged into one device so that multiple pointers can be seen and operate. This is for e-learning purposes, the goal is to have multiple students play an educational game in a classroom that has only got one PC but upto 10 or more mouse connected to a PC.
I did something similar a couple years ago in microsoft XNA framework. Currently I am developing applications and games in Adobe Flash AS3 and would like to find out if there is anyway that we can have multiple mouse functionality in a flash application?
Any sort of help would be great. Thank you!
For the web, this is probably impossible. If your flash project run on Adobe Air, you can add native code to handle this kind of functionality or you can use a local socket server to send information over socket to your swf or air application.
Example for native extension
I have 2 monitors on my computer, also am writing a program on AS3 that is exported to standalone SWF. My task is to make my app fullscreen on 2nd screen. How can I do this?
I tried converting my project to AIR project. It is possible there by using nativeWindow property of Stage. (setting x coordinate so that it appears in second screen and then call fullscreen). It works in Flash, but when I'm running compiled swf outside Flash, my app crashes (nativeWindow property not found).
So please do help me to solve my problem. I am disappointed, have been looking for solution for already 3 days...
You have to stick with your AIR application and use it as it is supposed to: run the .air file. You can't launch an AIR swf alone because it will miss all the AIR runtime including the NativeWindow you are insterested in.
To be clear, you can't manipulate windows from a swf launched with the Flash Player.
Another solution would be to execute your swf from a web browser and use javascript called through ExternalInterface to move the windows. But it may be quite painful in comparison with AIR.
I would like to play a flash animation when someone talks in the VoIP program Ventrilo.
I have a simple animation setup within Adobe Flash and I would like to somehow trigger it when a specific person talks "keys-up" in Ventrilo.
I know the G15 keyboard can access Ventrilo remotely and display who is talking in real time so I think it should be possible to use this event to trigger a movie clip play command if I knew how to access it. I have looked for example code but can't find any.
I know this is probably a highly complex task but I'm sure there is a genius on Stackoverflow how knows how to do it or could at least set me on the right path.
Many thanks,
This is not going to be an easy task and is going to require writing a C/C++ ANE.
You can use Windows API hooking to intercept calls from Ventrilo.
http://www.gamedev.net/topic/387670-api-hooking/
http://www.codeproject.com/Articles/2082/API-hooking-revealed
You would need to write an ANE to use this inside your AIR app.
http://www.flexjunk.com/2011/11/30/developing-an-air-native-extension-for-osx-and-windows-in-c/
I have a quick question relating to Actionscript 3 / AIR. I have looked through the site, but may be searching for the wrong thing or terms.
Is it possible to get an application wide audio stream from an AIR application?
I am trying to create a local audio file containing everything (all channels) played in an AIR app.
Does anybody have any ideas or suggestions?
Kind regards,
Phil
Update:
I have tried using the SoundMixer.computeSpectrum() function, but it returns a bytearray (size 2480) full of zeros...
It looks like it isn't reading the audio data correctly... I am playing a swf loaded using a SwfLoader and it is playing the sound out...
Odd... Anybody got an idea..?
There is SoundMixer.computeSpectrum, which will give you the global waveform or frequency data for the app. Unfortunately, it is fairly unreliable, and if you are trying to piece together the entire accurate audio stream, it is probably insufficient. But it might be enough to suit your needs if you are making, say, a visualizer or something else that only wants to know the current state of the audio stream.
Have you looked at SoundMixer Class? It has a computeSpectrum method that can get all playing sounds into a ByteArray, if I'm not totally misinterpreting the docs there.
I have existing flash 8 AS2 work that I want to update to Flash 10. Can I update only those elements i need to be Flash 10 and load them in to the Flash 8 movie as an external swf and pass variables and call methods? Is this a good option and what are the issues to be aware of? Eg will a user with player lower than 10 be able to load the flash 8 movie and then find that it breaks because the flash 10 wont load or will the player realise that there is flash 10 content and inform the user that they need to upgrade their player?
thanks
Several questions are overlapping here.
You can update parts of your content without updating the root, but interoperability becomes hairy. When the Flash player plays a SWF, it executes it according to the version tag in the file, not the version tag of the SWF that loaded it. So your F8 content can load in F10 SWFs without any particular issue, except for the following point.
However, if an AS2 SWF loads in an AS3 SWF (or vice versa), communication between them is hairy. I seem to recall there's some limited hand-waving support for setting variables in the root of one or the other, but for anything complicated the recommended method is to use LocalConnection. I've played with it and as I said it's hairy.
Whether content updated to version 10 will play in older versions of the Flash player is a separate question from either of the previous, and the answer is the same regardless of whether it's a lone SWF or newer SWFs loaded into older SWFs. And the answer is, the older player will attempt to play the content, but any newer features won't work, and Flash will not automatically tell the person to upgrade, or refuse to show your content until they do.
You might be able to load Flash 8 into Flash 10 but I would be very surprised if the reverse is true.