Hi Everyone
I'm having some problem dispatching events between classes. I'm working on this wesite with a presentation so to avoid getting errors for adding event listeners to objects that are not on stage i dispatch an event to the document class to let it know when the buttons are available but when i try to make the document class dispatch an event to the sound class to start the background music, it gives me this error:
Error: Error #2136: The SWF file file:////Volumes/Macintosh%20HD/Users/ross/Adobe%20Flash%20Projects/adva... contains invalid data.
at CISound()
at CI()
I've google the error, check out dispatchEvent tutorials cause I've been off AS3 for a while (Learning PHP) but i haven't found anything helpful.
Thanks in advance for your help.
FLA File:
stop();
dispatchEvent(new Event(BUTTONS_DOWN));
I updated what I've
I updated what I've changed so far (with no results at all) and now im not getting an error, it just doesnt work.
CISound class: package {
CISound class:
package
{
import flash.media.*;
import flash.net.*;
import flash.events.*;
import CI;
public class CISound
{
private var req:URLRequest = new URLRequest("loop.mp3");
private var sound:Sound = new Sound();
private var controller:SoundChannel;
private var Volume:SoundTransform;
public function CISound(ci:CI)
{
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req);
ci.addEventListener(CI.PLAY_SOUND, soundLoaded);
}
private function soundLoaded(event:Event):void
{
controller = sound.play(0,1000);
}
public function soundHeard(event:Event):void
{
trace("play_Sound dispatchEvent is working");
}
}
}
CI class: package {
CI class
package
{
import flash.display.*;
import flash.events.*;
public class CI extends MovieClip
{
public static const BUTTONS_DOWN:String = "buttons_down";
public static const PLAY_SOUND:String = "play_sound";
public function CI()
{
addEventListener(BUTTONS_DOWN, addListeners);
}
public function addListeners(event:Event)
{
trace("buttons_down Event dispatching works");
services_mc.addEventListener(MouseEvent.MOUSE_OVER, overServices);
portfolio_mc.addEventListener(MouseEvent.MOUSE_OVER, overPortfolio);
contact_mc.addEventListener(MouseEvent.MOUSE_OVER, overContact);
aboutUs_mc.addEventListener(MouseEvent.MOUSE_OVER, overAboutUs);
home_mc.addEventListener(MouseEvent.MOUSE_OVER, overHome);
dispatchEvent(new Event(PLAY_SOUND));
}