tabIndex is not working properly in the below flex code.
mx:AddChild tag is used to add Login.mxml in index.mxml as shown below:
index.mxml
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:login="com.states.login.*"
initialize="init()"
pageTitle="Demo" >
<mx:Script>
<![CDATA[
public function init():void {
Application.application.currentState = 'initState';
}
]]>
</mx:Script>
<mx:states>
<mx:State name="initState">
<mx:AddChild relativeTo="{MainCanvas}" position="lastChild">
<login:Login id="Login"/>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:VBox>
<mx:Canvas width="100%" height="100%" id="MainCanvas">
</mx:Canvas>
</mx:VBox>
</mx:Application>
Login.mxml
<mx:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" >
...
<mx:Form>
<mx:FormItem label="Username:">
<mx:TextInput id="username" tabEnabled="true" tabIndex="1"/>
</mx:FormItem>
<mx:FormItem label="Password:">
<mx:TextInput id="password" displayAsPassword="true" tabEnabled="true" tabIndex="2"/>
</mx:FormItem>
</mx:Form>
...
Tabbing is working when focus is outside the form in browser. But does not work when focus is inside the TextInput control.
The issue was resolved after doing below 2 changes:
Move the code in Login.mxml into index.mxml and removed AddChild method.
year is set to 2006 in xmlns:mx and xmlns:fx namespaces. (Not sure if this was the issue)
How to resolve the tabbing issue without removing AddChild method.
Related
I'm doing a flex program, but i'm having some trouble when calling a pop up from my module. These are the codes:
The function that calls the popUp.
[Bindable] private var popUp : newMemberPopUp;
private function btnNewClickHandler(event:MouseEvent):void {
popUp = newMemberPopUp(PopUpManager.createPopUp(this, newMemberPopUp, true));
}
The popUp mxml
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="350" height="250"
title="Dados Cadastrais">
<fx:Declarations>
</fx:Declarations>
<s:VGroup width="100%">
<mx:Form width="100%">
<mx:FormItem label="Nome">
<mx:TextInput id="nameTextInput"/>
</mx:FormItem>
<mx:FormItem label="Telefone">
<mx:TextInput id="phoneTextInput"/>
</mx:FormItem>
<mx:FormItem label="Email">
<mx:TextInput id="emailTextInput"/>
</mx:FormItem>
<mx:FormItem label="Data de Nascimento">
<mx:DateField/>
</mx:FormItem>
<mx:FormItem label="Data de Cadastro">
<mx:DateField/>
</mx:FormItem>
</mx:Form>
<s:HGroup paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<s:Button label="Gravar"/>
<s:Button label="Cancelar"/>
</s:HGroup>
</s:VGroup>
</s:TitleWindow>
The error i'm getting is this one:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.managers::PopUpManagerImpl/http://www.adobe.com/2006/flex/mx/internal::createModalWindow()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:682]
at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:397]
at mx.managers::PopUpManagerImpl/createPopUp()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:236]
at mx.managers::PopUpManager$/createPopUp()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\PopUpManager.as:139]
at view::Members/btnNewClickHandler()[E:\MyFlexWorkspace\CTCA\src\model\Members.as:29]
at view::Members/__btnNew_click()[E:\MyFlexWorkspace\CTCA\src\view\Members.mxml:39]
If i call the pop up from the application it works fine, but if i call it from the module i have this error.
Make sure you include PopupManager in your top level application. Here is a fairly detailed writeup that talks about a similar issue:
http://blog.flexicious.com/post/Modules-Ultimate-Styles-Popups-and-CheckBoxes-29.aspx
I am trying to add a DateField component to my flex application but when I click on it I get this runtime error:
[Fault] exception, information=ReferenceError: Error #1069: Property softKeyboardRect not found on flash.display.Stage and there is no default value.
It works ok if I do in a simple application and I add the DateField on it but it does not work when I add it on another application.
<mx: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"
color="#333333"
creationComplete="init()">
.... action script code.....
<fx:Declarations>
.............
</fx:Declarations>
<mx:Panel id="MainPanel" title="MyApp" height="1000" width="1100" layout="horizontal" verticalScrollPolicy="auto" >
<mx:HBox id="HBoxHeader" >
<mx:DateField id="StartDate">
</mx:DateField>
</mx:HBox>
<mx:VBox id = "VBoxGroupHeader_LB" height="950" width="250" verticalScrollPolicy="on" visible="true" horizontalAlign="center">
<mx:Label id="groupLable_LB" text="GROUPS" />
<mx:LinkBar id="linkBarGroup" direction="vertical" horizontalAlign="center" itemClick="getMembers(String(event.label))"/>
</mx:VBox>
<mx:VBox id = "VBoxMembersHeader_LB" height="950" width="250" verticalScrollPolicy="on" visible="true" horizontalAlign="center">
<mx:Label id="memberLabel_LB" text="MEMBERS" />
<mx:LinkBar id="linkBarMember" direction="vertical" horizontalAlign="center" itemClick="getMemberTypes('stats.' + activeGroup + '.' + String(event.label))"/>
</mx:VBox>
<mx:VBox id = "VBoxGraphs" height="950" width="580" verticalScrollPolicy="on" visible="true">
</mx:VBox>
</mx:Panel>
Any idea of what might cause this problem?
Thanks
you are targeting older flash player, if you are using SDK 4.6 you need at least flash player 11.1.
I am using the flex 4 popup manager to popup a panel, but the children of the panel are not staying inside the panel. But when i close the popup the children are being removed.
Like this: (sorry i can't post pics)
----------
l________l
l l
..... please enterl
l--------1
Anybody know why? Here's my code:
var forgotPopup:Panel = PopUpManager.createPopUp(this, forgottenForm, true) as Panel;
PopUpManager.centerPopUp(forgotPopup);
And here's what i'm popping up:
<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
// Handle the close button and Cancel button.
private function handleCloseEvent():void {
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<mx:Form horizontalCenter="0" verticalCenter="0">
<mx:FormHeading label="Please enter your e-mail address and your login details will be e-mailed to you"/>
<mx:FormItem label="E-mail">
<s:TextInput id="userInput" x="78" y="49"/>
</mx:FormItem>
<mx:FormItem direction="horizontal">
<s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
<s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
</mx:FormItem>
</mx:Form>
</s:Panel>
Any help on this would be brilliant, thanks.
Try to use the following:
<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
// Handle the close button and Cancel button.
private function handleCloseEvent():void {
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<mx:Form left="10" right="10" top="10" bottom="10">
<mx:FormHeading label="Please enter your e-mail address and your login details will be e-mailed to you"/>
<mx:FormItem label="E-mail">
<s:TextInput id="userInput" x="78" y="49"/>
</mx:FormItem>
<mx:FormItem direction="horizontal">
<s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
<s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
</mx:FormItem>
</mx:Form>
</s:Panel>
If you need to have header word wrapped you should reject standard FormHeading and replace it with Label:
<?xml version="1.0" encoding="utf-8"?>
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="218" height="168" skinClass="PanelSkin" title="Reset Details">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
// Handle the close button and Cancel button.
private function handleCloseEvent():void {
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<mx:Form left="10" right="10" top="10" bottom="10">
<s:Label width="100%" text="Please enter your e-mail address and your login details will be e-mailed to you" fontWeight="bold" />
<mx:FormItem label="E-mail">
<s:TextInput id="userInput" x="78" y="49"/>
</mx:FormItem>
<mx:FormItem direction="horizontal">
<s:Button id="okButton" label="Submit" skinClass="ButtonSkin" />
<s:Button id="cancelButton" label="Cancel" skinClass="ButtonSkin"/>
</mx:FormItem>
</mx:Form>
</s:Panel>
But the best way is to switch to Spark Form which is available since Flex 4.5.
Please Avoid X and Y position
this might also cause the Objects Positions.
I'm getting the "Component declarations are not allowed here error" where I've got my RadioButtonGroup. Below is the custom component.
Why can't I put a RadioButtonGroup in it?
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.RadioButton;
import mx.controls.RadioButtonGroup;
public function removeMe(event:MouseEvent):void {
this.removeChild(event.currentTarget as DisplayObject);
}
]]>
</mx:Script>
<mx:Panel width="500" height="400" title="hello" click="removeMe(event)">
<mx:Text text="My Text" />
<mx:RadioButtonGroup>
<mx:RadioButton label="A"/>
<mx:RadioButton label="B"/>
<mx:RadioButton label="C"/>
</mx:RadioButtonGroup>
</mx:Panel>
</mx:Canvas>
Any advice on how to solve this problem. I'm using Flex 3, SDK 3.2.
Thank you.
-Laxmidi
A RadioButtonGroup is not a container and therefore cannot have Children in the manner you're setting it up. Add a RadioButton to a group using the groupName property on the RadioButton instance. Like this:
<mx:RadioButtonGroup id="rbg" />
<mx:RadioButton label="A" groupName="rbg"/>
<mx:RadioButton label="B" groupName="rbg"/>
<mx:RadioButton label="C" groupName="rbg"/>
I am trying to use a combobox in flex with an array to change to a canvas in a view stack.
Can I do this with some custom action script? The UI I am designing could really benefit form this.
Here's a little demo app that demonstrates what you are trying to do:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.core.Container;
private function onComboBoxChange():void
{
stackNav.selectedChild = this[comboNav.selectedItem];
}
]]>
</mx:Script>
<mx:ComboBox id="comboNav" dataProvider="{['canvas1','canvas2']}" change="onComboBoxChange()"/>
<mx:ViewStack id="stackNav" width="400" height="300">
<mx:Canvas id="canvas1" width="100%" height="100%">
<mx:Label text="Hello" horizontalCenter="0" verticalCenter="0"/>
</mx:Canvas>
<mx:Canvas id="canvas2" width="100%" height="100%">
<mx:Label text="World!" horizontalCenter="0" verticalCenter="0"/>
</mx:Canvas>
</mx:ViewStack>
</mx:Application>
You can change the logic in onComboBoxChange() to use selectedIndex as well:
stackNav.selectedIndex = comboNav.selectedIndex;
Or you can bind the selectedIndex of the viewStack to the selectedIndex property of the combo:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:ComboBox id="comboNav" dataProvider="{['canvas1','canvas2']}"/>
<mx:ViewStack id="stackNav" width="400" height="300"
selectedIndex="{comboNav.selectedIndex}">
<mx:Canvas id="canvas1" width="100%" height="100%">
<mx:Label text="Hello" horizontalCenter="0" verticalCenter="0"/>
</mx:Canvas>
<mx:Canvas id="canvas2" width="100%" height="100%">
<mx:Label text="World!" horizontalCenter="0" verticalCenter="0"/>
</mx:Canvas>
</mx:ViewStack>
</mx:Application>
You can use this solution, but be warned that you can not pike a word with space
(try to change "canvas1" to "canvas 1") and you will see:
[Bindable] private var models:Array = ["tasks","users","bugs"];
public function changeViewStackModel():void {
//this.modelViewStack.selectedChild=users; //works
//this.modelViewStack.selectedChild="users"; //does not work
//this.modelViewStack.selectedChild=this.modelsCombo.selectedItem; //does not work
switch(modelsCombo.selectedItem) {
case "tasks": modelViewStack.selectedChild=tasks; break;
case "users": modelViewStack.selectedChild=users; break;
case "bugs": modelViewStack.selectedChild=bugs; break;
}
}
MXML code:
<mx:ComboBox id="modelsCombo" dataProvider="{models}" selectedIndex="0"
change="changeViewStackModel()"/>
<mx:ViewStack x="29.25" y="55" id="modelViewStack" width="90%" height="200">
<mx:Canvas id="tasks" label="Tasks"><mx:Label text="Tasks stack view!!"/>
</mx:Canvas>
<mx:Canvas id="users" label="Users"><mx:Label text="Users stack view!!"/>
</mx:Canvas>
<mx:Canvas id="bugs" label="Bugs"><mx:Label text="Bugs stack view!!"/>
</mx:Canvas>
</mx:ViewStack>