Search code examples
apache-flexcanvasactionscriptairflex-spark

Drawable Canvas


I recently upgraded my Flash Builder from Burrito to 4.5 Premium. I am trying to create this (Drawing Demo) in the latest version of Flex, on Blackberry Playbook, but I am getting errors:

Code

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark">

<s:Panel layout="absolute" title="Draw Test" backgroundColor="#ffffff">
    <mx:Canvas backgroundColor="#ffffff">
    <mh:DrawableCanvas id="main" backgroundColor="#ffff80" backgroundAlpha="0" width="100%" height="100%" y="0" x="0">
    </mh:DrawableCanvas>
    </mx:Canvas>
</s:Panel>

</s:Application>

The Error

The prefix "mx" for element "mx:Canvas" is not bound. I have tried adding "xmlns:mx="http://www.adobe.com/2006/mxml" to the head with no joy.

Is canvas no longer supported? All I want is a canvas to draw onto to capture a human signature...

Any ideas?

EDIT:

Took onboard the advice but still getting something wrong, see screenshot.

enter image description here

Any ideas? Am I missing a mx.swc or something?


Solution

  • Canvas and all other components are still supported since Flex4 is backwards compatible with Flex3.

    In your case, the error message says it all.

    Your application does not correctly refer to the mx: namespace.
    Therefore, it will not be able to find the Canvas component.

    In a Spark application, it is advised to add the mx namespace as follows:

    xmlns:mx="library://ns.adobe.com/flex/mx" 
    
    instead of 
    
    xmlns:mx="http://www.adobe.com/2006/mxml"
    

    If your are migrating your Flex3 Halo application to a Flex4 Spark application, please read the official migration guide. Chapter 4 is particularly useful.

    Cheers