2 Replies Latest reply on Jan 25, 2010 1:37 PM by cyber0897

    can you set arraycollection objects to certain states?

    cyber0897 Level 1

      hey guys.. so in my application, i need to setup rules and permissions for certain users...

      so basically my applicaion initially displays a login screen, on login success its going to get a variable from the server which says if the user has all or video access


      the way i have my "login success" component setup is i have an array collection and i have states

      basically if the user has "all" access then the user shoudl be able to see everythign in that array collection. and if the user has "video" access the the user shoudl onlly see the video option in the list


      the code i have is


                <!-- Place non-visual elements (e.g., services, value objects) here -->
                <s:ArrayCollection id="webCoreSourceData">
                     <fx:Object label="Content Group" stackId="contentGroup" />
                     <fx:Object label="Images" stackId="images" />
                     <fx:Object label="Image Renderer" stackId="imageRender" />
                     <fx:Object label="Videos" stackId="videos" />
                     <fx:Object label="Flash Objects" stackId="flashObjects" />
                     <fx:Object label="Story Editor" stackId="storyEditor" />
                     <fx:Object label="Tag Management" stackId="tagManagement" />
                     <fx:Object label="Image and Video Format" stackId="format" />
                     <fx:Object label="Rules And Permissions" stackId="rulesAndPermissions" />
                <s:State name="all" />
                <s:State name="videoUpload" />
                <s:State name="imageUpload" />
                <s:State name="contentGroup" />
                <s:State name="flashObjects" />
              <list dataprovider="webCoreSourceData" />



      i need to set each one of these arraycollection objects to a certain state, so when i set "currentState=videoUpload" then only video displays in the list component

      and when i set my "currentState="all"" then i want to be able to all the objects in the arraycollection



      any help is greatly appretiated!! thank you...

        • 1. Re: can you set arraycollection objects to certain states?
          David_F57 Level 5


          There are a few things you can do, one is to filter the array on change of state you could have it that your dataprovider is different for each state then you do something like below. This might give you some sort of direction anyway..




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

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





          import mx.events.FlexEvent;




          <s:State name="State1"/>

          <s:State name="ImageState"/>

          <s:State name="VideoState"/>

          <s:State name="OtherState"/>



          <s:ArrayCollection id="Videos">

          <fx:Object label="Video1" />

          <fx:Object label="Video2" />

          <fx:Object label="Video3" />

          <fx:Object label="Video4" />


          <s:ArrayCollection id="Images">

          <fx:Object label="Image1" />

          <fx:Object label="Image2" />

          <fx:Object label="Image3" />

          <fx:Object label="Image4" />


          <s:ArrayCollection id="OtherStuff">

          <fx:Object label="OtherStuff1" />

          <fx:Object label="OtherStuff2" />

          <fx:Object label="OtherStuff3" />

          <fx:Object label="OtherStuff4" />


          <s:RadioButtonGroup id="radiogroup1"/>


          <s:List id="myList" x="163" y="85" width="271" height="386"




          <s:Button y="15" label="Video" x="160" click="currentState='VideoState'"/>

          <s:Button y="15" label="Image" x="240" click="currentState='ImageState'"/>

          <s:Button y="15" label="Other" x="320" click="currentState='OtherState'"/>


          1 person found this helpful
          • 2. Re: can you set arraycollection objects to certain states?
            cyber0897 Level 1

            i did think of that... but the only problem is... if the user has multiple access like, if a user has access to the video and the images for example...


            is there a way i could do that?