2 Replies Latest reply on Mar 27, 2007 6:02 PM by Craig Grummitt

    referencing a runtime shared library

    Craig Grummitt Level 3
      you ever have one of those problems that make you feel like you must be stupid or surely you could solve this?
      can someone help me sort this out please?

      Step 1 - the library
      i created a simple helloWorld class inside a flex library project i called utils(see below). in the library properties, flex library build path i have selected the helloWorld class.

      Step 2 - the MXML project
      i created a simple Flex project.
      In its properties, flex build path, i added utils to the library path and selected 'runtime shared library' for link type.
      i added an MXML application file(see below) and attempted to call a function within the helloWorld Class.

      I receive the error:
      "1061: Call to a possibly undefined method getHello through a reference with static type Class."

      i won't complicate the issue by discussing my theories and attempts at solving this mainly because i think this'll be enough information for someone out there to have a good idea of what simple thing i'm missing!!

      thanks in advance

      ---------------------------helloWorld.as inside utils flex library project.
      public class helloWorld
      public function getHello():String {
      return("Hello world");
      -------------------MXML Application
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
      import utils.helloWorld;
      private function init():void {
      <mx:Text id="feedback"/>
        • 1. Re: referencing a runtime shared library
          peterent Level 2
          For Step #1, open the Flex Library Project's Properties and go to the Flex Library Build Path. Make sure you have the hellowWorld class selected in the Classes tab.

          For Step #2, open the project's Properties and go to Flex Build Path, Library path tab. Open the helloWorld's library and double-check the link-type setting. For RSL, make sure you give the URL to the RSL (which will most likely just be the filename) and make sure Auto extract is checked. This will place the swf from the Flex library into the bin directory of the application. So if your Flex Library were hello.swc, then hello.swf would be in the bin directory of the application project. Also, hello.swf would be the RSL URL since it will be comming from the same place as the main application swf.

          Now go to the Flex Compiler section of the Project Properties. Add this to the Compiler arguments:
          -runtime-shared-libraries= hello.swf

          where hello.swf is the name of the RSL swf from the first part of Step 2 above.
          • 2. referencing a runtime shared library
            Craig Grummitt Level 3
            thanks for that response peter.

            you are right - i hadn't noticed before but adding the library auto-generated a swf in the bin folder. and when i commented out the problem line there was no compiler error on the import line, all of which seems to imply that the library is being recognised okay.

            breakthrough! i couldn't see the forest for the trees - while i was trying to work out why shared libraries wasn't working, i didn't notice that i'd missed the word 'static'. the class was available, it was just the FUNCTION that wasn't...

            interesting though - i had already done everything you mentioned except for the additional compiler argument, but manually adding this line doesn't seem to be necessary as it is working okay without it.

            thanks for your time anyway peter. a simple little word like static huh? cheers. ;)