Flex backkeypressedhandler not launching with states
I'm developping an mobile program with the Flex 4.5 SDK, this for my thesis for school. I have a bug in my program that I can't fix.
I have a view where I have 2 states. When I change from state my program doesn't listen to the backKey event anymore. I allready tried this:
backKeyPressed.mystate = "backKeyPressed(event)"
But this doesn't help. I made a small program to show you:
<?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="Home"
initialize="init()"
backKeyPressed="view1_backKeyPressedHandler(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var m_list:ArrayCollection = new ArrayCollection();
private function init():void
{
}
protected function button1_clickHandler(event:MouseEvent):void
{
currentState = 'state2';
}
protected function but开发者_StackOverflowton2_clickHandler(event:MouseEvent):void
{
currentState = 'state1';
}
protected function view1_backKeyPressedHandler(event:FlexEvent):void
{
event.preventDefault();
}
]]>
</fx:Script>
<fx:Declarations>
<s:State name="state1"/>
<s:State name="state2"/>
</fx:Declarations>
<s:Group id="stateOneGroup" includeIn="state1">
<s:Button x="30" y="112" label="To State 2"
click="button1_clickHandler(event)"/>
<s:Label x="72" y="216" text="State1"/>
</s:Group>
<s:Group id="stateTwoGroup" includeIn="state2">
<s:Button x="267" y="112" label="To State 1"
click="button2_clickHandler(event)"/>
<s:Label x="303" y="216" text="State2"/>
</s:Group>
</s:View>
I also searched on adobe if it's a bug but I don't seem to find it.
I hope someone can help me.
Kind regards,
Thibault Heylen
I had the same issues today. At last i got it. In my issues, if it is the first view, the backkeypressed doesn't work, but for the other views, the backkeypressed works well.
Hope this helps
精彩评论