3 Replies Latest reply on Sep 20, 2011 2:52 PM by MatteoLegittimo

    Add custom class to display list

    MatteoLegittimo Level 1


      im new in flex.


      In a flex mobile project im tryin to add my custom class to my view:


      <?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="HomeView" creationComplete="complete(event)">
                  import GridView;
                  import Model;
                  import mx.events.FlexEvent;
                  private var grid:GridView
                  private var model:Model
                  protected function complete(event:FlexEvent):void{
                     model = new Model()
                      grid = new GridView(model)

              <!-- Place non-visual elements (e.g., services, value objects) here -->
          <s:BorderContainer id="gr">



      but i get this error:


      1067: Implicit coercion of a value of type:GridView to an unrelated type mx.core:IVisualElement.


      is not possible to add a pure actionscript class?

      thanks a lot

        • 1. Re: Add custom class to display list
          Jason Szeto Level 3

          Your GridView class probably doesn't implement the IVisualElement interface. UIComponent implements this interface. I recommend you create a UIComponent, add that to the BorderContainer and then add your GridView to the UIComponent.


          Also, don't add the UIComponent to the BorderContainer's contentGroup. Just add it directly to the BorderContainer.


          var uic:UIComponent = new UIComponent();





          • 2. Re: Add custom class to display list
            MatteoLegittimo Level 1

            Great, thanks a lot!!!

            So if i have a custom class i have always to put before in a UIComponent or implement the IVisualElement interface!?



            and not


            When use contentGrroup???


            thanks again!

            • 3. Re: Add custom class to display list
              MatteoLegittimo Level 1

              ...and my last question...


              why in my creation complete event


              protected function complete(event:FlexEvent):void{


                              grid = new GridView

                              uiComponent = new UIComponent





                              stage.scaleMode = StageScaleMode.NO_SCALE





              stage is null?