5 Replies Latest reply on Aug 14, 2006 7:35 PM by kglad

    Dynamic drawing problem

    jblack Level 1
      I'm creating a little app that maps out the vectors of hurricanes based on data in an XML file.
      So far I've been successful with getting the app to dynamically create a movie clip for each storm and draw a vector for each storm clip.
      Going a step further, I'm trying to make it so when a user clicks on one of the displayed storms, the storm is redrawn segment by segment with data for each segment attached to the segment (data like wind speed, pressure, long., lat., time, etc.) I figured I would handle this by creating a new movie clip for each segment and store an array for each segment within each clip.
      I've set up some code that creates the movie clip, attaches the array, sets the start point of each segment, looks ahead one data set to get the end point for the section, and draws the line based on that.
      However, when I run the app, what I get is a line that stretches diagonally across the screen, seeming to not adhere to any of the coordinates.
      Take a look. Thanks.
        • 1. Re: Dynamic drawing problem
          kglad Adobe Community Professional & MVP
          what's calcX(), calcY(), windXize() and windColor()? are they expecting numbers for parameters or are they able to handle the strings you are passing? (that's a hint.)

          actually, you should be getting a compiler error showing a type mismatch. are you?
          • 2. Re: Dynamic drawing problem
            jblack Level 1
            Gotcha. I tested the typeof each variable and, sure enough, they were all strings. I didn't realize Flash saw all values from an XML file as strings.
            I defined the variables as numbers using Number() and rechecked type. Good to go.
            However, I'm still having the same problem with drawing the line using individual clips for each segment. Results are still the same.
            Thx
            -Joe
            • 3. Re: Dynamic drawing problem
              kglad Adobe Community Professional & MVP
              your setup is designed to use distinct movieclips for each segement. is that something you do not want?

              show the results of a few

              trace(calcX(long)+" "+calcY(lat)); // and
              trace(calcX(nextLong)+" "+calcY(nextLat));

              statements after their arguments are defined.
              • 4. Re: Dynamic drawing problem
                jblack Level 1
                Here's the output of those trace calls.

                segment0
                TROPICAL DEPRESSION EIGHTEEN
                22/-69.7 startpt
                21.7/-71.2 endpt
                segment1
                TROPICAL DEPRESSION EIGHTEEN
                21.7/-71.2 startpt
                22/-72.2 endpt
                segment2
                TROPICAL DEPRESSION EIGHTEEN
                22/-72.2 startpt
                22.2/-72.7 endpt
                segment3
                TROPICAL STORM RITA
                22.2/-72.7 startpt
                22.9/-73.3 endpt
                segment4
                TROPICAL STORM RITA
                22.9/-73.3 startpt
                22.7/-74.3 endpt
                segment5
                TROPICAL STORM RITA
                22.7/-74.3 startpt
                23/-75.2 endpt
                segment6
                TROPICAL STORM RITA
                23/-75.2 startpt
                23.3/-76.5 endpt
                segment7
                TROPICAL STORM RITA
                23.3/-76.5 startpt
                23.3/-77.8 endpt
                segment8
                TROPICAL STORM RITA
                23.3/-77.8 startpt
                23.7/-79.5 endpt
                segment9
                TROPICAL STORM RITA
                23.7/-79.5 startpt
                23.8/-81 endpt
                segment10
                HURRICANE RITA
                23.8/-81 startpt
                23.9/-81.7 endpt
                segment11
                HURRICANE RITA
                23.9/-81.7 startpt
                24/-82.2 endpt
                segment12
                HURRICANE RITA
                24/-82.2 startpt
                24.1/-83.2 endpt
                segment13
                HURRICANE RITA
                24.1/-83.2 startpt
                24.3/-84.6 endpt
                segment14
                HURRICANE RITA
                24.3/-84.6 startpt
                24.3/-85.9 endpt
                segment15
                HURRICANE RITA
                24.3/-85.9 startpt
                24.4/-86.8 endpt
                segment16
                HURRICANE RITA
                24.4/-86.8 startpt
                24.6/-87.2 endpt
                segment17
                HURRICANE RITA
                24.6/-87.2 startpt
                24.9/-88 endpt
                segment18
                HURRICANE RITA
                24.9/-88 startpt
                25.4/-88.7 endpt
                segment19
                HURRICANE RITA
                25.4/-88.7 startpt
                25.8/-89.5 endpt
                segment20
                HURRICANE RITA
                25.8/-89.5 startpt
                26.2/-90.3 endpt
                segment21
                HURRICANE RITA
                26.2/-90.3 startpt
                26.8/-91 endpt
                segment22
                HURRICANE RITA
                26.8/-91 startpt
                27.4/-91.9 endpt
                segment23
                HURRICANE RITA
                27.4/-91.9 startpt
                28.2/-92.6 endpt
                segment24
                HURRICANE RITA
                28.2/-92.6 startpt
                29.1/-93.2 endpt
                segment25
                HURRICANE RITA
                29.1/-93.2 startpt
                29.9/-93.9 endpt
                segment26
                HURRICANE RITA
                29.9/-93.9 startpt
                31/-94.3 endpt
                segment27
                HURRICANE RITA
                31/-94.3 startpt
                32.1/-94 endpt
                segment28
                TROPICAL STORM RITA
                32.1/-94 startpt
                33/-93.9 endpt
                segment29
                TROPICAL DEPRESSION RITA
                33/-93.9 startpt
                NaN/NaN endpt
                • 5. Re: Dynamic drawing problem
                  kglad Adobe Community Professional & MVP
                  so, the graph you would expect to see is a zig-zag mess between x=21.7 and x=23 (but that's just over 1 pixel wide so you're probably not going to notice anything unless you scale that up).

                  between x=23 and x=33 you expect to see y decreasing from -75.2 to -94.3 (and remember, this is just 10 pixels wide and less then 20 pixels high, so this will be noticable if you look carefully (assumming y<0 is visible).

                  and between x=33 and x=0 you expect to see y increase from -93.9 to 0 (because flash is going to use zero when it receives NaN data. and this is probably the only part of the graph that you're noticing.

                  so, you're going to see a mess because either the data are a mess or you're not presenting the data in an informative manner.

                  you might try increasing the scale of your display (by a factor of between 10 to 100, so it's more like 500 pixels wide) and don't apply the drawing api to undefined data.