Well, I was able to simply enough (after about an hour of googling) implement i18n (internationalization) into my Flex application by having to reverse engineer the Flex SDK and do a lot of digging (a specific question on here helped me a lot! (with some updates for flex 4.5)).
The problem is, I can't use my {getLand('key')} bind inside an <fx:XMLList> (how you define the contents of a <mx:MenuBar>. I've included some example i18n below, as well as an example of the menu bar.
<!-- Example of proper (working) i18n -->
<s:TextArea text="{getLang('Rules')}"/>
<!-- Problem Area (a bare bones example) -->
<!-- Error message in IDE: Access of undefined property _application_XMLList1 -->
<mx:MenuBar labelField="#label">
<fx:XMLList>
<menuitem label="{getLang('File')}"/>
</fx:XMLList>
</mx:MenuBar>
Try putting the XMLList outside of the menubar, like so:
<fx:Declarations>
<fx:XMLList id="_menuStuff">
<menuitem label="{getLang('File')}"/>
</fx:XMLList>
</fx:Declarations>
<mx:MenuBar labelField="#label" dataProvider="{_menuStuff}"/>
That should work, good luck!
Related
I am new to adobe flash builder and I am making a mobile flex project.
In my project so far I have a simple two page layout with buttons to go forwards and back. It's a simple hello world just to test.
I wrote an action-script that uses the camera on the phone and want to attach it to a button call so the camera opens when pressed. I have looked all over the internet but cannot find a solution for this on android and would appreciate any links for any tutorials as-well.
My button call looks like this:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Camera">
<!-- The file I want to include -->
<fx:Script source="includes/Camera.as"/>
<!-- Declarations -->
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<!-- alignment for buttons -->
<s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">
<!-- Button that will take the user to camera -->
<s:Button label="Capture" click="button1_clickHandler(event)"/>
<!-- Button to navigate back to the main page -->
<s:Button label="Back" click="navigator.popView()" styleName="back" />
</s:VGroup>
</s:View>
This is my error:
1068: Unable to open included file: C:\Users\denis\Adobe Flash Builder
4.6\app3\src\views\includes\Camera.as.
Includes is a folder I created.
As I stated I could not find any tutorials and I am new to this so apologies for noob questions.
Where did you create the includes folder? My guess is that you created it in your app3 directory, and not as a subdirectory of src\views.
I thought this was the default behaviour (all the Adobe docs seem to indicate that this is the case).
Say you have a form:
Name: [______]
Password: [________]
generally you want Name and Password to line up on their right-hand side (right justification). The length should be the length of the longest label.
When I add the following code to my MXML (authoring in Flex 4) it does not do that at all! But rather tjust crams everything left-justified, similar to the Name/Password example above.
What's the solution?
<s:Form id="directoryForm_A" width="100%">
<s:layout>
<s:VerticalLayout horizontalAlign="justify"/>
</s:layout>
<s:FormItem label="Click">
<s:Button label="Button"/>
</s:FormItem>
<s:FormItem label="Root Directory">
<s:TextInput x="0" width="100%" enter="handleUserSetRootDirectory(event)"/>
</s:FormItem>
</s:Form>
Which Adobe docs were you reading? You realize that the Spark Form are going to be very different than the Halo / MX Form. I would also suspect that the Spark form is not working yet.
Here are the docs on the Spark Form.
I think you'll benefit from reading the layout rules section of the FormItemLayout details. I cannot find the documentation that claims that all labels will be right aligned.
For anyone looking to a beta solution, Peter deHaan posts about this exact topic here: http://blog.flexexamples.com/2010/08/28/setting-the-text-alignment-on-a-spark-formitem-label-in-flex-hero/
Do note, since his example doesn't translate directly over to my issue:
adding to the for some reason disables the ability for the renderer to calculate the maxLabelWidth
Hope this helps others in the future.
I'm trying to build a simple FLEX application. Unfortunately, I get '1131: Classes must not be nested.' errors even with the simples MXML .... the error pops out at the mx:Application openning tag:
(I'm using PureMVC if it's important)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:view="icm.view.components.*"
viewSourceURL="srcview/index.html"
name="ICM"
layout="absolute"
> //FLEX BUILDER SAYS THE ERROR IS HERE
<mx:Script>
<![CDATA[
import mx.effects.easing.Exponential;
import icm.ApplicationFacade;
public static const NAME:String = "AppSkeleton";
private var facade:ApplicationFacade = ApplicationFacade.getInstance(NAME);
]]>
</mx:Script>
<mx:Move id="slideInEffect" yFrom="5000" easingFunction="{Exponential.easeOut}" duration="1300"/>
<mx:Fade id="fadeOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>
<mx:Fade id="fadeIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>
<mx:Style source="css/yflexskin.css" />
<mx:Canvas id="mainViewStack" left="0" top="0" right="0" bottom="0" >
<mx:ViewStack id="vwStack" left="0" top="0" right="0" bottom="0" resizeToContent="false" creationPolicy="auto">
<mx:VBox />
<view:SplashScreen id="splashScreen" showEffect="{slideInEffect}" hideEffect="{fadeOut}" />
<view:LoginScreen id="loginScreen" showEffect="{fadeIn}" />
<view:MainScreen id="mainScreen" showEffect="{fadeIn}" />
</mx:ViewStack>
</mx:Canvas>
</mx:Application>
Can someone help me understand why? I've being doing a lot of non-sense tests because I'm not understanding it.
Sometimes if I remove the Script section the compilation suceed, others not.
Thanks
Thank you all for the comments.
The greatest tip at this topic is: build with the SDK!!!
Flex Builder (both, the IDE and the Plugin) seems to lack a lot of features on error treatment and even when it reports an error it's not reliable.
A prompt window for compiling used with the IDE saved me a lot of headaches.
Thank you all again!
I had this problem using a compiler option to exclude/include some code
like -define+=CONFIG::myOption,true
when the option is true (resulting including some code), and you have such thing into your code :
CONFIG::myOption {
import <a package>;
}
this will result in a 1131 error... I have no workaround but not using such conditional compilation directives.
There is a flex compiler option "Enable Strict type checking" just de-select it. I think that can give so a simple solution....
http://blog.gigantt.com/2011/02/how-to-build-flex-sdk.html
Building
Let's create a batch file to set some useful envars: envars.bat
set JAVA_HOME=c:\Program Files\Java\jdk1.6.0_23
set PATH=c:\dev\ant\bin;%PATH%
set ANT_OPTS=-Xmx256m
Open cmd.exe and run it...
Edit c:\dev\sdk\frameworks\build.xml
Look for:
And fix the location of the manifest file from:
"${datavis.dir}/manifest.xml" to:
"${datavis.dir}/manifest_datavisualization.xml"
Run Ant:c:\dev\sdk\frameworks> ant
It should end with such a message: BUILD SUCCESSFUL
Now let's tell Flash Builder where to find this new SDK: c:\dev\sdk
Add it to the "Installed SDKs" settings in Flash Builder
Make sure your project is configured to use this SDK (it was probably created with the original one and still refers to it).
Rebuild your project. It should work.
I'am having problems with, binding variables being updated. I've made custom TitleWindow component which have text-input and check-box control. When the check-box changes its value, the XML in parent application should also, but it doesn't nor does the
warning: unable to bind to property
Here is the code:
<fx:Declarations>
<fx:XMLList id="nastavitve">
<nastavitve>
<zacetek omogocen="{p_zacet.selected}">
<slika>{slika_i.text}</slika>
<opis>{opis_i.text}</opis>
</zacetek>
<konec omogocen="{p_konc.selected}">
<tockovanje>{tock.selected}</tockovanje>
<kljuc>{kljuc.text}</kljuc>
<besedilo>{besedilo.text}</besedilo>
</konec>
</nastavitve>
</fx:XMLList>
</fx:Declarations>
<fx:Binding source="nastavitve" destination="parentApplication.XML_KODA.nastavitve" />
Main application:
<fx:Declarations>
<fx:XML id="XML_KODA" format="e4x" >
<shramba>
<nastavitve/>
<elementi/>
</shramba>
</fx:XML>
</fx:Declarations>
Are you using the [Bindable] property in the parent control.
Usually flex compiler will give 'Unable to bind to property' warning when the [Bindable] tag is not there.
If you are not using Bindable tag the binding may not happen correctly. We can't predict the binding process if that tag is missing. sometimes it will get bound, sometimes not.
so first check whether the bindable tag is there or not
I just started using flashdevelop for flex apps (I had been using it for pure as3 projects previously). I can't figure out how to import files and such. I have included them to the library as usually. In this case I have included flexlib.swc and flexmdi.swc. Both are in my lib folder and both have been right clicked and Added to the Library.
Auto complete does not work so I think I am missing a step.
This is my code:
`
<flexmdi:MDICanvas id="mdic" width="500" height="500">
<flexmdi:MDIWindow id="win1" title="Window One" x="10" y="10">
<samples:SampleContent />
</flexmdi:MDIWindow>
<flexmdi:MDIWindow id="win2" title="Window Two" x="250" y="250">
<samples:SampleContent />
</flexmdi:MDIWindow>
<flexmdi:MDIWindow id="win3" title="Window Three" x="100" y="100">
<samples:SampleContent />
</flexmdi:MDIWindow>
</flexmdi:MDICanvas>
`
I also tried to add
<mx:Script>
<![CDATA[
import flexmdi.containers.MDICanvas;
import flexmdi.containers.MDIWindow;
]]>
</mx:Script>
I also get a strange error saying flexmdi:MDICanvas is not bound.
I might be way off here because we're talking about FlashDevelop, but I'm pretty sure you need to add the namespace for the MDICanvas in your MXML root tag, like this:
<?xml version="1.0" encoding="utf-8"?>
<MDICanvas xmlns="flexlib.mdi.containers.*" xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
...
</MDICanvas>
The import statements only apply to .as files or <mx:Script> sections of your MXML code.
Death by repetition, but Flex has two ways to import classes and packages. The MXML way and the AS3 way.
Unfortunately, the latest stable releases of FlashDevelop does not support code completion in MXML, although the feature is fully implemented in AS (you can browse packages in libraries with code completion in actionscript).
If you need help with MXML, I suggest keeping the library's API open side-by-side with FlashDevelop (it's what I prefer to do anyway). Still, you need to make sure that you include all of the XML namespaces. For example, for the Degrafa graphics library, you need to include
xmlns:gfx="http://www.degrafa.com/2007"
in the tag (there is also a similar namespace definition for the namespace "mx" already there).
However, MXML code completion is hopefully going to be implemented in a stable release very soon, and there have already been some ways to get it working.