How to mute entire flex application? - apache-flex

I'm playing several video streams in my flex application. Plus there are sounds of application UI. Is there possibility to mute entire application or I should silence each of potential sound sources?

Have you tried
SoundMixer.soundTransform = new SoundTransform(0, 0);

I'm pretty sure there is no way to do that with ActionScript out of the box. You'll need to have some manager class that keeps track of all the sounds (Sound, SoundChannel, SoundTransform, etc and your video streams) in your application and that has logic for muting.
If you can force your users to use firefox, there is a plugin available to mute swf files. Mute Flash - https://addons.mozilla.org/en-US/firefox/addon/5453

You probably have to re implement your app to centralize the control of audio components within your app. There is a design pattern out there called Inversion of Control that may be useful for this problem.
http://en.wikipedia.org/wiki/Inversion_of_control
Specifically with Flex, you should lookup the Model Locator pattern with Cairngorm.
http://www.adobe.com/devnet/flex/articles/cairngorm_pt2_06.html
You could use this to store all the various audio levels for your application in a single location. And you could add a method called muteAll() that would go in and set all the levels to 0. Anytime you create a new audio component in the app make sure to add a reference to its volume level in the model locator. Bind the audio's volume level to the value set in the model locator. Then elsewhere in the app you can change the value in the model locator and through binding the audio component you build will get updated.
This might also be helpful.
http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Sound_23.html#160274

Related

Get instance of view registered in Xlabs.ViewFactory

Actually I am trying to structure my project in a clean MVVMV way. Unfortunately to this restriction I need to find a way to set pins to the map without the power DataBinding. One workaround could be to have the View in my ViewModel and set it directly.
Right now I don't have any chance to get the registered view. Does it make sense to extend the XLabs.Forms.Mvvm.ViewFactory?
Before adding a new issue on GitHub, my hope is that there is a better solution to handle such restrictions. I always used MVVM in my (small) WPF projects.
No that doesn't make sense. Your best approach would be to extend the Maps class to make Pins an ObserverableCollection that is bindable.
The new documentation format on the Xamarin site is rather difficult to read and does not provide the information you require at hand like it used to but I believe the Pins object is not bindable.
Take a look at the Xamarin Forms Labs Github project to get an idea of how this can be done. The approach is defined particularly well in the ExtendedPicker classes (here the items are bound to an ObservableCollection).

Flex 3: Is It Possible to Use DeepLinking without a ViewStack?

I've got a Flex 3 project.
Does deep linking only work on viewStacks? (My project doesn't have any viewStacks). I'd like to use deeplinking based on what was selected in a comboBox. I'd like the user to be able to bookmark or use the back button based on what was selected in the comboBox.
The comboBox selection determines which data is pulled from the database.
Is this possible? I set-up deeplinking in another project, but it had viewStacks. And all of the deep linking examples that I've seen use viewStacks.
Thank you.
-Laxmidi
Look at the documentation for BrowserManager and deep linking.
You can use Flex deep linking without a component that has it built in, but you need to add the support manually.
You will need to create a BrowserManager instance and have it load the URL when your application loads. You can then use the URL to load the data requested.
You also need to make sure to update the URL using the BrowserManager each time your data changes in a way that you want to have a separate link for.

A newbie question on cairngorm

I am very new to Flex (started learning a couple of days back), I now have some understanding on how to create user interfaces with Flex and how to do MVC with Cairngorm and I really started liking it. But I am still lost with changing views using Cairngorm or entirely in Flex. Being a Java/J2EE developer for more than 10 years, it helps me understanding new technologies comparing it with Java. Typically in java world or in any MVC framework, the controller once got the updated modal it redirects or sets the new view to the user. Lets say once I added a new movie to movie database, I want to show the user a view Movie screen and when he deletes a movie I want to take user to list of all movies. The example which I have seen so far(including the diagram explorer) are just changing the modal values and the data is updating in the same view (using [Bindable]), but my question is how to change the view depending on the result or if it's a fault I want to take user to a different screen. How to do that in flex and in Cairngorm. Are there any best practices available and somebody please point me to right direction/resource. Thanks in advance.
The usual way to do this with Cairngorm is to put the data about the state of the application (eg. the screen the user is on) in the model too. You can, for example, use the ViewStack as the main container of the different parts of your application and bind it's selectedIndex to a variable in the model which will be used to control the screen that is displayed to the user. Putting it shortly - the state of the application is a reflection of the model.
You may also want to take a look at the Mate framework. We recently switched to Mate after using Cairngorm because we found it was a much easier framework to use and understand.
For your example, you would have a faultHandler event listener that would call whatever method you wanted in your model. You could easily use that to show or hide whatever you needed to.

What restrictions/workarounds are needed for third parties external swf

We are loading external swf content into an adobe air application. Content is provided by an increasing number of third parties.
Being third party content, it will be loaded in a separate security domain (trustContent=false) and a sibling app domain (loadForCompatibility=true). We are doing this using the Loader class.
What are the features/options/approaches that would cause problems when using the swf as external content?
I am interested in any kind of issues, as we have already reproduced issues with content that occur regardless of the app domain / security domain where its loaded ( and occurs also in both Loader and SWFLoader).
Any workarounds for the issues are highly appreciated, especially ones that can be applied from the main app.
The big nasty problem (and one we've dealt with a lot!) is the fact that external SWFs simply can not be directly trusted. Ever. This makes communicating between them and the base AIR application difficult at best.
There is a hack around this based on loading the data of the SWF via a URLLoader and then taking the bytearray from it and pumping it into a Loader. However, I believe that hack was killed with AIR 1.5.1.
That being said, it is possible to communicate between the AIR app and the loaded SWF through what Adobe calls the sandbox bridge. However, setting up the sandbox bridge is a royal pain and any complex data (objects, even as simple as Arrays) get stripped down to generic objects on the other side of the bridge and can not be cast back to their original form.
For our recent projects that needed to use the bridge we created a specialty class called AIRBridge that you use on both sides of the bridge and it facilitates setting everything up properly. If you're interested, you can pull the current source from our Google Code project Automata-Tools.
One we already addressed:
Content outside of the external swf stage shows in the application, and when setting the size where it will be displayed the offstage elements are taken into account. Workaround: Add a mask on the main app so the external content is hidden. Use .content.width/height (full with offstage elements) and .content.loaderInfo.width/height (original stage size) to calculate how much to scale content so the original stage matches the visible area.

Get Fscommand in Flex3

I have one swf file in that i used fscommand to get final output when submit button clicked in that swf ,
i am loading that swf in SWFloader in flex3 .i need to get fscommand value as Alert, how to get that value first and display as alert.
Thanks in advance
fscommand cannot be used for communication between loaded and containing SWFs.
From livedocs
fscommand: Lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. You can also use the fscommand() function to pass messages to Director or to Visual Basic, Visual C++, and other programs that can host ActiveX controls.
You can call a method in the loaded swf OR access its properties directly OR use events OR use local connection to pass data between parent and loaded SWFs.
TECHNICALLY this is feasible, but a bad idea. You'd need to register a callback which would call the child swf (generally done from the child swf). But, you will risk a good deal of headache, and you'll have to rely a lot more on the browser than other options. It would also be slower than an AS only solution.
You're much better off (in this order):
Using a shared Singleton. This allows for complete separation of the two
swf's without requiring any major coordination between the two. The only
real potential problem can be caused if you want the child swf to have its
own ApplicationDomain, but even with that, there are work-arounds
Using events. This can work if you have the child swf dispatch a bubbling,
non-cancel-able event and have the event.target recorded by the
parent swf. You may have to adjust to avoid
SecuritySandboxViolations, however.
Using LocalConnections. The two detriments to LocalConnections are:
You will need to continually re-generate unique connection names to
avoid the error thrown by connecting two LocalConnections to the same
channel.
LocalConnections do have bandwidth limitations which can call
slowdowns if there is a high volume of traffic or if the messages are
too large.
Using direct manipulations like loader.content.foo.bar.baz;
I don't like this solution because it is much harder to maintain. It is
also much worse from a design perspective: you want to use
encapsulation as much as possible in this situation -- this technique
actively works against that.

Resources