Play an external .swf sound loaded

I have a small .swf file containing any of the characters in my game. In my project main actionscript 3, I load the .swf from an external source and display it in my game. It works very well, however, I join the swf file contains a short sound clip that should be played whenever the user clicks on the character.

I know that I could add an onClick listener to the small .swf itself and write code in Flash Professional to play the sound. The problem is that I have an options menu in my game that allows the user to specify the volume of these sounds, and I think that this information would be unavailable for the loaded external .swf

The audio file must therefore somehow be packed inside the .swf of character, but I also need to be able to play through my custom "SoundPlayer" class that I have in my actionscript project. Any ideas how I could do this?

create a public method in your external swf file that controls the volume of the sounds.

Tags: Adobe Animate

Similar Questions

  • loading an external swf that loads an object from url

    I am trying to load an external swf which in turn automatically load an object. I want the external swf will only be loaded once the object is loaded in it. for now, it loads the external SWF first, then the external swf file loads the object specified in a URL...

    exactly.  you will need a preloader that checks if your external swf finished loading its dependent objects.

  • Problem with the playback of the external SWF sound

    Hello

    I need to load the external SWF file, which contains the simple + audio image sequence. I used the MovieClipLoader class for this and also a preloader, where I check if I can run the SWF safely, without having to pause later and continue with loading. It works similar to video YouTube, where the video is buffered.

    The problem is that when I load the SWF file and run it, the audio start to play later. I tried more cases and the reason is that even if I load enough of the SWF, I can be certain I can start reading, because it is not enough for audio, if you start playing a little later. When I insert more, the audio begins to play immediately.

    So the question is, is there a way how can I check if the audio is loaded and ready to play?

    Thank you

    Michal

    If you can inspect the external swf fla enough to know that synchronize sound is set to stream, you should be able to look at the scenario where the sound is attached and determine the number of images, the sound is.

  • Stop the external external SWF sound

    I'm working on the controls for an external swf. The external swf load an external audio file. The structure at the moment is

    extswf.swf contains mcSound that loads soundfile.mp3. extswf.SWF playback starts automatically when it is called.

    movieController contains the icons for the buttons play/pause. This is attributed to CntlClass.

    CntlClass load extswf.swf and control buttons play / pause.

    So far, the play buttons / break stop and start and stop the film, but not the sound. I know that I need to access the sound from the external swf channel and sound transformation allows you to change the volume. We know not how to access this channel.

    The examples that I think have integrated audio files. Also, the examples seem to use the main class for the external swf. My external swf is not a class file, so I have no idea what would be the main class.

    If someone has done this successfully, who would be willing to share?

    you follow my suggestion.  use:

    SerializableAttribute public class CntlClass extends MovieClip
    {
    public var loader: Loader;
    public var movie: MovieClip;

    public void CntlClass()
    {
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, movieLoaded);
    Loader.Load (new URLRequest ("extswf.swf"));

    mcPlay.buttonMode = true;
    mcPause.buttonMode = true;
    mcPlay.visible = false;
    }
           
    public void movieLoaded(event:Event):void
    {
    film = MovieClip (loader.content);

    loader.removeEventListener (Event.COMPLETE, movieLoaded);

    stage.addChild (movie);
    mcPause.addEventListener (MouseEvent.CLICK, pauseSWF);
    }
              
    public void pauseSWF(event:MouseEvent_=_null):void
    {
    Movie.Stop ();
           MovieClip (loader.content).channel.stop ();
    mcPlay.visible = true;
    mcPause.visible = false;
    }

    In extswf.swf:

    var req:URLRequest = new URLRequest ("noise.mp3");
    var sound: Sound = new Sound();
    channel: var SoundChannel = new SoundChannel();

    function soundLoaded(event:Event):void
    {
    sound.removeEventListener (Event.COMPLETE, soundLoaded);
    channel = sound.play().
    channel.addEventListener (Event.SOUND_COMPLETE, otherStuff);
    }

    function otherStuff(event:Event):void
    {

    Channel.Stop ();
    channel.removeEventListener (Event.SOUND_COMPLETE, otherStuff);
    }

    sound.addEventListener (Event.COMPLETE, soundLoaded);
    Sound.load() (req);

  • Pause/Play for external SWF

    Can someone help me witht this? I'm going crazy trying to understand because none does not work. I am trying to create a play/pause button that will make a break and play on the main timeline (easy), but also an external SWF that is loaded with the class Loader. Here is my code:

    var myLoader:Loader = new Loader();Create a new instance of the Loader class

    var url: URLRequest = new URLRequest ("MYCONTENT.swf");

    myLoader.load (url);load the SWF file

    myLoader.x = 134;

    myLoader.y = 148;

    addChild (myLoader);

    In the main scenario, I have a MovieClip that is the Pause/Play button. He alternates between the two. How to control the external SWF as well?

    Section 1:

    Stop();

    pauseBtn.addEventListener (MouseEvent.CLICK, pauseMovie);

    function pauseMovie(e:Event): void {}

    gotoAndStop (2);

    MovieClip (root) .stop ();

    MovieClip (root).myLoader.content.stop ();  ///??????????

    }

    Section 2:

    playBtn.addEventListener (MouseEvent.CLICK, regarderMovie);

    function playMovie(e:Event): void {}

    gotoAndStop (1);

    MovieClip (root) .play ();

    MovieClip (root).myLoader.content.play ();  ///????????????

    }

    Try:

    var myLoader:Loader = new Loader(); Create a new instance of the Loader class

    var url: URLRequest = new URLRequest ("MYCONTENT.swf");

    myLoader.load (url); load the SWF file

    myLoader.x = 134;

    myLoader.y = 148;

    addChild (myLoader);

    In the main scenario, I have a MovieClip that is the Pause/Play button. He alternates between the two. How to control the external SWF as well?

    Section 1:

    Stop();

    pauseBtn.addEventListener (MouseEvent.CLICK, pauseMovie);

    function pauseMovie(e:Event): void {}

    gotoAndStop (2);

    MovieClip (root) .stop ();

    MovieClip (MovieClip (root).myLoader.content) .stop ();  ///??????????

    }

    Section 2:

    playBtn.addEventListener (MouseEvent.CLICK, regarderMovie);

    function playMovie(e:Event): void {}

    gotoAndStop (1);

    MovieClip (root) .play ();

    MovieClip (MovieClip (root).myLoader.content) .play ();  ///????????????

    }

  • How to determine the total number of images in the external .swf file loaded

    I have to be able to load both external .swf files and make them play in order. To do this, I need to know the number of images in the first .swf file so I can check _currentframe against _totalframes to determine when he is finished playing so that I can load another.

    Most of the stuff I see indicate that _totalframes on an external .swf can be determined by loading the .swf in a container clip and then check using a listener in the .onLoadInit. Like this:

    ------------------------------------------------------------------------------------------ ----------------------------

    this.createEmptyMovieClip ("tester_mc", 1);
    var mcListener:Object = new Object();

    mcListener.onLoadInit = {function (target_mc:MovieClip)}
    target_mc.onEnterFrame = function() {}
    If (this ._currentframe > = this ._totalframes) {}
    trace ("total frames =" + this ._totalframes);
    delete this.onEnterFrame;
    } else {}
    trace (target_mc._currentframe + "OF" + target_mc._totalframes);
    }
    }
    }

    var test_mc:MovieClipLoader = new MovieClipLoader();
    test_mc. AddListener (mcListener);
    test_mc.loadClip ("Ad_Group.swf", tester_mc);

    ------------------------------------------------------------------------------------------ -------------------------------------

    Unfortunately, this doesn't seem to work. The trace will always return a total number of frames of 1.

    I guess it's because the container clip has only 1 frame, and the external .swf timeline seems to be ignored.

    I would appreciate any ideas on how to raise the total number of frames of an external .swf file or, Alternatively, put it another way when it's done playing. (Not only the loading, but play until the end.)

    TIA,

    C

    I guess it's because the container clip has only 1 frame, and the external .swf timeline seems to be ignored.

    I wouldn't imagine. My guess is that the main scenario for the external swf file has only 1 frame and the rest of the animation is inside a movieclip in this timeline. You publish this swf? Can you open the FLA and check how many images is open on the main timeline?

    The approach that you have mentioned is about what there is. But he knows check a chronology. If there are many nested movieclips, it may be impossible to understand what timeline you really want to be 'THE' full chronology.

    If you have the FLA, you can have the video call function on the _root timeline which tells the main swf that has completed a movieclip or something like that.

    Also, I have in my head somewhere that I recently saw something that someone made similar to this one, but do not remember... If it appears in my head that I will post.

  • Loading an external SWF that loads XML

    Hey all, I have a SWF that loads a swf file in that load images from a XML file with Ned Murphy.  I have a new problem with him.  It works everywhere I try except on the Web server.  When I try I get nothing.  It does not seem to load external SWf file or it cannot load the XML file.  I don't know why.  Has anyone encountered this before? Thank you.

    EDIT

    It works if I try the SWF for the Web server but when I embed in an HTML file and run it through a broweser I get nothing.

    If the swf file is one of the html page that incorporates, you might have to adjust how target you files that loads SWFs.

    When you embed a SWF in a web page, whatever is in that loads the swf file must be targeted as if the swf is in the same folder as the html page that got him.  So if the html page uses something like "flash/main.swf" to integrate the SWF of high level, so if the top-level file is loaded another swf from the same flash file that it should also use the "flash/other.swf" without worrying that it is in the same folder on the server.  When it is embedded in the page, it's like being anywhere where this page.

  • Loading an external SWF in Actionscript 2

    I'm creating an animation in Flash CS4 Actionscript 2.0 / Flash Player 7

    At the moment I have a Manager (video Clip) called myHolder which is used to play other swf files in a main swf file, when it is called by a button

    Within a button that loads the SWF in the main scenario - for example

    on (press) { loadMovie("BulletTrainDRAFT.swf", myHolder); }

    It works very well with bring the other swf files in the timeline of the main swf file, but when I put them a swf file that has video controls for a video it contains, they are not in Manager when played, but they do not work when the swf file is playing in its own window of external flash drive (the video is (Clip) on his own script in its fla design)

    Video buttons - ActionScript 2.0

    btnStop.onPress = function()

    {  _root.vid.stop();  }

    btnPlay.onPress = function()

    {  _root.vid.play();  } 

    btn_fastforward.onPress = function()

    {  _root.vid.nextFrame();  } 

    btn_Rewind.onPress = function()

    {  _root.vid.prevFrame();  }

    I tried ActionScript 3.0 code so

    Pausebtn.addEventListener(MouseEvent.CLICK,pauseHandler);

    Stopbtn.addEventListener(MouseEvent.CLICK, stopHandler);

    Playbtn.addEventListener(MouseEvent.CLICK,playHandler); 


    function stopHandler(event:MouseEvent):void

    { // Pause the stream and move the playhead back to // the beginning of the stream. video.gotoAndStop(1); }

    function playHandler(event:MouseEvent):void

    { // Pause the stream and move the playhead back to // the beginning of the stream. video.play(); }

    function pauseHandler(event:MouseEvent):void

    { // Pause the stream and move the playhead back to // the beginning of the stream. video.stop(); }

    Problem I have I think, is that an external swf movie load on the current timeline as a child and don't dump the chronology leading to the non-functional actionscript code, but I can't solve this problem.

    If the swf containing the video is an as2 swf, add:

    This ._lockroot = true

    It is the main timeline.

  • Loading external SWF - I thought it would be easy...

    Apologies: I do not really have my head around AS3! All I want to do is stop the main timeline until an external SWF is loaded and then run the external SWF file. Everything works fine locally, but the server stops just the timeline. The ext SWF appears to load but then when it ends, nothing happens, the timeline is stopped and does not play the loaded SWF file.

    Here is the site: johnmarshallmedia.com/default.aspx

    Any help appreciated.

    The following actionscript code:

    Stop();


    var req:URLRequest = new URLRequest ("intro2.swf");

    var loader: Loader = new Loader;


    function fileLoaded(event:Event):void

    {

    addChild (loader);

    }

    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, fileLoaded);


    Loader.Load (req);

    Use Firebug or Charles or Fiddler to see what happens when you run it on the server. Use Flash debug player to see the execution errors. The html code integrates the Flash in the same folder?

  • External SWF load on buttons

    Hi all..

    I am loading a SWF file outside on click of a button, however, when the external SWF file loads, it covers the buttons... Can someone help me please on how I can keep the buttons on the top? I even tried the external SWF to load in a clip and place the buttons on a layer above - and it does not work... Any help would be great appreciated. Thank you advance!

    Here is my code:

    Table external to use staples. Variable index refers to the next clip is displayed.
    var clip: Array = ["page1.swf", "page2.swf", "page3.swf"];
    var int index = 0;

    Stuff to load swf files
    var thisLoader:Loader = new Loader();
    thisLoader.contentLoaderInfo.addEventListener (Event.INIT, doneLoading);

    var thisMC:MovieClip = new MovieClip();
    stage.addChild (thisMC);            Add MC initially empty so that the nextClip function can be generic

    Removes the old MC and gets the following, waiting until what, when it booted transfer, adding to the scene
    function nextClip (): void {}
    thisLoader.load (new URLRequest (clips [index]));
    }

    AS of Tell the loaded file is a video clip and add it to the stage.
    function doneLoading(e:Event):void {}
    stage.removeChild (thisMC);
    thisMC = MovieClip (thisLoader.content);
    thisLoader.unload ();
    stage.addChild (thisMC);
    thisMC.play ();
    }


    'Next button' just calls a function that indicates the file name following (mod the number of files in the list)

    bttn1_mc.addEventListener (MouseEvent.CLICK, playNext);

    function playNext(e:MouseEvent):void {}
    nextClip();
    index = (index + 1)%(clips.length);
    }

    stage.addChild (bttn1_mc);
    bttn1_mc. Visible = true;

    You are welcome.

    Please mark this thread as answered.

  • Why I can't load external .swf boxes?

    Hello world...

    I am trying to load an external .swf that contains check boxes. The external .swf has a script in the applications folder on FMS3 server-side.

    When I insert the external .swf locally, it works fine.

    If I load the external .swf remotely with an Apache Web server, the external .swf is loaded but do not appear the boxes...

    Why?

    Please, help me...

    Emiliano.

    Are these components AS2 or AS3? If the latter, I would advise you to place the components in a RSLS (runtime shared library) and active in the external SWF, then reference the RSL.

    -Robert

    --

    Robert Reinhardt

    Creator, videoRx.com

    Author, series Bible Flash and video for Adobe Flash CS4 Professional Studio Techniques

    Adobe Community Expert

    http://blogs.flashsupport.com/Robert

  • Loading an external swf

    I am trying to edit the FLA of the developer who disappears when the link to an external SWF is somehow broken. The button that triggers the SWF has the next action associated with it:

    (release)
    {
    gotoAndPlay ("collection")
    }

    There is no sequence named 'collection', only an external swf called 'spring.swf '. When I change the actionscript code to refer to "spring.swf" I get nothing.

    There is a layer of script which has a unique setting with a reference to spring.swf. His action reads as follows:

    Stop()
    loadVariables("flash/spring.swf",placeholder).

    This action occurs on the same chassis as an instance of the button.

    I am a novice to say the least and I am totally baffled. Thanks for any advice.

    The mention 'collection' is an image tag, not a scene, if look back through the timeline (or the use of the movie in the Actionscript Panel Explorer/script) to find a framework with this name. The button has nothing to do with the external SWF file loading, it's the handle in the second bit of code you have there... but I have to say I've never seen loadVariables used to pull in a SWF file, which should probably be loadMovie instead.

    Hope that helps!

  • Using the DateField in an external SWF loaded

    Hello

    I had major trouble trying to get a PHP contact form basis to work within an external SWF file loaded within a parent SWF. When I test the movie on its own it seems to work fine (example: I am able to select a date in the DateField component). However, when I open the SWF file parent and call the external SWF file with the DateField shape is essentially unusable (example: when you click on it nothing happens, no calendar is displayed to select a date).

    I have no ActionScript on it yet, simply because I tell myself that I need to work before I tell him what to do with the PHP file. The name of the instance on the DateField is 'survive. ' Any help is appreciated. Thank you.

    Also, I used successfully the contact form on the web. But, UI components only that I am able to edit the input text boxes, not the DateField or ComboBox I have in there as well. It is very strange, I was not aware that he had to do something special with the help of these user interface components in an external file.

    Elijah

    Hey 2 m.

    In fact, I found a post on this forum who answered the way back in February in kglad. The answer to my problem was simply place the following code on the layer actions where my components have been posted:

    This ._lockroot = 1;

    That's all. Thank you at least 2 m.

    Elijah

  • His control of an external SWF PLS HELP!

    Hi all

    I'm trynig to control an external SWF sound but I can't seem to do things, I am kind again have you and would really apreciate any HELP given!

    Here is the code I use to import the sound

    mport flash.media.Sound;
    import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.media.SoundChannel;
    import flash.events.Event;
    import flash.events.MouseEvent;

    var _som1:Sound;
    var _channel1:SoundChannel;
    var _playing1:Boolean = false;
    var _position1:int;

    _som1 = new Sound( new URLRequest ( "som1.mp3"));
    _channel1 = _som1.play();


    /*
    //this controls the sound inside the SWF
    //this code has to be on the main SWF
    _play.addEventListener(MouseEvent.CLICK, playSound);
    _pause.addEventListener(MouseEvent.CLICK, pauseSound);

    function playSound(event:MouseEvent):void {
        _channel1 = _som1.play(_position1);
    }

    function pauseSound(event:MouseEvent):void {
        _position1 = _channel1.position;
        _channel1.stop();
    }
    */

    My main SWF call an internally within a clip, here is the code, if this can help somehow...

    var loadAnimBox:Loader = new Loader();
    var vid_mc:MovieClip;

    function startLoading():void {
        loadAnimBox.contentLoaderInfo.addEventListener(Event.COMPLETE, onBoxLoaded);
        // load the box animation SWF
        loadAnimBox.load(new URLRequest((meuCaminho.parameters.var3) + ".swf"));
    }

    function onBoxLoaded(e:Event):void {
        loadAnimBox.contentLoaderInfo.removeEventListener(Event.COMPLETE, onBoxLoaded);

        vid_mc = loadAnimBox.content as MovieClip;
        // We listen for that event:
        vid_mc.addEventListener("firstAnimationComplete", onFirstComplete, false, 0, true);   
        addChild(vid_mc);
       
        // set up the play button
        play_btn.addEventListener(MouseEvent.CLICK, playClick);   
        stop_btn.addEventListener(MouseEvent.CLICK, stopClick);

    }

    function onFirstComplete(e:Event):void {
        // we should remove the listener if we're not going to play this again
        trace("First animationn complete, start second animation.");
    }

    function playClick(e:MouseEvent):void {
        vid_mc.play();
    }
    function stopClick(e:MouseEvent):void {
        vid_mc.stop();
    }

    Thanks for the attention... best regards!

    When your external swf:

    var alreadyStarted:Boolean

    if(!alreadyStarted){alreadyStarted=true;_som1 = new Sound( new URLRequest ( "som1.mp3"));_channel1 = _som1.play();}
    
    and in your main swf use the two functions in suggested to play and pause your sound.
    
  • AS3 external swf close self

    Hello

    After looking through the forums online and video tutorials...

    I am always facing errors of loading an external swf into my main swf (full step width).

    In my main.swf... i have several scenes.

    On one of these scenes, I have an external SWF that loads my main.swf step size.

    Which works very well...

    BUT

    I now want to close the external swf on a button (in my external swf) and to return to one of my scenes in my hand. SWF

    I read many forums that talk about dispatchEvent

    I tried these methods and I am still facing errors.

    I want just one button on my external.swf that is farm/unloads/deletes itself... so that the user can continue by HAND. SWF after that they played OUTSIDE. SWF.

    in actionscript 2, it was a breeze.

    in as3, it's a useless pain in my rectum

    Sorry if I've missed a lot

    any help would be appreciated

    jayquery

    Try to change the code of loader main file for more like the following (blue nine):

    var defaultSWF:URLRequest = new URLRequest ("gametestG.swf");

    var loader: Loader = new Loader();
    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, loaderCompleteHandler);
    Loader.Load (defaultSWF);

    function loaderCompleteHandler(evt:Event):void {}
    MovieClip (evt.target.content) .addEventListener ("closeChild", onChildClose);
    addChild (loader);
    }

    function onChildClose(event:Event):void {}
    loader.unloadAndStop ();
    removeChild (loader);
    }

Maybe you are looking for