If I put a sound effect in a sequence with other effects, the effects
in the sequence after the sound effect never runs.
For instance in:
testSequence = new Sequence(button);
testSequence.addChild(z1);
testSequence.addChild(sound);
testSequence.addChild(z2);
z2 will never execute unless you remove the sound.
The following code is very similar to what's in the Flex documentation
and the Webster/McCLeod book. Any ideas?
-----------------
Test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*" creationComplete="setup()">
<mx:Script>
<![CDATA[
import mx.effects.*;
[Embed(mimeType="audio/mpeg", source="assets/windup.mp3")]
var windupSound:String;
private var testSequence:Sequence;
private function setup() : Void {
var z1:Zoom = new Zoom(button);
z1.zoomFrom = 100;
z1.zoomTo = 1;
z1.duration = 1000;
var z2:Zoom = new Zoom(button);
z2.zoomFrom = 1;
z2.zoomTo = 100;
z2.duration = 1000;
var sound:SoundEffect = new SoundEffect(button,
windupSound);
sound.duration = 200;
testSequence = new Sequence(button);
testSequence.addChild(z1);
testSequence.addChild(sound); // comment this line out and
all is well
testSequence.addChild(z2);
}
]]>
</mx:Script>
<mx:Button id="button" label="Click Me"
click="testSequence.playEffect()"/>
</mx:Application>
---------------------
// SoundEffect.as
class SoundEffect extends mx.effects.Effect
{
private var s:Sound;
function SoundEffect(targetObj:Object, soundClip:String) {
target = targetObj; // needed?
s = new Sound();
s.attachSound(soundClip);
s.setVolume(100);
//duration = s.duration; // needed?
//s.onSoundComplete = mx.utils.Delegate.create(this,
endEffect);
}
function setSoundClip(soundClip:String) : Void {
s.attachSound(soundClip);
}
function playEffect():Void {
super.playEffect(); // needed?
s.start();
}
function endEffect():Void {
s.stop();
}
}
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/