2 Replies Latest reply on Mar 2, 2012 7:43 AM by PagePageUI

    TypeError: Error #1034: Type Coercion failed: button + IFocusManager


      I am writing an application that only uses the keyboard to navigate throught the components on a page.

      When the user presses the any arror key, the focus is set to the component that has focus.

      For example, i have a container that has several images layout, the user can navigate to the other images

      that container using the arror keys.


      First, i tried using images as the component to store the image but i found out that i could not set the focus on an

      images component. Then i used buttons and set the icon property to the source of the image and it worked fine.


      But then i made a botton component in another mxml file i named buttonImage so i could set the icon property in the

      main application file. When i run it and navigate to the button that is a button is buttonImagel file, i get an error.


      "TypeError: Error #1034: Type Coercion failed: cannot convert components::buttonImage@121ca15c1 to mx.managers.IFocusManagerComponent."


      Does anyone know how i can fix this issue? I would really appreciate it. Here's some of my code:



      <?xml version="1.0" encoding="utf-8"?>

      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"




              width="160" height="220"







      //this is the code in the script block

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"





                          case Keyboard.LEFT: //left keycode: 37


                              if((pattern.indexOf("content_container")) > 0)





                                  focused_component = String(IFocusM.getFocus());

                                  trace('Focus is now on ' + focused_component);





      //this is the mxml code in the MainApplication.mxml

      <s:TileGroup id="content_container"

                       width="700" height="100%"

                       horizontalGap="20" verticalGap="20">

              <s:Button id="first" width="200" height="250" icon="images/charlottes_web.jpeg" focusColor="#28ff2b" focusThickness="4"/>

              <s:Button id="second" icon="images/bad_lieutenant.jpeg" focusColor="#28ff2b"/>

              <s:Button id="third" icon="images/caroline.jpeg" focusColor="#28ff2b"/>

              <s:Button id="fourth" icon="images/che.jpeg" focusColor="#28ff2b"/>

              <s:Button id="fifth" icon="images/date_movie.jpeg" focusColor="#28ff2b"/>

              <components:buttonImage id="last"/>