Stop Play action script 3 for mp3 on layer

I this the wrong way to write a stop play for mp3 on layer.
I have buttons and sound within a movieClip.
Should I give outside movie clip instance name
Thanks
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
function playSound(e:MouseEvent):void {
    this.play();
function stopSound(e:MouseEvent):void {
    stop();

The code you show should work so you may have some implementation issues.
For the stop button error you should go into your publish settings and select the option to permit debugging so that the error includes a line number for what's causing the error.  A 1009 error indicates that some object your code is trying to target does not exist as far as the code sees it.... which can be due to a number of reasons, such as assigning code in a frame where the targeted object does not exist.
For the second error, it appears to be an issue loading (or possibly finding) the file.  Does the sound start playing on its own when you first run the code?
Usually an error of any kind will prevent a file from running properly, so it may just be an issue of fixing just one of them.
You normally don't have to wait for a sound file to completely load before executing a play command... that woiuld be counter-productive to the concept of streaming sound.  In theory, a play command following a load command will execute but the sound will not start until a sufficient buffer exists.

Similar Messages

  • Stop/Play action script

    I have two scenes, one has an audio player that I have to put
    a stop action on, the other is an animation in the background I
    need to loop. How can I do that and play both scenes at the same
    time so the animation loops, and the audio only plays once through.
    The fla file can be downloaded at www.websperations.com/flash
    Thanks!

    The code you show should work so you may have some implementation issues.
    For the stop button error you should go into your publish settings and select the option to permit debugging so that the error includes a line number for what's causing the error.  A 1009 error indicates that some object your code is trying to target does not exist as far as the code sees it.... which can be due to a number of reasons, such as assigning code in a frame where the targeted object does not exist.
    For the second error, it appears to be an issue loading (or possibly finding) the file.  Does the sound start playing on its own when you first run the code?
    Usually an error of any kind will prevent a file from running properly, so it may just be an issue of fixing just one of them.
    You normally don't have to wait for a sound file to completely load before executing a play command... that woiuld be counter-productive to the concept of streaming sound.  In theory, a play command following a load command will execute but the sound will not start until a sufficient buffer exists.

  • Action script problem for audio player

    i have made a introduction with a  audio and controller. I am facing one problem. I will like to play as  soon as some one enter the page but it does not.
    My action script is pasted below and kindly advise me for any changes that can be done
    var soundReq:URLRequest = new URLRequest("Sonu Nigam_Alka Yagnik - Suraj Hua M.mp3");
    var sound:Sound = new Sound();
    var soundControl:SoundChannel = new SoundChannel();
    var volumeControl:SoundTransform = new SoundTransform();
    var resumeTime:Number = 0;
    sound.load(soundReq); sound.addEventListener(Event.COMPLETE, onComplete);
    up_btn.addEventListener(MouseEvent.CLICK, increaseVolume);
    down_btn.addEventListener(MouseEvent.CLICK, decreaseVolume);
    function onComplete(event:Event):void
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
    function playSound(event:MouseEvent):void
    { soundControl = sound.play(resumeTime);
    pause_btn.visible = true;
    pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);
    play_btn.visible = false; play_btn.removeEventListener(MouseEvent.CLICK, playSound);
    function pauseSound(event:MouseEvent):void {
    resumeTime = soundControl.position;
    soundControl.stop();
    play_btn.visible = true;
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    pause_btn.visible = false;
    pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
    function stopSound(event:MouseEvent):void {
    soundControl.stop();
    play_btn.visible = true;
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    pause_btn.visible = false; pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
    function increaseVolume(event:MouseEvent):void {
    volumeControl.volume += .5;
    soundControl.soundTransform = volumeControl;
    function decreaseVolume(event:MouseEvent):void {
    volumeControl.volume -= .5;
    soundControl.soundTransform = volumeControl;
    pause_btn.visible = false;

    i am having big problem with the coding below with the sound. As it we enter the site, the music auto start very loud which is not good at all for the ear drums. How do i adjust that?
    www.hitenkajal.co.uk
    var soundReq:URLRequest = new URLRequest("10 Kabhi Alvida Naa Kehna_0.mp3");
    var sound:Sound = new Sound();
    var soundControl:SoundChannel = new SoundChannel();
    var volumeControl:SoundTransform = new SoundTransform();
    var resumeTime:Number = 0;
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    up_btn.addEventListener(MouseEvent.CLICK, increaseVolume);
    down_btn.addEventListener(MouseEvent.CLICK, decreaseVolume);
    function onComplete(event:Event):void
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
    function playSound(event:MouseEvent):void
    soundControl = sound.play(resumeTime);
    pause_btn.visible = true;
    pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);
    play_btn.visible = false;
    play_btn.removeEventListener(MouseEvent.CLICK, playSound);
    function pauseSound(event:MouseEvent):void
    resumeTime = soundControl.position;
    soundControl.stop();
    play_btn.visible = true;
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    pause_btn.visible = false;
    pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
    function stopSound(event:MouseEvent):void
    soundControl.stop();
    play_btn.visible = true;
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    pause_btn.visible = false;
    pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
    function increaseVolume(event:MouseEvent):void
    volumeControl.volume = 1;
    soundControl.soundTransform = volumeControl;
    function decreaseVolume(event:MouseEvent):void
    volumeControl.volume = 0.1;
    soundControl.soundTransform = volumeControl;
    pause_btn.visible = false;
    playSound(null);

  • Creating a action script class for a flex component

    Hi,
    I am new to flex.
    I have designed a flex component into that I have 4 action script function. I have to write all those function in a separate action script class.
    Can anyone tell me how to do that?
    Thanks,
    Tushar

    I'm not sure I understand the question.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • After Effects CC 2014 plays/renders incorrect audio for mp3 (Mac OS X Yosemite)

    Hi,
    I'm translating the audio for a number of animations made in AE. Sometimes when the mac users import new audio in another language, AE plays and renders a totally different mp3 file than what has been imported. It is playing another piece of translated audio from another folder but I can't tell where from (as it's in another language).
    When I click reveal in Finder, the track in Finder plays the correct audio.
    When I re-import after purging and emptying caches, AE still plays the wrong audio.
    I found a work around where if I copy and re-name the audio and import that it works. The problem is, we can't tell when this has occurred until reviews have been performed and it's costing us a lot of time in re-renders and fixing.
    Does anyone know what causes this problem? Has anyone even encountered it?
    Any advice is much appreciated.

    Does anyone know what causes this problem?
    Sure: You are using MP3 files. AE never has been good with them. Convert them to WAV/ AIFF.
    Mylenium

  • How to get info from App buyer - Action Script 3 for iOS mobile

    Hello;
    I have a client that needs to track the salesperson (or store) who sells an Apple App. They need this information to be able to pay sales commissions and I want to make sure that commissions are only paid once for each sale.
    I will have a screen that appears when the App is installed that asks which salesman/store convinced them to buy the app... then the app will send us an email with the salesman's information...   How can this email (or other type of message) include a unique identifier - like the Apple ID - so I can prevent a buyer from uninstalling/reinstalling the app to be able to send another message and thereby causing us to pay a second commission for the same purchase?
    Thanks for all your help.
    -Rick

    do you want your 10 animations to play simultaneously or sequentially or something else?

  • Action Script 3 code not working for start and stop button?

    Ok so I have this simple animation I created of a circle that moves from one side of the stage to the other. I have added a new layer and called it buttons. On this layer I have added 2 buttons. One for start and another one for stop. The purpose is to get my circle to move from one side of the stage to the other but be able to use my buttons so that I can start and stop the animations at random times during playback. I fixed all my compiler errors now the problem lies in that everytime I click the start or the stop button I get an output error. I have a 3rd layer in which is titled actions and this is where all my code is posted. I removed that layer and placed my code in the first frame of the buttons layer to see if this would change anything but I still get the same output errors. So I just added back my actions layer. What could I be doing wrong? I have made sure to name all my movie clips and buttons correctly and I even added an instance name to them.
    Here is my code and the errors I am getting when I press the play and stop button on test-
    start_btn.addEventListener(MouseEvent.CLICK, startCircle);
    stop_btn.addEventListener(MouseEvent.CLICK, stopCircle);
    function startCircle(e:MouseEvent):void{
        circle.play();
    function stopCircle(e:MouseEvent):void{
        circle.stop();
    green_btn.addEventListener(MouseEvent.CLICK, greenCircle);
    red_btn.addEventListener(MouseEvent.CLICK, redCircle);
    function greenCircle(e:MouseEvent):void{
        circle.play();
    function redCircle(e:MouseEvent):void{
        circle.stop();
    Here are my output errors-
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at exercise2_fla::MainTimeline/redCircle()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at exercise2_fla::MainTimeline/greenCircle()

    ok so my circle is my movie clip and it is titled circle and the instance name is circle. Am I supposed to change MovieClip to circle? I put the code at the top of my actions script but for some reason it did not work. I did change play to stop and it got the movie clip to stop when I do test movie but my buttons still do not work. So I changed stop back to play. Strange.
    I did try changing MovieClip to circle but that did not work so I did Circle with a capital C and that did me no good eigther.
    I meant to add that I did get an error that said- 1180 Call to a possibly undefined method circle.

  • Ipad 2 ipod stops playing for no reason

    recently the ipod on my ipad 2 stops playing music mid-song for no apparent reason... I haven't actually change anything or done anything unusual to it, so not sure what could be causing this?
    Thanks!

    Try a Reset [Hold the Home and Sleep/Wake buttons down together for 10 seconds or so (until the Apple logo appears) and then release. The screen will go blank and then power ON again in the normal way.] It is app and data safe!

  • HLS encryption VOD randomly stop playing on IOS

    We have 4 AMS servers load balanced (DNS) with identical application on each. RTMPe is playing fine from flash desktops, however, HLSe on IOS devices randomly stops playing part way through the content. I do not see any relevant errors in AMS/Apache. The front end player shows the following errors when the content stops playing:
    "CoreMediaErrorDomain" "No response for media file in 0.49632s"
    "CoreMediaErrorDomain" "Segment exceeds specified bandwidth for variant"
    Similar issues discussed here: http://openradar.io/15060374 (thought not AMS specific).
    This could be a player issue. It seems to randomly have issues grabbing an HLS segment. Has anyone else had any similar issues?
    (the following IP's, certs, URL's have been replaced for privacy).
    httpd.conf
    <Location /hls-vod>
                    HLSHttpStreamingEnabled true
                    HLSMediaFileDuration 8000
                    HttpStreamingContentPath "/mnt/store0/"
                    HLSFmsDirPath ".."
                    HLSJITConfAllowed true
                    # Cache-control header configuration start
                    # Specify the max-age(in secs) to set in the Cache-Control header
                    # for different response types (m3u8, ts, drmmeta,...).
                    # A value of -1 turns off setting the cache control header.
                    HLSM3U8MaxAge 86400
                    HLSTSSegmentMaxAge 86400
                    HLSMetaMaxAge 3600
                    # Cache-control header configuration end
                    # Uncomment the following directives to enable encryption
                    # for this location.
                         HLSEncryptionScope server
                         HLSEncryptCipherKeyFile "../creds/vodkey.bin"
                         HLSEncryptKeyURI        "https://myurl/hls-key/vodkey.bin"
                    Options -Indexes FollowSymLinks
            </Location>
    httpd-hls-secure.conf
    <VirtualHost myip:443>
    ServerName myserver
    DocumentRoot "../webroot"
    SSLEngine on
    SSLCertificateFile    "/opt/certs/mycert.crt"
    #Uncomment the following if the file specified above does not
    #have the private key
    SSLCertificateKeyFile "/opt/certs/mykey.key"
    #Client Authentication configuration
    #SSLVerifyClient require
    #SSLVerifyDepth       9
    SSLCACertificateFile "/opt/certs/myintermediate.crt"
    SSLOptions           +StdEnvVars +FakeBasicAuth -ExportCertData +StrictRequire
    <Location /hls-key>
      HLSEncryptHostCipherKey true
      HLSFmsDirPath ".."
      HLSEncryptKeyRepository "../creds"
      SSLRequireSSL
    #  SSLRequire %{SSL_CLIENT_S_DN_CN} eq "iPhoneOS Device Certificate"
    </Location>
    </VirtualHost>

    I just wanted to add an update in case anyone else runs into a similar issue.  I seem to have found a solution to the problem.  Here's what I did:
    1) Plugged in to my computer and removed all music from my iPod (just unselected "sync music" then allowed the iPod to sync).
    2) In iTunes, under the summary tab of my iPod, I selected "convert higher bit rate songs to 256 kbps AAC" in the options section.
    3) I synced my iPod.  This took a REALLY long time, as I have just over 52GB of music that I chose to put on my iPod.  This is 52GB AFTER the conversion to 256kbps.  Anyway, it took a couple hours to sync the first time because it had to convert almost every song.  After the first sync, it doesn't take long to sync unless I add a lot of songs and even then, it only takes a few minutes.
    I've listened to my music on a variety of devices (in my car, different types of headphones, computer at work etc) and haven't noticed any degradation in quality, despite the fact that nearly all of the original music files on my computer are 320kbps.  I'm not sure if the problem I was having was due to the higher bitrate or the fact that the original music files are a variety of formats (aac, mp3, wav, and some others).
    I did this later in the evening after I posted the original question and have not had a problem since (about 15 days).  Skipping songs seems to go a lot faster as well.  I use my iPod a good 6-10 hours everyday, so I think that having no problems in the last 15 days is pretty good evidence that this is a good solution.
    Hopefully this is helpful to anyone that stops by here

  • Help with adding action script to an order form

    Hi - Firs time I'm on this board. Searched and didn't see
    anything that fit. Adobe/Macromedia Support told me my form needs
    an action script insert for me to gain access to a previous page.
    I'm revamping an online order form. It's about 2 1/2 pages in
    length. I find that I can't go back to the first page -- I'm locked
    in the second one. On split screen the HTML coding shows there is
    more than one page. Also, when I look at it in a browser the whole
    page is there.
    Does anyone know how and where I can put in action script.
    I'm not an HTML maven so this isn't my thing. Thanks for whatever
    advice you can give.
    Best - ETide

    Visit gotoandlearn.com and find a tutorial there for creating
    a preloader.

  • Photoshop action script

    Hello,
    Can someone give me an action script which could position my layer on specific Y location depending on height of text. I have a hundreds of PSD files with text. Each text has a different height. I need a script which would put the text of every PSD file so that Y position is always 8.5 cm but that Y position should be across the middle of text. My canvas is always the same size.
    Thank You very much!!

    It would be quite easy to write such a Photoshop script if one had the specifics which you did not provide. Action Script is a Flash  feature.  However a Photoshop can most likely be written to what you want here a link for you
    Adobe Photoshop Scripting | Adobe Developer Connection
    You should also be able to record an action to do what you want if all the text layer are in the same relative place in the layers stack. By aligning the text layer to a selection the action makes. Actions do not require programming you just need to know Photoshop and how to record actions.

  • Moving a Layer based on percentages via action scripting.

    Hi,
    I am trying to create an action script that will move a layer 90% to the left or right. Can this be done thru actions or is it something that can only be done via JS Scripting. The reason I need percentages is not all images are the same dimensions.
    TIA

    You should be able to do it with either.
    With an action set you ruler to percent, select all on the layer you want to move and with the move tool move the image. The amount of the move will be recorded in percent.
    With a script use activeDocument.activeLayer.translate( new UnitValue(.9,'%'),undefined) to move to the right or activeDocument.activeLayer.translate( new UnitValue(-.9,'%'),undefined)to move to the left

  • Placed mp3 stops playing on page turn in exported pdf

    Hi, I placed a sound file in an indesign file, left the 'media' setting 'stop on page turn' unchecked, and still, the file stops when i turn the page in the pdf. I have one button controling the play (mouse release action) and stop (mouseover action) of the file.

    hi steve, you're right; from what i've found, the only way that an embedded audio or movie file will keep playing is if you float a controller. The problem there however is that you have to use the controller; that can be dealt with in pdf, but not from indesign, and if one has a lot of media files in their interactive pdf, that's a lot of work after export. from within indesign, that controller can be made fairly small, and it ends up sitting in the top right corner of adobe reader once a media file is clicked; and it only goes away if you close it; and if you open other media files, the contollers start piling up.
    what i ended up figuring out as an alternative was that if you export to swf instead of pdf, for some reason the mp3 (i only tried mp3 in swf) keeps playing on page turn (with no controller); and the nice thing about swf is that you can get 'curl' page transitions, and since it opens as an html it's ready to go online.
    the document has buttons that upon being clicked, play the file (with nothing popping up); and the mouseover stops the file; and click again plays it.
    one thing that would be nice is if one audio file could be placed that buttons on other pages could access cue points within; unfortunately; buttons can only access audio files that have been placed on the page. so instead of having 1 file, accessed at different navigation points, you have 50 files cut from the 1, each with their own button.

  • Increasing the speed for a certian frames in Flash Cs5 using Action Script 3

    I have 60 frames I want to increase the fps value for frames from 20 to 30, and the remaining frames fps value should remain the same
    Using Action Script 3 or Action Script 2
    Thank you and regards

    I have found a script online
    Q: How can I speed the frame rate or slow it down when the movie is playing? For example, I would like to slow the frame rate from the default of 20 fps to 15 fps from frame #80 to frame #150. Then frame rate should speed back up to 20 fps after frame #151, (fps = frames per second).
    A: One way is to use “interval”. An example of changing the speed of the movie from frame #80 to frame #150 is shown below.
    Create a key frame at frame #80 and place this script:
    var fps:Number = 80;
    var intervalID:Number = setInterval(this, “advanceFrame”, 1000/fps);
    stop();
    function advanceFrame() {
    clearInterval(intervalID);
    gotoAndStop(_currentframe+1);
    if (_currentframe<151) {
    intervalID = setInterval(this, “advanceFrame”, 1000/fps);
    } else {
    play();
    I have changed the values from 80 to 20 and currentframe value to 30
    I get syntax error
    at :
    intervalID = setInterval(this, “advanceFrame”, 1000/fps);
    and
    var intervalID:Number = setInterval(this, “advanceFrame”, 1000/fps);
    In flash cs5

  • How to create volume slider for flash cs 5 using action script 2.0?

    how to create volume slider for flash cs 5 using action script 2.0?the output should like if user want to hear sound in slow pitch,medium pitch or high pitch(slow to high pitch anything).i have attach this sound to button with using this code:
    stop();
    mySoundBtn.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.attachSound("mySoundClip");
              mySoundC.start(0, 10);  //10 represents the number of loops
              gotoAndPlay(2);
    This sound plays till 3-4 scene ahead.
    Can anyone help me?

    Hey thnx Ned.
    this sites are really helpful.but,i have used sound through button.so how it is possible to attavh the link with slider.i have created slider also.
    Below is my slider code for sound.
    onClipEvent (load) {
        mySound1 = new Sound();
        mySound1.loadSound((myScale)+"/"+(myTanpura)+"/"+(myTanpuraSwar)+"/"+(myTanpuraTempo)+".w av", true);
        mySound1.onSoundComplete = function() {
        mySound1.start();
        mySound1.start(0.058,999);
    onClipEvent (enterFrame) {
        downloaded = mySound1.getBytesLoaded();
        total = mySound1.getBytesTotal();
        if (downloaded != total) {
            _root.dl = "You have to buy this software...";
        } else {
            complete = 1;
            _root.dl = "";
        mySound1.setVolume(ratio * 2);
    This code is working for slider.I mean it scrolls the slider.but it dosent make any effect to sound.
    Below is my button code.
    stop();
    mySoundBtn4.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.attachSound("mySoundClip4");
              mySoundC.start(0, 300);  //10 represents the number of loops
              gotoAndPlay("play1");
    this is on button's frame.not exactly on button.
    Button and Slider both are on diffrent scene.
    Can you plese help me out?

Maybe you are looking for

  • How to speed up JCO function call

    Hello, i have some function module in r/3 which returns a huge amount of data. When i am testing this fm in r/3 this function takes few seconds for executing. But when i run this function with jco from java it takes about ten times more :(. Is there

  • Http Adapter Problem

    I am working on File to Http Scenario. I am sending one requist to Servlet. In runtime monitaring showing black flag. but request is not going to Servlet. How will i monitor Http Adapter. Thanks

  • User Exit during Plant Order Saving

    Hi Friends Could you please tell me an user exit which triggers while saving Plant Order in IW31.  I need to keep a check regarding Settlement Rules. Could you please suggest one. Thanks Britto

  • User Defined Parameter

    Hi Amol Donger, Thank you for the reply , we have tryed the way you explained, its works for filters but for experssion transformation it is not working . Thanks & Regards,Shalini

  • PSE 8 and resizing

    Having just purchased an Apple mac a month ago, I decided to purchase PSE 8 as my final enhancing software to accompany Lightroom 2. I usually use  paintshop pro X2 as it it is very quick and has an easy interface. I found PSE 8 very frustrating to u