5 Replies Latest reply on Feb 9, 2007 2:52 AM by Peter Lorent

    How do i define different load locations

    breez11 Level 1
      I have a file which loads a combination of jpg's and swfs and they get there loaction from a loactionArray. once loaded they trigger the doEase function which slide them to a new location. The problem is when they slide into place they all slide to the same location since the location is defined in the doEase function. How can I specify different locations for the different loaded mc's?
        • 1. Re: How do i define different load locations
          Peter Lorent Level 2
          The way I see it you need to use two arrays: one that holds the original locations for the clips and one that holds the new positions. I've added a targetsArray in the code. Now, if you provide the same values for a clip in that array -> no animation. Provide the new location -> animation.
          I've added a third element to the array that calls doEase() using setInterval() so you can time when clips are going to move. The setInterval passes the iterator (n) to doEase() so you can get the new location there from the targetsArray.

          • 2. Re: How do i define different load locations
            breez11 Level 1
            Once agian thanks. I really apreciate all your help. I like how you added the setInterval value to the array. It makes this very efficient and easy to update.
            • 4. Re: How do i define different load locations
              breez11 Level 1
              I have loaded some xml and attached it to a couple of the widgets and the mainLogo. When the xml loads it calls a function names myFunction which assigns a var name for each node which is link1-link4. The xml is loading and when I mouse over the mc's I get the hand cursor so I know the onPress function is triggered correctly. Either the var names are not being assigned or the getURL statement is not working. What is going on?
              • 5. Re: How do i define different load locations
                Peter Lorent Level 2
                What is happening is that you are probably not parsing the xml correctly (can't see that because the xml is missing in the posted code) but more importantly, you cannot assign an onRelease event handler before the jpg or swf is fully loaded. The loadmovie() will kill the event handler. So, when writing a program you have to make sure things are executed in the right order to get the behaviour of the program as you expected. Now, let's rewrite the code somewhat to get that behaviour.
                We need some external data - jpg, swf and xml - to get the show on the road and we know we have to first load that data. In this program we want to first load the xml (because we need the url) and then we want to load the jpg and swfs.
                The code we have already uses arrays to save some data and the code uses an iterator to get the stuff we need from the arrays. To be able to do that we keep the data 'in sync'. The first element of the first array corresponds to the first element of another array. So we can do the same with the data coming from the xml. If we don't want to use an url for one of our movieclips, we simply use an empty value. That way we can use the same iterator throughout the code. To control the execution of the code we are going to use functions for every task.
                You didn't show the xml so I've gone ahead and used the following xml:

                <link url="" />
                <link url="" />
                <link url=" http://www.adobe.com" />
                <link url=" http://www.nike.com" />
                <link url=" http://labs.adobe.com" />
                <link url=" http://kuler.adobe.com" />

                No url for the first two elements and you can change that to your needs.
                In the program, the first step is to load the xml. We are going to use an array linksArray to save that data. When the data is loaded and saved, we are going to load the jpg and swfs and when that is done we assign the onRelease event handlers. To be able to to that we are going to save references to the loaded clips in an array, again using the iterator to get the correct clip. So, attached the corrected code with additional comments.