AS3 help with buttonClickHandler

Ok, so i am getting the following error:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at file_Scene1_fla::MainTimeline/buttonClickHandler()
So here is the code
At frame 75 (intro before hand, works perfectly, with only a
play command)
note: 30fps
var nextSection:String="home";
stop();
firstButtons.firstButton.addEventListener(MouseEvent.CLICK,
buttonClickHandler)
function buttonClickHandler(event:MouseEvent):void {
if ( event.target == firstButtons.firstButton ) {
nextSection="home";
gotoAndStop(nextSection);
} else if ( event.target == home_btn ) {
nextSection="home";
gotoAndStop(nextSection);
} else if ( event.target == collections_btn ) {
nextSection="collections";
gottoAndStop(nextSection);
} else if ( event.target == orders_btn ) {
nextSection="orders";
gottoAndStop(nextSection);
} else if ( event.target == about_btn ) {
nextSection="about";
gottoAndStop(nextSection);
} else if ( event.target == contact_btn ) {
nextSection="contact";
gottoAndStop(nextSection);
} else if ( event.target == americas_btn ) {
nextSection="americas";
gottoAndStop(nextSection);
} else if ( event.target == europe_btn ) {
nextSection="europe";
gottoAndStop(nextSection);
} else if ( event.target == asia_btn ) {
nextSection="asia";
gottoAndStop(nextSection);
} else if ( event.target == oceania_btn ) {
nextSection="oceania";
gottoAndStop(nextSection);
then, i have more objects enter the stage at frame 80
home_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
collections_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
orders_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
about_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
contact_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
stop();
and finally at frame 95
americas_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
europe_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
asia_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
oceania_btn.addEventListener(MouseEvent.CLICK,
buttonClickHandler);
stop();
the error comes, when i try to click on the buttons that
enter in frame 80 (also, the button works as in the up and down
state changes, but it does not move on to the next section of the
website)
from what i got, i have to list the function and all its
possibilities the first time (as in AS3, you can only list a
function once or else get error 1114 (i think thats the # might be
wrong))
then later you list the items entering (as they enter the
stage) or get error 1009, which i still am getting
thank you very much in advance
PS: i only learned Flash this week and have looked through
dark world wide webs for many errors but am finally stumped

ok, the firstButtons.firstButton is a button called
firstButton in a movie clip firstButtons however, the movie plays
(i said a simple play command in the post plays it) and if i click
on it, it takes me to the next section of the website, so i dont
think that's it (note: from what i understand you have to list the
button in that order or else it wont identify it (am i wrong))
the problem starts at frame 80 with the new buttons that dont
forward me on to their given sections
if you can explain what to do next (ie: trouble shoot x or
y...) that would be greatly appreciated as im way way out of my
league
thanks alot

Similar Messages

  • AS3 Help with hyperlinking

    Hi All
    Hoping you can help me, I have 2 websites both built entirely in flash.
    My problem is that I have created a button on one of the sites that has to link to a particular scene and frame within the second website.
    I know I need some actionscript 3 to do this, but have no idea how to code this.
    Can anyone help me? Or point me in the right direction?
    Many Thanks
    N

    append a query string to your ulrrequest string that indicates the frame/scene.   in the loaded swf, use the _url property and string methods to isolate those values and use them in a goto.  if you're loading a html, use javascript to parse the url and the externalinterface class to retrieve the javascript results in flash.

  • Need help with as3 for popup window

    I am nearing the end of the semester in my Flash Animation class. I have learned very simple AS3 things, code snippets etc. I am trying to find the actionscript for coding a very simple popup window, but have not found a clue.
    Here's what I want to do...I have a white box with some type on the stage. When a person clicks on the white box, I want a popup to open that is larger, that will contain the same type but larger. That box will have an x so it can be dismissed. I don't want to do this in html, only in Flash CS5. I don't want a browser window, I just want a bigger version of the smaller box. I know how to build both boxes, just don't know how to write the code. I know there will be an on-click mouse event listener, and then I am lost.
    Can anyone help with the code I might use? It would be most appreciated.

    It would be something along the lines of... (using instance names relative to your description)...
    popup.visible = false;
    whiteBox.addEventListener(MouseEvent.CLICK, showPopup);
    function showPopup(evt:MouseEvent):void {
         popup.visible = true;
    popup.popupX.addEventListener(MouseEvent.CLICK, hidePopup);
    function hidePopup(evt:MouseEvent):void {
         popup.visible = false;

  • Need help with AS3 to play movies

    Here is my what I'm working with: Flash CS3, AS3. I have 4
    buttons and 4 movies (each button will be asigned to play one of
    the 4 movies).
    Not sure if this is the best layout but here is what's
    included in my file. I have an Actions layer, 4 buttons (on 4
    different layers), 4 embedded movies (on 4 different layers...all
    about 5-8 seconds long). I'm sure this is simple but figuring out
    the code for AS3 is like learning Chinese....I need major help with
    this.
    Lets say that my buttons have instance names like button1,
    button2, button3, button4, and my movies have instance names like
    movie1, movie2, movie3 and movie4. Here's the catch. I don't want
    the movies viewable (or seen) until the user selects one of the
    buttons. So if the user selects button1 the movie will appear (next
    to the button without any contols...just a movie with a border) and
    play. If the user hovers off or moves the mouse off the button, I'd
    like for the movie to disappear.
    Can someone please give me the the code needed so that when I
    select button1 that it will play movie1, button2 w/ movie2....and
    so on.
    Thanks for your help!

    Here is the link to the fla file.
    http://joshhicks.com/flash/flashfile.html
    I updated the link to the latest swf
    http://joshhicks.com/flash/del2.html
    I added stop(); to the 1st frame of each moive and this fixed
    the movies from playing in the background unseen. If you can help
    me with one last question...then the file will be complete. As of
    now when you select one of the movies, it plays once thru and
    starts back at frame one (loops) which is the way I want it to
    play. But if you hover off one of the buttons while the movie plays
    (lets say when the movie is showing the number 2) when you go back
    to view the same movie, it will start where you left off (it will
    start on the fram showing 2 and not 1). How can this be set up to
    play from the beginning of each movie everytime you happen to go
    back and click on the button? Thanks

  • Help with unloading images AS3

    Please can anyone help me. I am new to Action Script and flash and am having a nightmare unloading images. The code below works but I keep getting the following error messages:
    TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/clickSection()
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/clickSection()
    Any help with this would be much appreciated.
    var ImgReq01:URLRequest=new URLRequest("images/home/01.jpg");
    var ImgReq02:URLRequest=new URLRequest("images/home/02.jpg");
    var ImgReq03:URLRequest=new URLRequest("images/home/03.jpg");
    var ImgReq04:URLRequest=new URLRequest("images/home/04.jpg");
    var ImgReq05:URLRequest=new URLRequest("images/home/05.jpg");
    var imgList:Array=[ImgReq01,ImgReq02,ImgReq03,ImgReq04,ImgReq05];
    var imgRandom = imgList[Math.floor(Math.random()* imgList.length)];
    var imgLoader:Loader = new Loader();
    imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    imgLoader.load(imgRandom);
    function onComplete(event:Event):void
      var randomImage:Bitmap = Bitmap(imgLoader.content);
      randomImage.x=187.4;
      randomImage.y=218.1;
      addChild(randomImage);
    //handle events for info buttons...
    information. addEventListener (MouseEvent.CLICK, clickSection);
    home. addEventListener (MouseEvent.CLICK, clickSection);
    galleries. addEventListener (MouseEvent.CLICK, clickSection);
    function clickSection (evtObj:MouseEvent) {
    //Trace shows what's happening.. in the output window
    trace ("The "+evtObj.target.name+" button was clicked")
    //go to the section clicked on...
    gotoAndStop (evtObj.target.name)
    // this line is causing errors when navigating between the gallery and information buttons
    var Image:Bitmap = Bitmap(imgLoader.content);
      removeChild(Image);

    you really should be adding the loader to the displaylist, not the content.
    try:
    var ImgReq01:URLRequest=new URLRequest("images/home/01.jpg");
    var ImgReq02:URLRequest=new URLRequest("images/home/02.jpg");
    var ImgReq03:URLRequest=new URLRequest("images/home/03.jpg");
    var ImgReq04:URLRequest=new URLRequest("images/home/04.jpg");
    var ImgReq05:URLRequest=new URLRequest("images/home/05.jpg");
    var imgList:Array=[ImgReq01,ImgReq02,ImgReq03,ImgReq04,ImgReq05];
    var imgRandom = imgList[Math.floor(Math.random()* imgList.length)];
    var imgLoader:Loader = new Loader();
    imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    imgLoader.load(imgRandom);
    function onComplete(event:Event):void
    imgLoader.x=187.4;
    imgLoader.y=218.1;
      addChild(imgLoader);
    //handle events for info buttons...
    information. addEventListener (MouseEvent.CLICK, clickSection);
    home. addEventListener (MouseEvent.CLICK, clickSection);
    galleries. addEventListener (MouseEvent.CLICK, clickSection);
    function clickSection (evtObj:MouseEvent) {
    //Trace shows what's happening.. in the output window
    trace ("The "+evtObj.target.name+" button was clicked")
    //go to the section clicked on...
    gotoAndStop (evtObj.target.name)
    // this line is causing errors when navigating between the gallery and information buttons
    if(this.contains(imgLoader){
      removeChild(imgLoader);

  • Help with If statement please

    Hi,
    First Special thanks to Kglad for the help with the AS1 to AS3 conversion.
    I've been able to link up my buttons to play a different frames of the movie. this was my novice way of finally getting the programming to work.
    In frame 95 I have
    var myLoader:Loader = new Loader();
    addChild(myLoader); var url:URLRequest = new URLRequest("page1.swf");
    myLoader.load(url);
    in frame 165:
    var myLoader1:Loader = new Loader();
    addChild(myLoader1); var url1:URLRequest = new URLRequest("page1.swf");
    myLoader1.load(url1);
    My buttons link to 116 which plays a frame and loads ^
    in frame 226: removeChild(myLoader).
    But if the user has looped back into home from another part in the movie clip then it would need to remove myLoader1 instead of myLoader.
    I'm guessing there is some really dynamic way to solve the programatic nightmare i'm developing, but I'm really novice.
    So what i need is an if statement for frame 226
    That would do something:
    if(myLoader <> null
         removeChild(myLoader)
    else(
    removechild(myLoader1)
    Anyone have a method for this?

    yes, you can use the same urlrequest but just change its url property:
    // initialize, for example in frame 1.  this is done once and never again:
    var loader:Loader=new Loader();
    var urlR:URLRequest=new URLRequest();
    //  then in frame 2, for example:
    urlR.url="page1.swf";
    loader.load(urlR);
    //  in frame 20, for example:
    urlR.url="page2.swf";
    loader.load(urlR);
    // in frame 30, for example:
    urlR.url="page3.swf";
    loader.load(urlR);
    //etc.  if you're loading any swfs that play streams (sound or video), you'll want to add some code to this.

  • Need Help With Video In Flex Mobile

    Hi,
    I have been searching quite a bit for information on this and have found really nothing useful for my problem. So far, I've converted the actionscript code posted here: http://www.adobe.com/devnet/flash/articles/osmf-media-player.html
    to work within my ios mobile project. The problem is that no matter what I have tried, I can hear the video but not see it. That codes uses the OSMF framework, which uses StageVideo I think, so I've tried setting the application background alpha to 0 as has been posted about; still no video though. The project is also set to use direct rendering. I've even tried some bare bones AS code to implement the StageVideo, as others have posted here, but still same thing. So can anyone either show me a working example or provide any suggestions on what I might be doing wrong?
    thanks

    Hi, Keith Lee -
    I'm sorry that I cannot help with your problem, but I'm posting a few URLs that may perhaps help - 
    Working with video: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e1a.html
    Getting started with stage video: http://www.adobe.com/devnet/flashplayer/articles/stage_video.html
    Stage video articles and tutorials: http://www.adobe.com/devnet/flashplayer/stagevideo.html
    ActionScript reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/StageVideo. html
    Thanks,
    Mallika Yelandur
    Adobe Community Help & Learning

  • Need help with a simple basketball game.

    Hi im new here and I need help with making this simple basketball game.
    Im trying to recreate this game from this video. Im not sure if he is using as2 or as3
    Or if anyone could help me make a game like this or direct me to a link on how to do it It would be greatly appreciated.

    If you couldn't tell whether it is AS2 or AS3, it is doubtful you can turn it from AS2 into AS3, at least not until you learn both languages.  There is no tool made that does it for you.

  • Help with Errors please!

    Hi, I'm building a Flash website.
    I've used frames with names to contain the different 'pages'
    of the site. On the frame called 'SVHS1' I've built an XML mp3
    player with buttons and a volume slider.
    I'm having a couple of problems with this section of the
    site.
    Firstly: when I 'test movie' and navigate to the mp3 player
    section it all works fine, the mp3s load correctly, the playback
    controls work fine, and the volume slider does what it's supposed
    to do. But if I've used the volume slider to adjust the volume (and
    only then) and then navigate to the next frame 'SVHS2' (or any
    frames that are later in the main timeline) I get multiple
    occurrences of the following error in the output pane:
    TypeError: Error #1009: Cannot access a property or method
    of a null object reference.
    At PSPWebsite1_fla::MainTimeline/adjustVolume()
    I understand (from reading other posts/help etc.) in
    principle what is causing this, but my knowledge of AS3 is too
    limited to know exactly what is wrong with my script or how to fix
    it.
    Secondly: if I press the stop button on my mp3 player and
    then navigate to another frame (any frame before or after
    ‘SVHS1’) the site works fine, and the mp3 player works
    perfectly if I go to that frame again. But if I navigate to another
    frame without first stopping the song it continues to play even
    though I’m not on the mp3 player frame, and if I go back to
    the mp3 player before the song has finished it starts playing
    automatically from the beginning of the first song in the XML list
    again and simply doubles up the sound, which is horrible. When this
    happens the playback controls only affect the 2nd version
    (understandably).
    I think this is probably quite simple to fix, assuming that I
    have to write some script that tells the mp3 player to stop playing
    if/when the user navigates away from that frame...but I don’t
    know how to do this.
    Any help with either of the above would be much appreciated.
    The attached script is for the mp3 player frame.

    You can consider the trace function as being a "can you hear
    me now" helper (instead of an annoying tv commercial gimmick). It
    displays whatever it's told to in the same output window that you
    see that error message come up in. There are two ways I'll usually
    use it.
    I'll often end up simply using a trace("here"); as a means of
    seeing where a process is getting hung up. I gradually move that
    line of code thru what I know to be the step by step sequence of
    the code until "here" no longer shows up. It normally indicates
    that the preceding line of code is where the ball got dropped.
    In AS3, which is often a little more helpful when it trips on
    something, such as the error message you received which tells you
    there's a problem in the adjustVolume function, you can use it to
    see what element in that function is either undefined or out of
    scope.
    Place... trace(vol); ... just after the first line of code in
    that function to see if vol is a number. If it is, then you know
    that line is okay and you can move on to check the next line. If it
    isn't a number, then move the trace before that line and change it
    to... trace(volume_mc.slider_mc.x); ... and see if it is a value.
    If it isn't, then change the trace to check to see what
    trace(volume_mc); results in.... so on and so on.
    It's basically a process of working your way thru code to
    narrow down what piece is the undefined/out-of-scope (or a syntax
    error) element that is causing the problem.

  • Help with adding image onclick

    Hey everyone,
    I am making a simple game in AS3 and need help with adding an image once they have click on something.
    On the left of the screen are sentences and on the right an image of a form. When they click each sentence on the left, writing appears on the form. Its very simple. With this said, what I would like to do is once the user click one of the sentences on the left, I would like a checkmark image to appear over the sentence so they know they have already clicked on it.
    How would I go about adding this to my code?
    var fields:Array = new Array();
    one_btn.addEventListener(MouseEvent.CLICK, onClick1a);
    one_btn.buttonMode = true;
    function onClick1a(event:MouseEvent):void
        fields.push(new one_form());
        fields[fields.length-1].x = 141;
        fields[fields.length-1].y = -85;
        this.addChild(fields[fields.length-1]);   
        one_btn.removeEventListener(MouseEvent.CLICK, onClick1a);
        one_btn.buttonMode = false;
        //gotoAndStop("one")
    two_btn.addEventListener(MouseEvent.CLICK, onClick2a);
    two_btn.buttonMode = true;
    function onClick2a(event:MouseEvent):void
        fields.push(new two_form());
        fields[fields.length-1].x = 343.25;
        fields[fields.length-1].y = -85;
        this.addChild(fields[fields.length-1]);
        two_btn.removeEventListener(MouseEvent.CLICK, onClick2a);
        two_btn.buttonMode = false;
        //gotoAndStop("two")

    I don't know where you're positioning the button that should enable/disable the checkbox but for "one_btn" let's just say it's at position: x=100, y=200. Say you'd want the checkbox to be to the left of it, so the checkbox would be displayed at: x=50, y=200. Also say you have a checkbox graphic in your library, exported for actionscript with the name "CheckBoxGraphic".
    Using your code with some sprinkles:
    // I'd turn this into a sprite but we'll use the default, MovieClip
    var _checkBox:MovieClip = new CheckBoxGraphic();
    // add to display list but hide
    _checkBox.visible = false;
    // just for optimization
    _checkBox.mouseEnabled = false;
    _checkBox.cacheAsBitmap = true;
    // adding it early so make sure the forms loaded don't overlap the
    // checkbox or it will cover it, otherwise swapping of depths is needed
    addChild(_checkBox);
    // I'll use a flag (a reference for this) to know what button is currently pushed
    var _currentButton:Object;
    one_btn.addEventListener(MouseEvent.CLICK, onClick1a);
    one_btn.buttonMode = true;
    function onClick1a(event:MouseEvent):void
         // Check if this button is currently the pressed button
         if (_currentButton == one_btn)
              // disable checkbox, remove form
              _checkBox.visible = false;
              // form should be last added to fields array, remove
              removeChild(fields[fields.length - 1]);
              fields.pop();
              // clear any reference to this button
              _currentButton = null;
         else
              // enable checkbox
              _checkBox.visible = true;
              _checkBox.x = 50;
              _checkBox.y = 200;
              // add form
              fields.push(new one_form());
              fields[fields.length-1].x = 141;
              fields[fields.length-1].y = -85;
              this.addChild(fields[fields.length-1]);
              // save this button as last clicked
              _currentButton = one_btn;
         // not sure what this is
        //gotoAndStop("one")
    I'd also centralize all the click handlers into a single handler and use the buttons name to branch on what to do, but that's a different discussion. Just see if this makes sense to you.
    The jist is a graphic of a checkbox that is a MovieClip symbol in your library exported to actionscript with the class name CheckBoxGraphic() is created and added to the display list.
    I made a variable that points itself to the last clicked button, when the "on" state is desired. If I detect the last clicked button was this button, I remove the form I added and the checkbox. If the last clicked button is not this button, I enable and position the checkbox as well as add the form.
    What is left to do is handle the sitation where multiple buttons are on the screen. When a new button is pushed it should remove anything the previous button added. This code simply demonstrates clicking the same button multiple times to toggle it "on and off".

  • Please help with LoaderContext().checkPolicyFile

    Hello everybody, i'm newbie in as3 and I need your help with
    a such problem. It's need to download gif pictures. Flash widget
    and source of gif pictures are placed in different domains.
    Locally in Flashcs3 environment it works okay but if I put it
    on IIS server I get the such error message from security box under
    the firefox browser:
    SecurityError: Error #2123: Security sandbox violation:
    LoaderInfo.content:
    http://www.mydomain.com/test/widget.swf
    cannot access www.seconddomain.com/gif/submit_but.gif. No policy
    files granted access.
    at flash.display::LoaderInfo/get content()
    at com.techwire.classes::ResourceLoader/completeBmpHandler()
    For this case I've found the such solution:
    Security.loadPolicyFile("
    http://www.mydomain.com/test/crossdomain.xml");
    var context:LoaderContext = new LoaderContext();
    context.checkPolicyFile = true;
    loader.load(request, context);
    in crossdomain.xml :
    <cross-domain-policy>
    <allow-access-from domain="*" secure="false"/>
    </cross-domain-policy>
    But after that I have the same error message. What i am doing
    wrong? Help me please..
    code of class:
    public class ResourceLoader extends Dispatcher
    public function ResourceLoader():void
    Security.loadPolicyFile("
    http://www.mydomain.com/test/crossdomain.xml");
    loader = new Loader();
    request = new URLRequest();
    loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,
    completeBmpHandler);
    loader.contentLoaderInfo.addEventListener(IOErrorE
    vent.IO_ERROR, ioBmpErrorHandler)
    public function loadResources(urlsArray:Array=null):void
    var context:LoaderContext = new LoaderContext();
    context.checkPolicyFile = true;
    request = new URLRequest(my_url);
    //loader.load(request);
    loader.load(request, context);
    private function completeBmpHandler(event:Event):void
    count++;
    resources.push(Bitmap(Loader(event.target.loader).
    content));
    var loader:Loader = event.target.loader;
    var textureMap:BitmapData =
    event.target.content.bitmapData.clone();
    }

    What is the domain that you're loading the gif from?
    if your loading swf is at
    http://www.mydomain.com
    You need
    Security.loadPolicyFile("
    http://www.seconddomain.com/crossdomain.xml");
    And the crossdomain file at that location needs to grant
    access to your mydomain.com or to "*" which is all domains as per
    your example.

  • Can you help with the code to publish Flash to my own domain.

    Thank you for your help, I publish the my site to my own domain, I do not use .Mac, I tested your code and ity works well on .Mac, can you help with the code to publish to my own domain.
    Thank you again

    You appear to have just collected a variety of code snippets and thrown them together, including a section of AS2 code ( gage.onRelease = function() {... )
    The suggestion I offered yesterday still stands.  You should find a tutorial regarding AS3 and the atan2 function.  Beyond that, what you show suggests this is a school assignment.  You should seek help from your fellow students and instructor if that is the case.

  • Help with video in Flex - Alternative to embedding .flv?

    I'm building a Flex application that needs to play a video, which I have in .flv format.  I tried the mx:VideoDisplay component, and it was great, but, unfortunately, I need to be able to package the entire application into a single file, and Flex doesn't support embedding .flv files.  Next I tried converting the .flv to a .swf, embedding that, then using mx:SWFLoader to display it.  This worked, except that I can no longer control the video playback; the video just keeps endlessly looping.  I need to be able to stop the video, and ideally I would like access to something like the complete event from mx:VideoDisplay, so that I can hide the video when it has reached the end.
    I have tried a couple of solutions based around the idea that the content of the .swf can be treated as a MovieClip, but none of these worked for me.  Any ideas?

    Hi, Keith Lee -
    I'm sorry that I cannot help with your problem, but I'm posting a few URLs that may perhaps help - 
    Working with video: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e1a.html
    Getting started with stage video: http://www.adobe.com/devnet/flashplayer/articles/stage_video.html
    Stage video articles and tutorials: http://www.adobe.com/devnet/flashplayer/stagevideo.html
    ActionScript reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/StageVideo. html
    Thanks,
    Mallika Yelandur
    Adobe Community Help & Learning

  • Hi i need help with my mp3 flash player

    Hi i need help with my mp3 player, i wan't to add pause button..can you help me?
    i created button i added btn_pause and it won't work.
    function soundStatus(){
              var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
              _root.loader.loadBar._width = amountLoaded * 260;
              duration = _root.sound_mc.sound_obj.duration;
              position = _root.sound_mc.sound_obj.position;
              _root.playHead._x = position / duration * 272 + 5;
    btn_play.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.songStarter(songfile[song_nr]);
    btn_pause.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.sound_obj.pause();
    btn_stop.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.sound_obj.stop();
    btn_fw.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
              _root.sound_mc.songStarter(songfile[song_nr]);
    btn_rev.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
              _root.sound_mc.songStarter(songfile[song_nr]);
    <moved by mod from as3 - kglad>


    function soundStatus(){
              var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
              _root.loader.loadBar._width = amountLoaded * 260;
              duration = _root.sound_mc.sound_obj.duration;
              position = _root.sound_mc.sound_obj.position;
              _root.playHead._x = position / duration * 272 + 5;
    btn_play.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.songStarter(songfile[song_nr]);
    btn_pause.onRelease = function() {
              clearInterval(timeInterval);  // you should re-set this interval when the unpause button is clicked
             // _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.sound_obj.stop()
    btn_unpause.onRelease=function(){
    this._parent.sound_mc.sound_obj.start(position/1000);
    btn_stop.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              this._parent.sound_mc.sound_obj.stop();
    btn_fw.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
              _root.sound_mc.songStarter(songfile[song_nr]);
    btn_rev.onRelease = function() {
              clearInterval(timeInterval);
              _root.timeDisplay_txt.text = "00:00/00:00";
              (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
              _root.sound_mc.songStarter(songfile[song_nr]);

  • Help with linking buttons to Scenes

    Hey,
    Rookie to Flash and AS3. Just needed some help with my buttons. Im making a flash program about pancakes (random I know). I have a "Mainmenu" scene and then a "Recipe" scene. I have a button on my mainmenu which takes me to the recipe page when I click it, the code behind the button is
    "stop();btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {
    gotoAndStop(1, "Recipe");
    Then when I arrive at my recipe page I have a button which will take me back to my MainMenu, the code behind that button is:
    "stop();btn_home.addEventListener(MouseEvent.MOUSE_DOWN, mouse5DownHandler);function mouse5DownHandler(event:MouseEvent):void {
    gotoAndPlay(1, "MainMenu");
    So I run my program and the first button works and takes me to recipe page but the button to get to the main menu does nothing, click it and no response or anything
    Please help

    First, hopefully having all your code mushed onto the same line is a copy/paste error, otherwise it should look like...
    stop();
    btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {
         gotoAndStop(1, "Recipe");
    If the intention is to click the buttons to make them work, then you should use CLICK instead of MOUSE_DOWN.  MOUSE_DOWN can be a persistent state whereas CLICK involves releasing it afterwards.
    As for the code to get you back home, where is it located on the timeline?  Are you getting any error messages when you try to use it?
    One thing you should learn to use is the trace() function.  It is useful for troubleshooting.  You can use it now to see if your second button is talking to the function at all...
    stop();
    btn_home.addEventListener(MouseEvent.CLICK, mouse5DownHandler);
    function mouse5DownHandler(event:MouseEvent):void {
         trace("the button works okay");
         gotoAndPlay(1, "MainMenu");
    If you don't get that message in the output panel, you'll know the button is not properly coded to work.
    Most folks here will recommend you get away from using scenes in a design that includes navigation--they have a history of being problematic.  Instead of using scenes, divide the one main timeline up into sections or use movieclips for the sections and manage their visibility... or do a bit of both.

Maybe you are looking for

  • What is the PXI-7854R Digital IO Type and is it User Setable.

    Are the Digital Outputs on the 785x cards Line Driver, Open Collector, or Push-Pull Outputs? Specifically the card I am working with is PXI-7854R. Here is my basic question, but notice that the R-series cards are missing. http://digital.ni.com/public

  • There is no sim card installed in the iphone you are attempting to activate

    hi my iphone was lock from orange uk. and i made to unlock from legal way. ıt has done but after ios 5 upgrade iphone doesnt activate it always want to sim card. there is also sim card but not orange one.  it is freezin from here http://imageshack.us

  • [Newbie] Model2 JSP + JDBC + JSTL forEach

    Hi, This is my first post. I'm running into a bit of brain failure over decoupling my JSP view page from the specifics of the JDBC the model uses. I want to avoid the easy route of: Controller - interogates request as default main listing page. - run

  • Server not starting - Failed to Connect to hostname/3201

    Hi,    The Sneak Preview Version was working fine.. All of a sudden the server is not starting up.. It is throwing up the following error in the server0 log default.trc ##0#0#Error#1#/System/Server#Plain###Encomi: failed to connect to ganni/3201(Conn

  • YouTube upload problems.

    I'm probably in the wrong forum but... I am having problems uploading my videos from FCE (encoded in 'Streamclip) onto YouTube. I have tried MP4, MP2 and .wavfiles. The progress bar on Youtube seems to stall right at the end. This is my first time do