HELP: Preloader and Button AS3

Hi guys!
I used to work on AS2 to make my animations, buttons and portfolios, but now I needed to use AS3 to make some forms interact with some PHP script.
TextInputs and Buttons on COMPONENTS are working and interacting normally with PHP. My PreLoader is working great too. But what should the easiest is not working: MY SIMPLE BUTTONS! It used to be so easy in AS1 and 2, but now on AS3 it's not working. I am putting all my action and codes in a ACTIONS FRAME in the top of my animation, but it is not working!
I have my Preloader on my frame 1 working, calling my animation on frame 2. The code is here (it's working):
stop();
addEventListener(Event.ENTER_FRAME, loading);
function loading(event:Event) {
var bytestotal = stage.loaderInfo.bytesTotal;
var bytesloaded = stage.loaderInfo.bytesLoaded;
var sclbar = Math.round(bytesloaded*100/bytestotal);
custom_animation.gotoAndPlay(sclbar);
if (bytesloaded >= bytestotal) {
removeEventListener(Event.ENTER_FRAME, loading);
removeChild(custom_animation);
gotoAndPlay(2);
Then I placed my buttons actions on the frame 2.
If I use the action:
home_btn.addEventListener(MouseEvent.CLICK,clickHome);
function clickHome(evt:MouseEvent):void {
gotoAndPlay(2);}
release_btn.addEventListener(MouseEvent.CLICK,clickRelease);
function clickRelease(evt:MouseEvent):void {
gotoAndPlay(2690);}
My movie pauses and no action is added to my buttons.
I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_Scene1_fla::MainTimeline/frame2()
If I use the action:
addEventListener("addedToStage", oas);
function oas(ev){
init();
home_btn.addEventListener(MouseEvent.CLICK,clickHome);
function clickHome(evt:MouseEvent):void {
gotoAndPlay(2);}
release_btn.addEventListener(MouseEvent.CLICK,clickRelease);
function clickRelease(evt:MouseEvent):void {
gotoAndPlay(2690);}
The movie plays complete, but I get no actions in buttons and a error in my components textinput and button (they look like shaking).
I get this error: 1180: Call to a possibly undefined method init.
I tried to use the import flash.display.SimpleButton too, but it doesn't work too.
Anyone could help me????
Thanks,
Pedro

If you can provide a clear explanation of where the buttons are and where the code for them is located that might help lead to a solution.  From what you have described already it is not clear where the code is and where the buttons are.  You should not have to use an init function if you are doing so to wait for the buttons to be loaded... they are already loaded when you get wherever they are.
For the 1009 error, it is indicative of the object targeted by your code does not exist in theframe where that code is.  SO if you have your code on frame 1 and your buttons are in frame 2, that would account for that error, as well as a few other possible scenarios.

Similar Messages

  • Digital Publishing Suite Help | Hyperlink and button overlays

    This question was posted in response to the following article: http://helpx.adobe.com/digital-publishing-suite/help/hyperlink-overlays.html

    @Fabian – just for the records: there is a way.
    But it's quite a hack!
    You cannot rely on it for future versions of DPS or InDesign…
    1. You start with two buttons and a single MSO on the same page.
    Button 1 says: Go to State 1 of MSO
    Button 2 says: Go to State 2 of MSO
    NOW the hack:
    2. DUPLICATE (do not copy/paste) the two buttons by [alt] + drag with the mouse to page 2.
    You'll see, that the duplicates still control the MSO on page 1.
    The following screen shots will illustrate this:
    Here the state control of the green button on page 1:
    Here the state control of the green button on page 2:
    (Note the difference!)
    To make it clear again. I would not recommend to do it.
    But you could test it. Come back and report if that is working for you with the most recent versions of InDesign and ADPS…
    (I accomplished this with InDesign CS5.5 v7.5.3)
    Uwe

  • Deleting/hiding a preloader and a button

    Pls help - i have to figure this out before 2pm ESP today. I
    purchased a flash intro template and switched out the text, images,
    etc. for a colleague for an internal presentation. Here's the
    problem: he wanted the intro to run twice - seemlessly - so at the
    end of the first .fla file I changed the 'stop" action to a
    loadMovie action. The problem is the preloader and button that is
    OK when the first .swf file runs is fine but I can't figure out how
    to delete it from the 2nd .swf file. (The company i bought the
    template from said this modification is out of their realm...) I'm
    desparate now... The .fla files are huge - but I can send a link to
    show what I mean. Thanks,
    Lisa

    I solved it in this way:
    package untitled24;
    import javax.swing.UIManager;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    public class Application1 extends Frame
       private TextArea tekstgebied;
       private MenuItem ok;
       public Application1()
        MenuBar menubalk = new MenuBar();
        setMenuBar(menubalk);
        Menu hoogste = new Menu("ok");
        menubalk.add(hoogste);
        ok = new MenuItem("test");
        ok.addActionListener(new MenuHandler());
        hoogste.add(ok);
        tekstgebied = new TextArea();
        add(tekstgebied);
        addWindowListener(new WindowAdapter()
          public void windowClosing(WindowEvent e)
            dispose();
            System.exit(0);
        setSize(300,200);
        setTitle("oef 1");
        setVisible(true);
        public static void main(String[] args )
          new Application1();
        public class MenuHandler implements ActionListener
          public void actionPerformed(ActionEvent f)
            FileWriter uit;
            String inhoud;
            inhoud = tekstgebied.getText();
            try
              uit = new FileWriter("bestand.txt");
              uit.write(inhoud);
              uit.close();
            catch (IOException e)
              System.out.println("Fout bij het openen, maken of sluiten bestand");
              e.printStackTrace();
      }

  • I cant get hyperlinks and buttons to work...

    I am creating basic Folio's but I cant get none of my Hyperlinks or buttons to work... Am I doing something wrong?

    Hi,
    Make object for button, select it and press "convert to button" (Buttons and Forms tab). Choose "go to url" action (it is located under tiny plus button) and paste or type in full url with http://  in "URL" field.
    Likewise for hyperlinks select text and press "Create new hyperlink" on Hyperlinks panel then paste full url (uncheck "Shared Hyperlink Destination") and press OK.
    It should work. Of course if you have Internet connection.
    If your links point to pages or articles inside the folio use navto:// instead of http://
    More info:
    Digital Publishing Suite Help | Hyperlink and button overlays

  • Help with Quiz pages and buttons (please)

    We use Captivate 6 with a subscription. I have put together a couple of modules with question pools, and some with just a few questions pages inserted. The last time I created a new captivate project, I put inserted quiz pages and the buttons were different then they had been before. The first few times they were grey, now they are green and a bit smaller. Looking at the proporties for each page and button, I cannot see anything that is different othe than one is a text button and the other is a transparent button. Both buttons are marked as default quiz button style. I don't use any themes. To make this short, I would like to know if there is a way to make the buttons the same every time I add a page, or a pool? I am not yet up to designing my own buttons, but probably will here shortly. Right now I need to get some training modules completed as quickly as possible so I don't have the time to reinvent the wheel (so to speak). The only other thing that I noticed was different in the projects was that in the skin editor one uses one called [default](modifired) and the other one uses one that I created. HOWEVER, I have another one that uses my custome skin and the buttons are grey on that one which is the same as the default one. I don't think the skin has anything to do with the button look. Correct me gently if I am wrong on this.
    Thanks for the help.

    Just one remark: in CP6 you always use a theme. And quiz slides have their own master slides, that will always be used. The buttons take on the style you see on those master slides, and this style can also be found in the object style manager. Skin and object styles are part of the theme. Probably you have overridden some of the styles defined?
    Lilybiri

  • Help with images and buttons

    I was wondering if anyone could recommend a tutorial or point me in the right direction. I've been trying to figure out how to use buttons to add images (been using png from photoshop with alphachannel) to a canvas. I don't have any problems skinning the buttons nor putting in a single image, nor text. As far as getting the images to layer when the buttons are clicked then I'm pretty lost. Not sure if an array is best or if adding and removing them as children in another container would be any easier..

    I've been using flash builder beta 2. I was planning on embedding the images. I'm not sure if the help files and examples I am reading are not compatible or if I just have the syntax wrong. I haven't been able to find any examples that use embedded images and toggle visibility. I've used spark components. In design mode it puts the code in for a button when drag-dropped, then recommends using spark component instead. It seems that the only time that the images really do anything is when there's a spark component.
    I've never used flex before would it be easier to use wordpad and try compiling it with something other than flash builder?

  • Help with Flex preloading and transitions please

    I downloaded and installed Flex Builder 3, and I think I have
    my slideshow project about 75% finished. It's the last 25% that I
    can't figure out, regarding preloading and transitions. Can someone
    take a look at the code below and see if you can help me? I tried
    to write the code in such a way that you can debug it from any
    computer as it's calling an PHP/XML file and images that are on a
    server.
    Here's what's finished...
    1. PHP file looks at image files on server and builds XML
    file.
    2. Flex app calls PHP file and traverses the XML in the
    response.
    3. Flex app figures out how many "slides" there and displays
    the slides one at a time, each slide with 3 images, with a 5 second
    delay between "slides."
    Here's what's not finished...
    1. I would like a fade-out to white at the end of each slide,
    and a fade-in from white at the beginning of each slide.
    2. I need each slide to stay put intil the next slide is
    pre-loaded. That is, during the 5 seconds that a slide is
    displayed, the next 3 images need to be preloaded, and then the
    slide should not progress to the next until slide is completely
    loaded.
    3. The very first slide should not appear until it is
    completely loaded, and when it does appear, it should fade in from
    white.
    How do I do this?!? Please help! Here's the code...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="472" height="195"
    backgroundGradientAlphas="[1.0, 1.0]"
    backgroundGradientColors="[#FFFFFF, #FFFFFF]"
    creationComplete="StartFunction();" >
    <mx:Fade id="fadeOut" duration="2000" alphaFrom="1.0"
    alphaTo="0.0"/>
    <mx:Fade id="fadeIn" duration="2000" alphaFrom="0.0"
    alphaTo="1.0"/>
    <mx:Image id="PhotoA" x="0" y="0" width="154"
    height="195" />
    <mx:Image id="PhotoC" x="318" y="0" width="154"
    height="195" />
    <mx:Image id="PhotoB" x="159" y="0" width="154"
    height="195" />
    <mx:Script>
    <![CDATA[
    private function StartFunction():void {
    var oXML:XML = new XML();
    var sXmlUrl:String = "
    http://www.smis.org/templates/smis/slideshowxml.php";
    var oUrlReq:URLRequest = new URLRequest(sXmlUrl);
    var oUrlLoader:URLLoader = new URLLoader(oUrlReq);
    oUrlLoader.addEventListener("complete", xmlLoaded);
    function xmlLoaded(event:Event):void {
    oXML = XML(oUrlLoader.data);
    var iSlide:int = 0;
    function ChangeImages():void {
    PhotoA.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[0]["@filepath"]);
    PhotoB.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[1]["@filepath"]);
    PhotoC.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[2]["@filepath"]);
    iSlide++;
    if (iSlide >= oXML.children().length())
    iSlide = 0;
    PhotoA.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[0]["@filepath"]);
    PhotoB.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[1]["@filepath"]);
    PhotoC.load("
    http://www.smis.org/" +
    oXML.slide[iSlide].photo[2]["@filepath"]);
    iSlide++;
    if (iSlide >= oXML.children().length())
    iSlide = 0;
    setInterval(ChangeImages,5000);
    ]]>
    </mx:Script>
    </mx:Application>

    What you've done is beyond my capabilities, as of now. But, I
    ran into the same problem with the fading in and out of the photos.
    Here's my solution.
    I defined my fade with only the id and the duration
    parameters. No 'from' and 'to'.
    Then I used the 'showEffect' and 'hideEffect' parameters.
    showEffect="{bannerFade}" hideEffect="{bannerFade}"
    Works like a charm for my project.
    I hope this helps.
    Randy

  • I have created an iMovie but cannot share it. I have looked at the help menu and have tried to follow these instructions but cannot get the sharing button to open anything.

    I have created an iMovie but cannot share it. I have looked at the help menu and have tried to follow these instructions but cannot get the sharing button to open anything.

    Do you have MacKeeper installed? If so, you need to uninstall it. There is a known issue where MacKeeper disables all the sharing functions from the new iMovie.
    Uninstall MacKeeper, then re-install iMovie.
    Keep MacKeeper uninstalled.

  • Please help me with an as3 preloader

    Hi All,
    I'm a flash noob and really need some help. I spent two full days trying to figure this out and I'm completely stuck.
    I'm using a common preloader technique which basically uses one swf file (preloader.swf)  to open another swf file (content.swf) using the following flash object:
    var request:URLRequest = new URLRequest("content.swf");
    It almost works but the progress never quite makes it to 100% but it suddenly stops around 85% and launches the video early. It screws up the timing and the video becomes out of synch with the audio.
    Any help would be GREATLY apprecaited.
    You can see what I mean here:
    http://redwoodsmedia.com/help/preloader.html
    Also the source files are included in this thread.
    Thanks in advance.
    Paxton

    If you include the code that is in that file you may get more help as some people cannot and others will not open files that people attach.
    For the moment I'll suggest taking a look at the tutorial linked below to see if it is different than what you've done...
    http://www.gotoandlearn.com/play?id=85

  • Could someone help me and telling me how I do a copy from one song. don't tell me press the button copy - doesn't work anymore!!!

    could someone help me and telling me how I do a copy from one song. don't tell me press the button copy - doesn't work anymore!!!???

    i made a "playlist" and did some aac-version, because i need the songs for different length of time. but some of this songs i need the same way (i teaching aqua gym lessons). and earlier i could made a copy and past and it worked. but now, nothing worked! everytime something is different.
    sorry, actually i am not so good in english to explain my problems i prefere german.

  • Preloader stops buttons from working?!

    Hi,
    I made a flash file with buttons that go here and there and everything was fine
    except it takes a while to load so i added a preloader and suddenly the compiler
    is throwing the following error:
    Error #1009: Cannot access a property or method of a null object reference.
    ... and the buttons have ceased to function.
    Here is my code:
    preloader:
    import flash.events.ProgressEvent;
    function update(e:ProgressEvent):void
    var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
    if(preloaderMC is MovieClip){
    preloaderMC.gotoAndStop(percent);
    if(percent == 100){
    play();
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
    // Extra test for IE
    var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
    if(percent == 100){
    nextFrame();
    stop();
    scene 1:
    stop();
    import flash.events.MouseEvent;
    //---Hair Button---\\
    hair_btn.addEventListener(MouseEvent.CLICK, hairClick);
    function hairClick(event:MouseEvent):void{
        gotoAndStop("4");
    //---Home Button---\\
    home_btn.addEventListener(MouseEvent.CLICK, homeClick);
    function homeClick(event:MouseEvent):void{
        gotoAndStop("1");
    //---Contact Button---\\
    weddings_btn.addEventListener(MouseEvent.CLICK, weddingsClick);
    function weddingsClick(event:MouseEvent):void{
        gotoAndStop("3");
    //---Products Button---\\
    products_btn.addEventListener(MouseEvent.CLICK, productsClick);
    function productsClick(event:MouseEvent):void{
        gotoAndStop("2");
    //---Gallery Button---\\
    gallery_btn.addEventListener(MouseEvent.CLICK, galleryClick);
    function galleryClick(event:MouseEvent):void{
        gotoAndStop("5");
    //---Contact Button---\\
    contact_btn.addEventListener(MouseEvent.CLICK, contactClick);
    function contactClick(event:MouseEvent):void{
        gotoAndStop("6");
    Please help me sort this out!
    Thanks

    If you are getting a 1009 error, the file will not work, so the buttons might not be the problem.
    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is not in the display list
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • Preloader in CS4/AS3

    I need help.  I'm trying to create a preloader using CS4/AS3, and so far I've accomplished what I consider to be "one step forward - two steps back".  I've found plenty of guidance for creating/manipulating in AS2, but..... next to nothing for AS3. Everything that I have found tells me what to do with the .swf movie that I've created.  The problem..... creating the .swf.  Can someone guide me in the right direction. 
    So far one of the best resources (most thorough anyway) is www.gotoandlearn.com.  The problem is each tutorial that I've seen still begins with a pre-created .swf movie.
    Thanks in advance.

    Well, kind of..... and not.  The preloader appears to come up when I do a "Publish Preview", but it's instantaneous, then the movie loads.  Ironically, without the preloader, the redirect works great... with the preloader, the movie simply loops.....
    New screencaps attached...

  • 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.

  • Blank screen between preloader and beginning of SWF movie

    I'm having a problem with a published SWF. A long lag time is occurring between the end of my AS3 preloader and the beginning of my SWF movie. Once the preloader disappears, the SWF screen goes blank for up to 10 seconds before the movie begins. I've monitored the SWF's download progress using Firebug, and the preloader disappears once 45% of the SWF has been downloaded, as is to be expected.  But the movie does not begin until most of the SWF has been downloaded, which causes the 10 seconds of blank screen. After reading some blog posts, I suspected that the audio embedded in the Captivate presentation was causing the SWF to download all of the audio before starting the movie. I followed recommendations to add a tiny amount of silence the beginning of each slide, but it hasn't resolved the problem.
    Does anyone know how to fix a long lag time between a preloader and movie? My SWF settings and other details are below. Thanks in advance.
    - Using Captivate 5
    - The presentation has 18 slides.  Each slide has one JPG and one audio clip.  (The audio clips were imported one at a time, instead of importing one large audio file and having Captivate spread it across multiple slides.)
    - Each slide is .4 seconds longer than its audio clip, leaving .2 seconds of silence before and after the audio clip. 
    - SWF Size and Quality are set to Low
    - Audio Quality is set to MP3, 64Kbps, 44.100 KHz
    - Using AS3 preloader set to 45%
    - The SWF is hosted on a web server and is viewed via the htm file that is generated when the SWF is published.
    Kim

    Hi Vikranth,
    Thanks for your help.  The online SWF is here:
    http://leo.lincolninst.edu/eTeach/captivate-tests/inside-focus-area/new-opt-img-mp3-chunks -full-2/inside-focus-area-new-opt-img.htm
    I've also posted the same SWF with a 15% preloader here (the smaller the preloader percentage, the longer the blank screen):
    http://leo.lincolninst.edu/eTeach/captivate-tests/inside-focus-area/new-opt-img-mp3-chunks -full-2-15/inside-focus-area-new-opt-img.htm
    I've sent the cptx file to your email address.
    Kim

  • ID 5.5 Interact. PDF, cannot remove white background for Multi-States and buttons.

    Hi
    I am working on an Interactive PDF Portfolio document. The problem I have is with Multi-State object feature with several buttons going to states that need to be exported as a SWF and imported back into InDesign 5.5. See, the background of my entire doc. is GREY, but when I import the SWF (as directed in Lynda.com videos correctly) and export the entire doc as Interactive PDF and view it in Adobe Acrobat Pro (version 10.1.1) is when all the trouble starts.
    When I try to get rid of the WHITE background around the Multi-State objects and the buttons for them (using Select Object Tool and then control+click on it to change the Properties to Transparent Background Appearance) it does not change, even when I go forward and backward to the page.
    Does the option of removing white background and making it transparent work only for Animation, but not Multi-State feature with buttons?
    Can anyone suggest any other tecnique to create a nice slide show that works in Interactive PDF in ID CS5.5? Please..
    Sincerely,
    in need of help,
    Eve

    I have 8 Multi-State objects in one stack on the left and the 8 buttons for each state in the stack on the right. The background of my document is dark grey. There is space inbetween Multi-State objects and the buttons that show the grey background. But after exporting as SWF the Multi-States together with the buttons and placing the SWF back in the PDF file, the space inbetween Multi-States and buttons that is supposed to show the grey background appears white. The problem is that I cannot even change this white background to transparent in Acrobat Pro, as well. I used to do that to animations and it worked, but not in this case.

Maybe you are looking for

  • Field population after ds enhancement.

    Dear gurus,   I enhanced sales data source by adding 3 fields from  database tables of different application component. I write the code to populate the fields by using enhancement rsap0001. Every thing is fine from r3 side in the bw system previousl

  • I get "An unexpected error has occurred" whenever I try to create item in a list or view site permission page

    I am working a SharePoint site with a custom masterpage and css. Everything displays just fine and the site functions with several subsites, and so forth. I have double-checked to ensure that important content placeholders were on the new masterpage,

  • Word Wrap in JTextPane

    I'm working with just a JTextPane, no JScrollPane around it or anything. I would like the JTextPane to use word wrap, but it looks like by default it does not. I looked through some API stuff and tutorials and found nothing on the subject. The code i

  • Problem Installing P.O. 8i (8.1.6)

    I installed forms and reports 6i on the default home and personal oracle 8i release 2(8.1.6) on different oracle home. During installation it give error message ora-012638 credential retrieval error at 95% of database creation. If deinstall all and a

  • Hardcode Logical Column

    Hi, I need to hard-code a logical column to hold 2 values "Pay" and "Buy" and i need this field in Prompt as multiselect. Any help will be greatly appreciated. Thanks