4 Replies Latest reply: Jul 22, 2009 6:42 PM by ForrestMorgan RSS

    Connecting a .as file to the .fla file

    ForrestMorgan Community Member

      I have written my .as file to 'make a scrollbar work with text' but the on line video training missed out the last step.

       

      I now have my 'package' defined in my .as file . . . how do I 'link' . . . 'connect' it to my .fla file?

       

      Also, wouldn't it be easier just to write the code in the .fla action layer than a .as file???

       

      Forrest

        • 1. Re: Connecting a .as file to the .fla file
          Ned Murphy CommunityMVP

          If you have created a class file, then you need to "import" the file in the main fla and then declare an instance of it and add it to the stage.

           

          import YourClass;

          var textScroll:YourClass = new YourClass();

          addChild(textScroll);

           

          Personally, I don't deal with classes that much, so for me, yes it would be easier to add the code to the fla file.  Whenever I do deal with as files I end up forgetting to save them every time I add or adjust some code, which can be troublesome when troubleshooting.  If the code is in the fla, I don't have to remember that all the time.

           

          There is a practicality consideration to weigh in deciding whether to use class files or not.... if you are only going to create a one time design with unique features, there isn't much benefit in creating classes.  Classes become meaningful when you are creating re-useable code... code that can quickly be applied to new projects the same way you might add a component or a textfield.

          • 2. Re: Connecting a .as file to the .fla file
            ForrestMorgan Community Member

            Thought so myself - thanks again!

            Forrest

            • 3. Re: Connecting a .as file to the .fla file
              debb4jc Community Member

              Please remove me from your list thanks debb4jc54@yahoo.com

              • 4. Re: Connecting a .as file to the .fla file
                ForrestMorgan Community Member

                Thanks for your help - I tried that but still no scrollbar connected to the text.

                 

                This is getting frustrating - I'm not that stupid! Really I'm not!

                 

                Anyway, no I'm not trying to get someone else to write my code - I NEED to learn this but - but I'm not sure how to "declare an instance of it and add it to the stage".


                (This is waht you wrote)
                import YourClass;
                var textScroll:YourClass = new YourClass();
                addChild(textScroll);

                Like we talked about, I would rather just write my script in my .fla file instead of using classes. But now
                after learning classes - I'm not sure what to delete out of my code.

                I think I am too old to learn this! I understand code but Adobe's code is again, a little different than what
                I had learned years ago on other programs.

                Well, time quit (and have a drink) -

                Forrest