4 Replies Latest reply on Jul 24, 2008 9:50 PM by anirudhs

    draw lines and other graphics

    georges.goebel
      Hi,

      We need do draw some lines (in fact it is the highway road system in luxemburg) and other graphic components and dynamically change the colors of these lines based on some values which are generated in the backend. You can check it out at : http://www.cita.lu

      At the moment we have a simple flash application which does all the color changing baed on the values an we want to change this application in a flex application which gets the processed data through Java interaces. The problem of this application is that most of the business logic is in the flash application which we want to move to the Java application.

      Our first problem is how do we draw the lines in flex ? We found some ideas but they are all based on programatical drawing. So you write actionscript to draw these lines. This is quite hard and also not very usefull as the location of the lines do not change. Only their color ! So we want to draw the lines as in Flash, which works fine and in some seconds.
      Next idea we had war to draw the lines in flash and load this application in flex with the "swloader" component. We can load the flash application but we cannot access the draw lines. In fact they are drawn in flash and then converted to "graphics" (not movieclips nor commands). They have a name in flash but when we try to get a reference in flex to these elements we always get a null reference.

      Does somebody know a best practise or a solution of this problem ?

      Thanks

      Georges
        • 1. Re: draw lines and other graphics
          anirudhs Level 2
          Hi,

          Declarative drawing is coming up in Flex 4. This is currently possible in Flex 3 using the Degrafa library: http://degrafa.com/

          By the way, if you programatically draw the lines using actionscript, you can move the lines simply by moving the Shape / Sprite object by changing it's x or y property.
          • 2. Re: draw lines and other graphics
            georges.goebel Level 1
            Hi,

            Thanks for your reply.

            The degrafa is an interesting library but all the lines are drawn in a matematically way. You have to specify the coordiantes where you want to dra the lines. The library hides to the user the nasty code of the drawing and filling which is described in the doc of flex (programatical drawing) as I understand. As I understood it is comparable to a taglib in java which hides alle the nasty jsp scriptlet and html code to the user (like <h:outputTest value="Hello"/> for jsf components)

            What we are looking for is the possibility to draw freehand lines. Like drawing with the brush tool in flash on the background. And in flex we want to have the possiblilty to change graphics of a flash component. Or, better would be to leave out the flash component (not using the sfloader component) and draw immediately in flex. For example take the panel or canvas component and draw freehand lines on that component. And each line could be accessed by their ID.

            Georges Goebel
            • 3. Re: draw lines and other graphics
              levancho Level 3
              quote:

              Originally posted by: georges.goebel

              What we are looking for is the possibility to draw freehand lines. Like drawing with the brush tool in flash on the background. And in flex we want to have the possiblilty to change graphics of a flash component. Or, better would be to leave out the flash component (not using the sfloader component) and draw immediately in flex. For example take the panel or canvas component and draw freehand lines on that component. And each line could be accessed by their ID.

              Georges Goebel


              you can do that by developing component in flash and then importing in flex, flex can still access objects from within loaded swf file an also listne to its event as well.