18 Replies Latest reply on Feb 5, 2010 5:31 AM by Ned Murphy

    Why do Scenes hate me?

    GhengisJones Level 1



      I'm creating a clock in CS4 using AS2.


      Each hour is its own scene with animated minute and hour hands. At the end of the hour, the next Scene begins and counts off the next hour.


      (FWIW, the clock is designed to run six times faster than a real clock.)


      At each number of the clock there is an invisible button that will jump the clock to that hour. For instance, the clock stats at noon. If you click on the 3, the clock will jump to 3 o'clock and continue running.


      Here is the problem: from noon 'til 7, the clock runs fine, seguing from one hour's scene to the next. The buttons also work fine.


      However, for 8 through 11, Flash behaves as if those scenes arent' even there. When the 7 o'clock hour finishes, the scene does not transition to the 8 hour. And the buttons for 8 -11 send the timeline anywhere but.


      See what I mean here:




      Here is the really weird thing: If I delete any of the scenes from 1- 7, the problem persists BUT if I delete all scenes from 1-7, then 8-11 work fine!


      What is going on?


      Now I'm starting to understand that Scenes can be problematic, but if so, why have they not been either a) fixed or b) removed from Flash altogether?


      CS4 is v10, after all -- the thing should work by now.


      Mostly, I want to know WHY this is happening.


      I'm thinking I might have to create a swf that loads a 1-7 swf and a 8-11 swf to make this work!


      Thoughts, please!

        • 1. Re: Why do Scenes hate me?
          GhengisJones Level 1

          I should add that each scene is identical save for the starting position on the hour hand and the instance names of the various elements.

          • 2. Re: Why do Scenes hate me?
            Ned Murphy Adobe Community Professional & MVP

            Scenes have always been unreliable things to try to navigate, so the answer to why may not be possible to determine.  You are better off just avoiding scenes and deisgning in one scene using labels.  In any case, if there is any chance it might be the controls you have in place, then you'll need to explain them and show the code.


            Have you considered doing this using code instead of timeline animation (I am assuming it is timeline based)?

            • 3. Re: Why do Scenes hate me?
              GhengisJones Level 1

              Thanks Ned.


              I started out using just one timeline but quickly exceeded the 16000 frame limit so I used Scenes instead.


              The biggest frustration I have with Flash is that you can go miles down a certain route and find it is a dead end. Why have the Scenes feature at all if it has always been buggy and unreliable?


              Yes, I've been using the timeline.


              Apart from navigation, the 7 oclock scene (Scene 8) doesn't even segue into the 8 o'clock scene (Scene 9). Flash behaves as if the last four scenes don't even exist.


              How do I display all the code? It's so easy in Dreamweaver but Flash not so much.



              • 4. Re: Why do Scenes hate me?
                Ned Murphy Adobe Community Professional & MVP

                Scenes get buggy when you introduce navigation schemes.  Animators generally use them without a problem due to lack of navigation.  That's one reason for them surviving.  Another reason is so that the software is backward compatible.


                You really oughtya consider the coded approach... one frame is all you need.

                • 5. Re: Why do Scenes hate me?
                  GhengisJones Level 1

                  Even without naviagtion the problem persists.


                  What exactly do you mean by "coded approach?"


                  I don't see any place in Flash to go into a Code-only mode.



                  • 6. Re: Why do Scenes hate me?
                    Harry Kunz Level 4

                    Press F9 (Window -> Action) to bring out the Actions Panel. That is where you start your coded approach. You can choose Script Assist if you are new to it.

                    • 7. Re: Why do Scenes hate me?
                      GhengisJones Level 1

                      Well, I've been using the Actions Panel all along to add a script.


                      If that's what the Code Approach means, it's not doing any good.


                      It's not like it displays code for the entire file at once; just whatever element is selected -- unlike say Dreamweaver where you can work in nothing but code.

                      • 8. Re: Why do Scenes hate me?
                        Ned Murphy Adobe Community Professional & MVP

                        Instead of involving thousands of frames to animate something rotating, you just use code to change the _rotation property of the objects.  I created a simplified example to show you how code can be used to control the rotation of an object like a clock hand...



                        1 person found this helpful
                        • 9. Re: Why do Scenes hate me?
                          GhengisJones Level 1

                          Thanks for making the effort, Ned.


                          I'll check it out.

                          • 10. Re: Why do Scenes hate me?
                            GhengisJones Level 1



                            With your speed increments such as .1, .2 and so forth -- what speed do they represent in terms of time?


                            In other words, at your default speed of .1, how long does it take the hand to make a complete rotation?


                            Is it contingent on some other setting?


                            I need to know because I need to make the hands move at precise speeds.



                            • 11. Re: Why do Scenes hate me?
                              Ned Murphy Adobe Community Professional & MVP

                              The code uses an enterframe scheme to keep things turning, so the design is based on the frame rate of the file....  The rotation value (.1, .2, etc) is a value in degrees.  Each frame the rotation value changes that much.


                              So your variables include a speed in units of frames/second, and an allotment of degrees/frame... You can set these value, so I'll leave it to you to work out your numbers (adding that there are 360 degrees in a round trip)

                              1 person found this helpful
                              • 12. Re: Why do Scenes hate me?
                                GhengisJones Level 1



                                Two more questions:


                                1) I assume I can pause and restart the clock using hidden buttons similar to the speed change buttons in your example. For instance, the pause button will set the speed of both hands to zero and the restart button will set the hands back to their orginal speeds.


                                This should work, no?


                                2) What code do I need to make the clock "jump" to a particular hour? For instance, in my original attempt, clicking on the III on the clock face sets the clock to 3 o'clock and it continues running.


                                Is it even possible to do this with this code/rotation approach?



                                • 13. Re: Why do Scenes hate me?
                                  GhengisJones Level 1

                                  Well, I accidentally answered my second question with this code:


                                  TwoOClock.onRelease = function(){
                                  MinuteHand._rotation = Number(0);
                                  HourHand._rotation = Number(60);



                                  Now to figure out the Pause and Restart Buttons

                                  • 14. Re: Why do Scenes hate me?
                                    Ned Murphy Adobe Community Professional & MVP

                                    It's all possible, but I'll leave it to you to try to work things out... you should have all the pieces you need.  It's not difficult, so if you think something seems it would be too easy, try it.  And don't get sidetracked with my example and the use of the textfield (that complicates matters due to having to work in String conversions).... your primary interests concern controlling the _rotation value, and the rate at which it changes.

                                    • 15. Re: Why do Scenes hate me?
                                      Rothrock Level 5

                                      I totally agree with Ned. If you are going to use Actionscript, don't use scenes!


                                      BTW, the 16,000 frame limit is on total frames in a swf. When you publish, scenes are actually strung together into one timeline and then dropped. So you end up with one long timeline anyways!


                                      Next, if you are using code and accurate timing is actually important––as compared to say, almost accurate. Then you should use getTimer() each time your rotating function happens to figure out how long it has been since the last time ran. Frame rates (onEnterFrame) and intervals (setInterval) are not completely accurate, but getTimer is.

                                      • 16. Re: Why do Scenes hate me?
                                        GhengisJones Level 1

                                        Well I did use the text field and it works:


                                        this.onEnterFrame = function(){
                                        MinuteHand._rotation += Number(speedminute.text);
                                        HourHand._rotation += Number(speedhour.text);

                                        PauseClock.onRelease = function(){
                                        speedminute.text = String(Number(speedminute.text)*0);
                                        speedhour.text = String(Number(speedhour.text)*0);

                                        StartClock.onRelease = function(){
                                        speedminute.text = String(Number((speedminute.text)*0)+0.04);
                                        speedhour.text = String(Number((speedhour.text)*0)+0.00333);



                                        So I'm a happy camper.


                                        Maybe not the most elegant way to do it, but it works.


                                        Thanks so much for all your help!

                                        • 17. Re: Why do Scenes hate me?
                                          GhengisJones Level 1

                                          D-oh ... getTimer!



                                          As for the 1600 frame limit and the continous timeline, I was aware of those but my previous attempt worked with 8 scenes of 9000 frames each!


                                          And I didn't get the warning message from Flash when publishing the SWF.


                                          Since it behaved as if the last 4 scenes weren't even there, though, that may have been the problem -- those scenes got cut off -- but still 8 scenes at 9000 fr each is still way over 16000!

                                          • 18. Re: Why do Scenes hate me?
                                            Ned Murphy Adobe Community Professional & MVP

                                            You're welcome.  If you want the speed to be user adjustable, then using the textfields is fine, but if not, you can avoid all of the string conversions to numbers and whatnot and just use numeric values behind the scenes.