3 Replies Latest reply on Oct 10, 2006 2:24 AM by DazFaz

    Changing URL during movie

      I have a movie consisting of text that shape tweens into som new text (text are of course breaken apart into symbols).
      When new text are readable (after tweening), it stands still for 4 seconds. During the 4 seconds, I want to be able to click on it to get to a spesific URL. I have made an invisible button, but how do I write code to change the URL depending on the text that is visible (depending on where I am on the main timeline)?
        • 1. Re: Changing URL during movie
          DazFaz Level 1
          getMyURL = function(page:String,location:String){

          //this needs to be placed on the main time line
          //the call reference will be:
          • 2. Re: Changing URL during movie
            fn Level 1
            Thank you for your answer. Here is what I did: I made an invisible button. Each time a new text appeared on the timeline, i dragged an instance of this button onto the stage. On the button I made the actionscript code you prescribed (in an on(release) event). It worked, but some additional answers:
            a) in the on(release), I can as well call getURL() directely, why should I need to go thru getMyURL() ?
            b) All "modern" text about actionscript tell meI not to place code inside symbols, but rather on a layer e.g. called "actions". How do I get the wanted effect with code inly in an "actions" layer?

            • 3. Re: Changing URL during movie
              DazFaz Level 1


              In a perfect world you would never put any code within any symbol, movieClip, button or otherwise.

              All functions would be in one place, managed well and efficiently coded.

              In your case you are writing the code straight onto the button. What you should be doing is applying the code to all your buttons from one place. E.g.

              myButtonName.onRelease = function(){
              //do what ever it is that you do Mr Button

              This would be put on the same layer as all the other scripts you have written.

              It sounds as though you are using the time line for lots of tweens and things. Something that I prefer not to do as all my actions are performed on one frame. Personal choice here I think but never the less you need to be thinking about keeping all your code in an easily accessible place.

              Once you have been able to get your head around working this way then you can take your coding one step further. External .as files. “Christ” I hear you say, “what kind of mad man would think about doing that”. Well, this fruity loop, highly recommends it. Again, once you become more confident with your coding and more importantly, your lateral thinking process, you will be able to create simple shell .swf’s with all the hoots, whistles and bangs being managed outside.

              Managing scripts is one of the more skilful attributes that any flash programmer can have. Having all your coding on one particular layer will help you easily edit and update any changes that you make at a later date. On top of this, the debugging is a lot easier too. I’m surprised that you say:

              “b) All "modern" text about actionscript tell meI not to place code inside symbols, but rather on a layer e.g. called "actions".”

              As through experience, unless you have created a very good working schematic and you have commented out every single line of code (which obviously every programmer does :D), then in a fey days time, once you come back to this project, and if you don’t have a very good memory (which I don’t) then you will waste time reverse engineering your code trying to find an embedded function that is hidden behind a small button that was included at runtime by some clever d**k who thinks they are being clever, which uses an external include file. Slightly over the top there but it happens, especially when you are working on projects that have multiple developers, lol.

              Do yourself a favour and try to keep all your code in once place. Hard at first but in the long run you will really reap the benefits. Especially once you move into Class structuring and so on.
              Well this is only my opinion and at the end of the day you have to go with what you feel comfortable with.