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.
Any ideas? Am I missing a mx.swc or something?
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
Make sure that your project can use both MX and Spark components in Properties -> Flex Build Path
Move caret to the end of <mx:Canvas and press Ctrl + Space. IDE should suggest correct namespace.
Related
I am trying to implement drag & drop of files from the file system into Flex, but somehow it doesn't work.
To be precise, it refuses to register when the nativeDragEnter event happens, meaning, it doesn't do anything when i drag a file system file into a component. I tried it with mx and spark components, using flex 3.6A and 4.10 but nothing works.
I am working on Windows 8.1. Could this be the problem?
Below is what i did, did i miss something?
<mx:Script>
<![CDATA[
protected function hbox1_nativeDragEnterHandler(event:NativeDragEvent):void
{
var a:String = "segdfsh";
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%" nativeDragEnter="hbox1_nativeDragEnterHandler(event)">
</mx:HBox>
The code in the question seems to work after all, but for some reason it didn't work if i debug it from Flashbuilder, but when i release my project, then it works like a charm, so yeah, no issue here, i guess.
I've just noticed in my AIR application that redo is not working. It also seems that there it only is going back one step (but sometimes two or three).
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextArea horizontalCenter="0" verticalCenter="0" />
</s:WindowedApplication>
I'm using CMD + Z for undo and CMD + Z + Shift for redo. I'm sure this was working at one point. Maybe it was only in the browser?
I'm using Flex 4.6 and AIR 3.6. I'm using Mac 10.10.5. I'm using Firefox 40.3. I also tried it in Safari.
Undo and redo work correctly in the text fields in both of those browsers using the same shortcut combinations listed.
according to docs it should work:
The Spark TextArea also supports unlimited undo/redo within one
editing session. An editing session starts when the control gets
keyboard focus and ends when the control loses focus.
but i noticed during development of my app that
when we use backspace it counts it as separate states
in other cases it see all changes as one
Would anyone be able to point out some good tutorials on creating applications in flex that are don't have UI's?
Actually, it looks like all I really need to know is how to call a function upon initialization of the flash object. I tried the creationComplete attribute, but it doesn't work in browser.
Well, I'm not sure what made it work finally, but I ended up copying and pasting this code from some website (sorry, i don't remember the site):
<?xml version="1.0" encoding="utf-8"?>
<!-- wrapper/CheckExternalInterface.mxml -->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="initApp()">
</s:Application>
And that ended up working! thanks anyway.
If you're intent is to connect JavaScript to a Java Server, why not use XMLHTTPRequest? IT is the basis of every AJAX style RIA application. The data format you pass back and forth can either be JSON or XML. It doesn't have to be binary.
Second, you don't need Flex for this. The Sockets APIs in ActionScript and are part of the Flash Player. You can use them without any dependencies to the Flex Framework.
Trying to create a banner ad as a one-off project for a client. I am using Flash Builder / AS 3 and with my simple hello world example. Google Adwords rejects the add with: Encountered flash error - ad cannot use mouse tracking.
I Have not been able to figure out what I am doing that signals to Adwords that I am mouse tracking. Follows is my simple mxml file: (the handleClick is to adhear to their clickTAG specification)
Thanks!!!
<?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"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="336" minHeight="280" width="336" height="280" includeInLayout="true" click="handleClick(event)">
<fx:Script>
<![CDATA[
public function handleClick(mouseEvent:MouseEvent):void {
navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTAG),"_blank");
}
]]>
</fx:Script>
</s:Application>
It is quite possible that whatever automated analysis that Google does on the ads submitted is being confused by the Flex framework. You could try creating an ActionScript project instead of Flex project in Flash builder and see if that makes any difference.
If you use an ActionScript project you won't be able to use MXML for creating the ad, but you might not really even want to drag in the Flex framework, since it takes a while to load (the first time at least).
I'm a complete newbie to Flex, so apologies for my dumbness. I've searched for an answer but haven't found anything that seems to be doing the trick.
What I'm trying to do: port this example http://www.adobe.com/devnet/air/flex/articles/flex_air_codebase_print.html
to Flash Builder 4.
All seems to be fine but for one thing. When I use the original code for the Air application
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="onApplicationComplete()">
<fx:Script>
<![CDATA[
private static const neededForCompilation:AirGeneralImplementation = null;
private function onApplicationComplete():void
{
var can:MainCanvas = new MainCanvas();
this.addChild(can);
can.labelMessage = "Loaded in an AIR Application ";
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:WindowedApplication>
I get this run time error
Error: addChild() is not available in
this class. Instead, use addElement()
or modify the skin, if you have one.
at
spark.components.supportClasses::SkinnableComponent/addChild()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:1038]
If I substitute the code with
this.addElement(can);
Everything loads well but the first time I try to press any of the buttons on the main canvas I get the following run time error
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.managers::SystemManager/getChildIndex()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:1665]
at mx.managers.systemClasses::ActiveWindowManager/mouseDownHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\systemClasses\ActiveWindowManager.as:437]
here's the super simple code for the main canvas
<?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"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="init();">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script source="main.as" />
<mx:Label id="lblMessage" text="The UI from the shared Flex app BothCode" x="433" y="112"/>
<s:Button x="433" y="141" click="saveFile();" label="Save File"/>
<s:Button x="601" y="141" click="GeneralFactory.getGeneralInstance().airOnlyFunctionality();" label="Air Only"/>
</s:Application>
Any help would be immensely appreciated. And any pointers to how to setup a project that can compile in both Air and Flash while sharing the same code, all for Flex 4, would also be immensely appreciated.
thank you!
I ran into the same problem using that tutorial for Flex 4. I did the same thing as you and used the <s:Application> component for the Main Canvas. However the tutorial uses a <mx:VBox>, the solution I found was to change the Main Canvas from an <s:Application> to an <s:Group>. The problem seems to be embedding an Application within an Application.
The code on that link was written using the flex 3.5 sdk or below. You are using the new flex 4 sdk ( which is the default for Flash Builder ).
You can do the following:
1. step into the code do any necessary changes to make it work for flex 4 sdk.
2. setup a new project using the flex 3 sdk ( select "Use a specific SDK" and choose the Flex 3 from the dropdown box in the "New Project" window)
I would suggest going for the second option, make it work and once you've stepped a little deeper into flex 4 you can do the 1st option.
Cheers.