Showing posts with label object. Show all posts
Showing posts with label object. Show all posts
Saturday, 9 April 2011
Experimenting with Sound in Flash - DJ Music Mixer
As soon as I realised the possibilities available with Sound Objects in Flash I realised that you could write a simple sound mixing app using ActionScript.
I started this experiment ages ago, but ran into a problem with the sound I couldn't solve straight away. 18 months later I remember it exists and blow the dust off to find the problem still waiting for me.
Just in case any one else has struggled with the same problem... I now have the solution, or at least know why that particular approach wouldn't work and have an alternative.
Once you set up a Sound Object you can either use attachSound to connect an embedded sound from your document Library, or you can use loadSound to load in an external MP3 file. But... and this is where I went wrong... you can't do both. In other words, if the first time you initialise the sound object you use attachSound you can't later change the sound using loadSound and expect it to behave normally. At least that was my experience.
My experimental app was a 2 channel audio mixer that used 2 Sound Objects, one for each channel. The mixing was done very simply by reducing the volume of one Sound Object while simultaneously increasing the volume of the other. So far so good.
However, for the Sound Objects to properly initialise, (and therefore the volume control code work properly) they needed to have a sound loaded into them straight away. The most obvious solution to me was to use attachSound to connect a sound embedded in the movie. So I made a couple of MP3s of 0 second duration and used those embedded within the app. Fine, the Objects initialised OK.
However, to be useful you need to be able to load external MP3s in, or it's only a 2 song show. And that's where the problem arose, because I would need switch from using attachSound to loadSound after the object initialised, and all of a sudden the volume control stops working as expected.
And that's what stumped me. It was only coming back with fresh eyes that allowed me to spot this discrepancy.
So, how to overcome it?
Simples - use loadSound from the first, but get Flash to load a non-existent sound by getting it to load nothing (e.g. ""). Sure, Flash will error, and complain it can't find the file, but the Sound Object will still initialise correctly - and the error is only visible when you test the movie from within the authoring software, not once exported.
Hey presto, when I load an external sound it all works, because I used loadSound all along and didn't change method later on. My music mixing app finally works.
It's possible there are other factors or other solutions - happy to hear about them, but that's how I got round it.
If it helps, happy to help.
Wednesday, 22 August 2007
Dealing with "Click to Activate" for browser based Flash content
One thing you may have noticed when browsing websites containing Flash content, is that you now need to "click to activate", before you can interact with it. This is not IE being more secure, but rather it is a result of legal action from a company called Eolas who apparently owns a patent that has something to do with how plugins and browsers work together. Without going into the legal rambling the real issue for interactive media creators is how you get around it.
So you have crafted some smooth graphics and smoother actionscript all designed to respond to the mouse at it's merest touch. You object and embed it into a web page, the user opens the page, the mouse moves over the flash movie and... nothing happens.
At least not what you intended. Instead a grey box appears around the flash content and a message appears telling the user to "click to activate". That's alright for you - you know there is a flash movie there to activate. But do your users even know what the message means? Besides that, who wants to introduce another 'click' before your page works properly.
If you don't know what I mean, take a look here (click) and mouseover the yellow box on the home page.
The solution
Well, in fact there are several suggestions. But rather than go into details here repeating what others have said, take a look for yourself:
http://blog.deconcept.com/swfobject/ >
and
http://www.howtocreate.co.uk/noclicktoactivate.html >
While Microsoft is not without its anti-fans wishing it ill luck, it is ironic that when in this case they are not having things their own way, the result is also very annoying for end users too.
So you have crafted some smooth graphics and smoother actionscript all designed to respond to the mouse at it's merest touch. You object and embed it into a web page, the user opens the page, the mouse moves over the flash movie and... nothing happens.
At least not what you intended. Instead a grey box appears around the flash content and a message appears telling the user to "click to activate". That's alright for you - you know there is a flash movie there to activate. But do your users even know what the message means? Besides that, who wants to introduce another 'click' before your page works properly.
If you don't know what I mean, take a look here (click) and mouseover the yellow box on the home page.
The solution
Well, in fact there are several suggestions. But rather than go into details here repeating what others have said, take a look for yourself:
http://blog.deconcept.com/swfobject/ >
and
http://www.howtocreate.co.uk/noclicktoactivate.html >
While Microsoft is not without its anti-fans wishing it ill luck, it is ironic that when in this case they are not having things their own way, the result is also very annoying for end users too.
Labels:
click to activate,
embed,
Eolas,
Flash,
javascript,
object
Subscribe to:
Posts (Atom)
