12 Replies Latest reply on Jul 30, 2012 7:52 AM by robdillon

    Quick question from someone new to flash....

    rmacatee

      Hey guys,

       

        I'm having a very weird problem with a project I'm working on.  I have a multi-scene project and on one of the scenes there are three buttons which the user can interact with.  Each button takes the user to a difference scene that starts with music, text fade ins, and pretty simple stuff.  Two of the buttons worked fine, and I duplicated the scene I used for the second button when I started on the third since they have the same general format.  What is really weird is that when I have the third button link to the second scene (via actionscript), everything works fine...but when I use actionscript to link the third button to an EXACT duplicate of the second scene, there is a brief burst of sound before the main track that is supposed to begin starts...almost as if it tried to play a sound file for a brief second and then abruptly stopped - any ideas what could be going on?  It just doesn't make sense to me that the annoying 1 second sound would only be there when I make a copy of the scene, but not when I link to the original....

       

       

      Also, since my project contains many scenes, is there a way for me to preview only one scene that will still let me click on a button to link me to another scene - seems like that only works when I compile the entire movie, when I preview a scene in isolation it gives me a compiler error saying the scene I'm linking to can't be found (likely because when you preview a scene in isolation it doesn't compile any of the button-linked scenes)...

       

      Hope this made sense!

       

      Thanks!

       

      -Ricky

        • 1. Re: Quick question from someone new to flash....
          robdillon Most Valuable Participant

          Using scenes is always problematic. You really shouldn't be using scenes, that's a methodology that was abandoned at about Flash 2. The central problem is that when a scene based Flash file is saved as an .swf, Flash concatenates all of the scene timelines end to end to make one, long, timeline. One of the resulting problems is that you may end up with duplicate frame labels, and function and variable names.

           

          While Flash will warn you about duplicate frame labels, it may have difficulty resolving the duplicates, even if your code refers to the scene and the frame label.

           

          Another problem with using scenes is that you end up with one large .swf file that may not download quickly or efficiently and can result in unpredictable playback. At runtime, when Flash will always use the first named thing that it finds, so, if there are two frame labels with the same name, Flash will always go to the first one in the timeline. If it gets completely confused, Flash will always go back to the first frame of the movie and start over, this is the looping that you may see when there is a problem in playback.

           

          A better method for producing a movie made of many parts is to produce each section as a unique Flash movie. Then, at runtime, load each of these movies separately. This may seem more complex, but it will yield a more predictable user experience, a simpler production process, and a simpler testing process.

          • 2. Re: Quick question from someone new to flash....
            rmacatee Level 1

            Hey Rob,

             

              Thanks for the tip.  I've gone about breaking everything into one scene movies, and I've got code that, upon the click of a button, loads the new .swf thusly:

             

            import flash.display.Loader;

            import flash.net.URLRequest;

             

            stop();

             

            var singleLoader:Loader = new Loader(); 

             

            btnCont_scene1.addEventListener(MouseEvent.CLICK, btnContClick);

             

             

            function btnContClick(event:MouseEvent):void

            {

                removeChild(singleLoader);

                var request:URLRequest = new URLRequest("DT-Session1-Male_AnxietyIntr2.swf");

                singleLoader.load(request);

                addChild(singleLoader);

            }

             

            However, I'm unsure how to go about clearing the screen first?? The code above just tries to copy right over it without clearing the stage first...

             

            Thanks!

             

            -Ricky

            • 3. Re: Quick question from someone new to flash....
              rmacatee Level 1

              Oops the removeChild actually shouldn't be there, that was just something I was playing around with to try to get the screen to clear.

              • 4. Re: Quick question from someone new to flash....
                robdillon Most Valuable Participant

                Yes, when you add a child object to the display list that new object will be placed on top of whatever is already on the stage. If you don't position this new object, it will be positioned with its upper left corner at the upper left corner of the stage.

                 

                Working with the display list and loading new objects is a complex subject, but simply put, loading in a new .swf works pretty much the same as opening a new .swf in a browser window. When you call for that new .swf it will begin to stream into your existing movie. It will begin to run or not depending on how it was coded. One difference between loading an .swf into a browser and loading an additional .swf into an existing .swf is that the background for that additional .swf does not load. The background, the color layer that you define in the movie's properties, is only used for the first movie that is loaded into the browser. This means that if you create a movie with a blank first frame and a stop(); directive at that first frame, and then load that movie, the user will not see anything on the stage as that movie loads.

                 

                Alternatively, you can set an x and/or y position for the newly loaded movie that is off the visible area of the stage. I often load in new movies with a y position of -1000. Then, when I want to actually use that movie, I change its y position property value so that it shows on the stage.

                 

                You can then either move that movie back off the visible area or you can use removeChild() to get rid of the movie if you no longer need it.

                 

                When you load new content, how you make the new content appear on the stage and how you remove that content are all part of the design of your website. You can load in all of the individual parts at the start and then show and hide each piece as needed, or you can wait until the user asks for a particular part and then load that part as it is asked for.

                 

                Does that help?

                • 5. Re: Quick question from someone new to flash....
                  rmacatee Level 1

                  I've been trying to use the method of making one with a blank first frame and a stop() directive and it loads the movie fine, but it still doesn't solve the issue because I'm linking multiple flash files so that one scene leads to the next which leads to the next etc.  And each scene needs to wipe out everything that was there on the previous scene - by the time im going from the second to the third scene, the third is trying to overwrite the second scene again - I tried using a transition one with just the blank stage and a stop; but it didn't work, and I really don't want to have to create a unique transition .swf file each time - it just seems like there should be a less convoluted way to do this - it doesn't seem like it should be too fancy, is there no equivalent to a clear screen command or a way to unload the current stage before loading up whatever is in the next .swf file?

                  • 6. Re: Quick question from someone new to flash....
                    rmacatee Level 1

                    I found a way to do it but I want to check to see if there's anything wrong with it - basically I just have the button skip ahead to a frame where I deleted everything that was on the stage, and then on that frame I load the .swf file...

                    cuts out the separate transition .swf middleman....

                    • 7. Re: Quick question from someone new to flash....
                      robdillon Most Valuable Participant

                      Yes, that is one way to load in new content and display it. Without seeing your movie's content it's difficult to know what the best method might be. The way that you display your content relates to the design of that content. You need to consider what parts are constant, if any, what parts change, how the user interacts with the individual elements, the randomness of the interaction, the pacing, etc.

                       

                      Say, for instance, that you have three sections to your movie and you want to move from one section to another when the user clicks on a button. Further, you want to show a transition between each of these sections.

                       

                      You can create each section as a different flash movie. Likewise you can create the transition as another unique flash movie. Finally, you can create a container movie that does nothing except to load in these content movies.

                       

                      Let's call these movies "container", "content1", "content2", "content3" and "transition". Have the movie container, load in each of these movies with transition as the last to be loaded. So now you have four .swf movies stacked on top of your container movie. Content1 can play when it loads. When the user calls for the movie content2, you can play the movie transition and when it finishes, play the movie content2. When the transition movie begins, you can remove the movie content1. If you no longer need the movie content1, then you can use removeChild() to get rid of it. If you think that you will need it again, then just rewind it back to frame 1.

                      • 8. Re: Quick question from someone new to flash....
                        rmacatee Level 1

                        Hey Rob,

                         

                          I'm pretty confused.  My application generally proceeds in a linear fashion, and content is not reused so I really just need to wipe out the stage each time and load in a new .swf file.  There is one part where I used a sharedObject to store what the user has already clicked on so I can adjust which options are later presented.  I've been using the gotoAndStop() method of loading new movies, but things are getting all mixed up and I don't really understand what's going on.  Sometimes things don't load, sometimes they load multiple times and loop, and other times I get a compile error - for instance, when the user clicks on a button, I have the actionscript direct it to a certain frame and load a new movie - but then when that movie loads, it crashes at frame 466 and when I look at it in the debugger, its because its still traversing the timeline of the parent caller and referring to a button that doesn't exist on the movie I've loaded -- I'm confused as to how to do something that I thought would be pretty straightforward - all I want is that each time the new movie loads for flash to use that timeline and that timeline only -- I'm not sure why it's going through the timeline of the calling movie - I have a stop command so I thought it would just go straight to the new movie's first frame and go from there....I've been trying to read help documentation on how the loading stuff works but it's confusing and I'm unable to find examples of the sort of simple thing I need to be do...

                         

                        -Ricky

                        • 9. Re: Quick question from someone new to flash....
                          robdillon Most Valuable Participant

                          It sounds like you may have a couple of problems. The first is that you are addressing the wrong movie and the second is that you may be addressing a movie before its ready to be used. There may be other problems. Can you send me a copy of the movies so that I can see what's going on?

                          • 10. Re: Quick question from someone new to flash....
                            rmacatee Level 1

                            Thanks for all the help Rob.  Below are links to download the movies.  Here's a brief explanation of what I'm trying to do.

                             

                            DTM1-Start.swf is the starter file, and at the end is a continue button that should load DTM1-Intr1.swf.   DTM1-Intr1.swf does load successfully, but it loops instead of following the stop() command at the end to allow the user to click on one of the three emotion buttons.  If, however, I run DTM1-Intr1.swf alone, it does not loop and the stop() command is executed as it should be -- this is a common theme throughout, i.e., the files work as they should when I run them directly, it's the loading and linking between .swf files that is problematic.  Anyway, if I run DTM1-Intr1.swf directly, I am able to click on one of three buttons.  No matter what button I choose (anger- DTM1-Ang1.swf, anxiety - DTM1-Anx1.swf, or sadness - DTM1-Sad1.swf), the movie only gets a bit through the first block of text before crashing with a null reference error (I alluded to this problem in my above post).  Again, if I run any of the emotion movies directly, there is no crash.  When running the emotion movies directly, the continue button is supposed to lead the user to DTM1-EmotTrans.swf.  It does do this, but the movie loops repeatedly instead of following the stop() and goto commands that are supposed to display the buttons the user has not yet clicked (i.e., if they first clicked the sad button, only the anxiety and anger buttons remain on the screen in DTM1-EmotTrans.swf) --- again, if I open DTM1-EmotTrans.swf directly, it displays the correct buttons.  Finally, when clicking on one of the emotion buttons from the DTM1-EmotTrans movie, where it should be taking me back to the emotion movies, it instead crashes with a null reference error.  So basically none of my linking is working and I'm not sure what I'm doing wrong :/   .....  Anyway, below are the .swf files -- I really appreciate your help, I'm pretty desperate.

                             

                            DTM1-Start.swf - https://www.box.com/s/b98ccb465300b9ebfba5

                            DTM1-Intr1.swf - https://www.box.com/s/0b97389f002110cd3c14

                            DTM1-Sad1.swf - https://www.box.com/s/0da112b4a27128ba6b90

                            DTM1-Anx1.swf - https://www.box.com/s/0eb0f4f3b373cbe8d631

                            DTM1-Ang1.swf - https://www.box.com/s/a9bae191dbdfe5c00c0e

                            DTM1-EmotTrans.swf - https://www.box.com/s/fbd5810d0ee8eafdbf54

                             

                            With gratitude,

                             

                            Ricky 

                            • 11. Re: Quick question from someone new to flash....
                              rmacatee Level 1

                              Also, I'm not sure if you need the project files as well to figure out what might be going on - I didn't post them since they're significantly bigger, but if you need them I'll put them up.

                               

                              -Ricky

                              • 12. Re: Quick question from someone new to flash....
                                robdillon Most Valuable Participant

                                Yes, the .fla files will be the useful things for me to look at.  Send me a private message through this forum and I'll send you an address to my file uploader. That way I'll get the files directly.