Application Development Tips and Tricks > Adding a privacy module |
![]() ![]() ![]() |
Adding a privacy module
When creating applications that capture client audio or video streams, you should provide users with explicit notice that you are doing so, and request their permission. Including a self-view is a good way to let the user know that they are "on camera" and a transmission light or microphone activity indicator can let that person know that the microphone is on. For live communication applications it is always a good idea to give the user easy access to controls that allow them to turn their camera and microphone off and to mute the audio they are receiving.
Many of the sample applications provided in the Flash Communication Server applications directory illustrate how to implement one or more of these techniques. The following sample shows one way to request the user's permission before recording. You can find the sample file for this code in the /flashcom_help/help_collateral/doc_approval directory under the installed Macromedia Flash MX authoring directories or in the server's installation directory.
To create the privacy module:
1 |
In the Flash MX authoring environment, select File > New to open a new file. |
2 |
From the Components panel (Window > Components), drag the Push Button symbol under Flash UI components to a position near the bottom of the Stage. In the Property inspector (Window > Properties), give it the instance name |
3 |
From the options menu in the Library panel (Window > Library), select New Symbol, and give it the name |
4 |
On the |
Note: Please note that this text is provided merely as an example, and the precise wording of the text that you use will be dictated by the nature of your application and/or service and any privacy, legal, or other issues raised by your application and/or service. |
|
5 |
Drag two instances of the Push Button symbol onto the |
6 |
Copy and paste the following code to the Actions panel for the first frame of the movie: |
stop(); var userAnswer = false; function doRecord() { // If user selects button to record... if (Record_btn.getLabel() == "Record") { // Call function to get user's approval to record. getApproval(); // When user has provided an answer, if the answer's // yes, begin to record, otherwise, send a status // message WarnNow_mc.onUnload = function () { // If user approved, Record. if (userAnswer == true) { // // Record // . // . // . // trace("Recording..."); // Change the button label Record_btn.setLabel("Stop"); // Else if user refused, give status. } else { trace("User did not approve streaming."); } } // Else if user selects button to stop recording... } else if (Record_btn.getLabel() == "Stop") { trace("Stopped Recording."); // Change the button label Record_btn.setLabel("Record"); } } function getApproval(){ // Attach the movie clip to prompt user input, // and align it on the stage. _root.attachMovie("warnRec_mc", "WarnNow_mc", 1); var x = 275; var y = 160; setProperty("WarnNow_mc", _x, x); setProperty("WarnNow_mc", _y, y); // If the user selects the Yes button, they // approved the recording. So, set userAnswer // to true, unload the movie clip and return // the updated userAnswer value. WarnNow_mc.Yes_btn.onRelease = function () { userAnswer = true; trace("userAnswer: " + userAnswer); WarnNow_mc.unloadMovie(); trace("Returning: " + userAnswer); return userAnswer; } // If the user selects the No button, they // do not want to record. So, set userAnswer // to false, unload the movie clip and return // the updated userAnswer value. WarnNow_mc.No_btn.onRelease = function () { userAnswer = false; trace("userAnswer: " + userAnswer); WarnNow_mc.unloadMovie(); trace("Returning: " + userAnswer); return userAnswer; } } |
|
7 |
Create a directory named doc_approval in your Flash Communication Server applications directory, and save your file as doc_approval.fla in this directory. |
You can now publish and test the application.
![]() ![]() ![]() |