9 Replies Latest reply on Jul 30, 2007 8:13 AM by dimival

    flex components missing

    flumanou
      Hello,

      I am starting with flex to continue a work who started somebody else.
      I don't achieve to make it work in my local machine.
      I run an Ubuntu/Linux
      I installed flex from fds2-lin.bin
      I run ./jrun4/bin/jrun start default and the server starts fine. http://localhost:8700/
      I write a "Hello World" flex example and I put it on FLEX_PATH/jrun4/servers/default/samples/ directory and works fine, I see the flex "Hello World" in the browser http://localhost:8700/samples/test.mxml

      Now the problem, I have two files: backoffice.mxml and backoffice.as that works fine in the production environment. I have to work on it to improve them, but I need to set up a local configuration to work on it until I get the right result.

      I store both files at the same directory than before and when I access with the browser to http://localhost:8700/samples/backoffice.mxml

      I see lot of errors like:
      Error /backoffice.as:155
      Access of undefined property mx.

      154: function adminDataHandler(eventObj) {
      155: customers = mx.utils.ArrayUtil.toArray(eventObj.result.customerDetails);
      156: // check if there are NO customers in the system

      I think flex components are not recognised in my installation,... I don't know what I miss.... I need help to fix this first step and start working.

      At the same time, I would like to know if it is possible to set up the work directory I prefer and not need to use the default http://host:8700/samples/

      Thanks for your time.
        • 1. Re: flex components missing
          dimival Level 1
          You mentioned you have both files on the same directory, i think you might have an error there. What's the package for the AS file?
          If it is something like com.myPackage.bla.bla then you should have a directory structure like that:
          com/myPackage/bla/bla/.......

          And about your second question, you will need to change the name of you war (obviously :P) and then open the flex-config.xml file and find the following line:

          <context-root>/samples</context-root>

          then replace samples for whatever you named your war. I think that should do the trick
          • 2. Re: flex components missing
            flumanou Level 1
            Hello,
            Thanks for your kind response to these newbie questions.

            How can I install the mx package?, I think it is not installed on the system. MXML components are well shown but when I need to modify the dynamic of the control, any properties are available.

            Following simple code from doc samples:
            <?xml version="1.0"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >

            <mx:Panel title="My Application" paddingTop="10" paddingBottom="10"
            paddingLeft="10" paddingRight="10" >

            <mx:Label text="Hello World!" fontWeight="bold" fontSize="24" />
            <mx:VBox id="search_area" width="100%" height="100%" marginLeft="0" marginTop="1" marginRight="0" label="Search">
            </mx:VBox>
            </mx:Panel>
            </mx:Application>

            Give me this error:

            3 Errors found.

            Error /test.mxml:8
            Cannot resolve attribute 'marginLeft' for component type mx.containers.VBox.

            7: <mx:Label text="Hello World!" fontWeight="bold" fontSize="24" />
            8: <mx:VBox id="search_area" width="100%" height="100%" marginLeft="0" marginTop="1" marginRight="0" label="Search">
            9: </mx:VBox>

            Error /test.mxml:8
            Cannot resolve attribute 'marginTop' for component type mx.containers.VBox.

            7: <mx:Label text="Hello World!" fontWeight="bold" fontSize="24" />
            8: <mx:VBox id="search_area" width="100%" height="100%" marginLeft="0" marginTop="1" marginRight="0" label="Search">
            9: </mx:VBox>

            Error /test.mxml:8
            Cannot resolve attribute 'marginRight' for component type mx.containers.VBox.

            7: <mx:Label text="Hello World!" fontWeight="bold" fontSize="24" />
            8: <mx:VBox id="search_area" width="100%" height="100%" marginLeft="0" marginTop="1" marginRight="0" label="Search">
            9: </mx:VBox>

            Then, it is sure I don't have flex well installed to understand AS/SWC.
            From

            http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part5_ProgAS. html

            I realise that I don't have any AS files in to my /opt/fds2/jrun4/servers/default/flex/WEB-INF/flex /user_class/ directory.

            I am looking for mx package install,... and so but no luck. Also I thought mx components are installed with Data Services. Maybe I have misses something in the installation.

            Thanks for your time.
            • 3. Re: flex components missing
              dimival Level 1
              You sure are a bit lost :P no worries, i can help.

              There's no such thing as a marginLeft property, it is called paddingLeft:
              http://livedocs.adobe.com/flex/201/langref/mx/containers/VBox.html

              I recommend you to check the online reference, it contains all the properties and methods Flex classes have.
              http://livedocs.adobe.com/flex/201/langref/index.html


              So first things first, change those margins to padding and try it out
              • 4. Re: flex components missing
                flumanou Level 1
                Hi,
                Thanks for your guide. I comment you my impressions :)
                First of all, it is true... I am quite lost :)
                The code I am trying to run in my local machine it is working in other server and I need to continue the development. What I have to do fortunately are not flex issues, mostly scripting to give flex the data. But I need to put a flex development server in my local machine to use the flex application.
                Trying other examples:

                /* test.mxml */
                <?xml version="1.0"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
                <mx:Script source="test.as"/>
                <mx:Button label="Submit" click="doSomething();"/>
                <mx:Label id="textarea1" text="Hello..." fontWeight="bold" fontSize="24" />
                </mx:Application>

                /* test.as */
                public function doSomething():void {
                textarea1.text='Hello World !';
                /* textarea1.fontWeight="normal"; */
                }

                If I comment out the line textarea1.fontWeight="normal"; I take an error:
                1 Error found.

                Error /test.as:3
                Access of possibly undefined property fontWeight through a reference with static type mx.controls:Label.

                2: textarea1.text='Hello World !';
                3: textarea1.fontWeight="normal";
                4: }

                But from:
                http://livedocs.adobe.com/flex/201/langref/mx/controls/Label.html

                I see the Style fontWeight.

                Surely this is not the way to change a style property but a mx:Label property, and it should be my error. But as I introduced, what I need to run is a code that works in other flex server, and I get errors like:

                39 Errors found.

                Error /backoffice.as:155
                Access of undefined property mx.

                154: function adminDataHandler(eventObj) {
                155: customers = mx.utils.ArrayUtil.toArray(eventObj.result.customerDetails);
                156: // check if there are NO customers in the system

                So I guess I missed something in my installation.

                Thanks for your help,
                • 5. Re: flex components missing
                  dimival Level 1
                  Ummmm i think i know what the error is, since you are using an external .as to be your script you don't have the reference to the label named "textarea1" so let's try this:

                  /* test.mxml */
                  <?xml version="1.0"?>
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
                  <mx:Script source="test.as"/>
                  <mx:Button label="Submit" click="doSomething(event);"/>
                  <mx:Label id="textarea1" text="Hello..." fontWeight="bold" fontSize="24" />
                  </mx:Application>

                  /* test.as */
                  import flash.events.MouseEvent ;

                  public function doSomething(event:MouseEvent):void {
                  event.currentTarget.text='Hello World !';
                  event.currentTarget.fontWeight="normal";
                  }

                  That should work, let me know the result of it.

                  I suggest you to download and begin to read the Flex 2 Developer's Guide, it's on the Adobe site, it will be very useful so you can learn some basics :)
                  • 6. Re: flex components missing
                    flumanou Level 1
                    Hi,
                    Thanks for following me. But don't make efforts to try to make the example works, I just trying to set up the environment and try examples to test it.
                    The script I have to run gives me errors, but not in the production server, so I have something bad in my installation.

                    By the way, your changes doesn't make it work. Now no errors but nothing happens when click :)

                    I have errors like:
                    Access of undefined property mx.
                    ...

                    So I think I don't have the core flex module installed. Can you help me with this?

                    Thanks.
                    • 7. flex components missing
                      dimival Level 1
                      Well since you have a deployed war on your application server, it don't think it is an installation problem. I am assuming you are using the samples war that is on your installation directroy, am i right?
                      In case you are not using it, then you will need to check that you have the following .swc files inside your /WEB-INF/flex/libs folder:

                      automation.swc
                      automation_charts.swc
                      charts.swc
                      fds.swc
                      flex.swc
                      framework.swc //this is the one that contains the mx.utils package, along with many others
                      playerglobal.swc
                      rpc.swc
                      utilities.swc

                      Now, i am assuming this is all correct then i would suggest you to import the mx.utils.ArrayUtil in your script, like this:

                      import mx.utils.ArrayUtil;

                      public function adminDataHandler(eventObj) {
                      customers =ArrayUtil.toArray(eventObj.result.customerDetails);
                      }

                      There's something that has been bothering me, and this is only a guess, but it seems as if the app you are trying to run was Flex 1.5 app, the code above has certain errors, for instance the lack of public or private for your function (i added it on bold), then the lack of a data type for your eventObj variable. Those are things that worked on Flex 1.5 but don't work anymore on Flex 2. Like i said it is only a guess but just make sure that the app is indeed a Flex 2 app

                      Hope this helps

                      • 8. Re: flex components missing
                        flumanou Level 1
                        Hi there,

                        Yes, you help is welcome, at least I don't feel alone in the desert :)

                        I try your suggestion, and yes... this error has been solved.

                        Thinking about the thing that bothers you ... is it possible that the scripts I am trying were written for flex 1.5, I am running flex 2, so... maybe that's why I am experiencing these issues.

                        I will try to look for the way to import each control is used. For example NULL should be null, but the old code has NULL and it is working. It is strange.

                        Thanks a lot.
                        • 9. Re: flex components missing
                          dimival Level 1
                          Glad to hear that it is working, there's an Adobe official guide on how to migrate applications from Flex 1.5 to Flex 2.0, i recommend you to check it out, you will be able to detect most of the migration errors with it.

                          Let me know if you need any further assistance, i am always glad to help :)