5 Replies Latest reply on May 13, 2009 5:30 AM by ckisthebest

    Canvas API

    ckisthebest Level 1

      I want to expose my Cavnas API so any technolgy like .Net and java can access it.

       

      How can I do it?

       

      Thanks,

      -CK

        • 1. Re: Canvas API
          Michael Borbor Level 4

          When you say your canvas API, do you mean you create a custom Canvas? It

          really depends, you could create your own API like the guys at Ribbit have

          done with their product. I don't really understand what you mean, give us a

          clearer picture and will be able to help you.

          • 2. Re: Canvas API
            ckisthebest Level 1

            I want to make a custom drawable canvas. I want to add images, text and various shapes on it.

             

            I want my action controls in another technology. Like if i want to add text then my button for adding text will be in .Net.

             

            When I click a button on .Net it should add text in my flex canvas.

            • 3. Re: Canvas API
              Barna Biro Level 3

              Hi there,

               

              I'm not sure but I think you could try playing around with FlashVars. You can pass any data to the application in form of pairs. Normally, you'd update the variables with Javascript, but I'm quite sure that you can do the same thing with almost any other language too.

               

              If that's not what you want then the problem can get quite tricky. Maybe try playing around with the ExternalInterface.

               

              With best regards,

              Barna Biro

              Blog: http://blog.wisebisoft.com

              • 4. Re: Canvas API
                Richard_Abbott Level 3

                Hi ckisthebest,

                this is an interesting mix of technologies. You will probably need to look into the documentation for ExternalInterface. This allows Flex apps to talk to the pages in which they are embedded, for example to access DOM elements. The most obvious vehicle (to me, at least) for doing what you want is:

                 

                1) The .NET button does whatever in the code-behind file, eg talking to a database, and then writes the relevant bits into a DOM element which you keep hidden.

                2) A JavaScript function accesses the contents of said element and provides a return argument of (say) a string

                3) A Flex method uses ExternalInterface to call said function and inspects the contents to do the necessary inside the Flex app.

                 

                I have used this in a few cases to respond to actions in the ASP-managed parts of the page.

                 

                There are a couple of problems with the scenario, namely

                1) The .NET part when managed this way normally triggers a page refresh, which can be visually disturbing and also means you wil have to track your previous actions/state carefully enough to reproduce where you were

                2) You are vulnerable to variations in how JavaScript works between browsers, and in principle to someone turning JS off.

                 

                Are you committed to using a button in the containing page? If you went for controls inside the Flex app itself then you can invoke server-side functionality without the need for page refresh (using HTTPService, URLRequest etc) and I suspect the user experience would be better.

                 

                Hope that helps,

                Richard

                • 5. Re: Canvas API
                  ckisthebest Level 1

                  Hi Richard,

                   

                  You are right man.

                   

                  Thanks