4 Replies Latest reply on Mar 29, 2011 12:27 PM by DaveGallant

    import and/or export for actionscript without extention?

    DaveGallant Level 1

      I have a project in which I need to import several hundered png images.

       

      When I import them into the library, then select all the images, then view the properties, I Check the export for action script and the export in frame 1.

       

      Now, all my images have class names that I can access though my code, however, it included the file extensions in the class names, thus making invalid class names.

       

      Is there any way I can import and/or set class names so they do not include the file extensions without having to do it manually for EVERY file?

        • 1. Re: import and/or export for actionscript without extention?
          kglad Adobe Community Professional & MVP

          i don't have a direct answer to your question but you can work-around the problem by using:

           

          var classRef:Class=Class(getDefinitionByName("yourimage.jpg"));

          var image:*=new classRef();

          • 2. Re: import and/or export for actionscript without extention?
            DaveGallant Level 1

            I would, but all my media is in an swc file... and anything that needs to be referenced by getDefinitionByName but first be instantiated... otherwise, that is indeed what I would sololy do.

            • 3. Re: import and/or export for actionscript without extention?
              kglad Adobe Community Professional & MVP

              i don't understand your last messge but i infer my suggestion doesn't help you for some reason.

              • 4. Re: import and/or export for actionscript without extention?
                DaveGallant Level 1

                My actual project has something like 9200 images in it.

                 

                if  my main project, let's call it "main.fla", was to contain every one of  those images, every time I tried to run or debug it, it would take  FOREVER to compile... as a work around that I discovered in a previous  project was to put all my graphics and media into an swc file. (Let's  call it MyLibrary.swc)

                 

                While I was trying to get the  swc working, I discovered that while my media in the swc was indeed  setup to be exported for actionscript with unquie classes and  everything, when I compiled and built my project, I could not get any of  those media elements using the getDefinitionByName function.

                 

                After alot of reading and trail and error I found that the only way to get it to work was to have someplace in my code, an actual reference to the objects that I was trying to get with getDefinitionByName. It turned out, that without instantiating the object in the code, the compiler was omitting it.

                 


                Now, but instantiate, I mean doing this:

                 

                var bm:BitmapData = new MyImage();

                 

                Where MyImage.png is in my swc and has a class defined as "MyImage"

                 

                Once I do that, then I can do this

                 

                var classRef:Class = Class(  getDefinitionByName("MyImage")  );

                 

                But without that line above SOMEWHERE in my code (even if it's not actually executed), the getDefinitionByName returns an error saying it can't find the class.

                 

                 

                 

                Now, here's the problem.

                 

                 

                When I import all my images into my swc library they get named with the file extention... "MyImage.png" and when I select all the images that Imported and batch set the export for actionscript, they get automatically assigned a class name equal to their library name, so the class name is "MyImage.png"

                 

                so if I wanted to use getDefinitionByName to access the class, I would need to instantiate it in my code by doing this:

                 

                var bm:BitmapData = new MyImage.png();

                 

                BUT, that is erronous as the period causes an error and the adobe docs says right in it that class names can't use periods or any other non-alphanumeric character.

                 

                 

                So while the getDefinitionByName function DOES actually work with classes with periods in them, because my media is external of the main.fla, I can't load it unless it's instantiated first, which leaves me right back where I was.... having to to manually rename over 9000 classes manually one at a time.

                 

                 

                I did some searching and found the "Flash Library Renamer" extension, but it requires me changing all my class names to be sequenial, which the vast majority is not.

                 

                 

                Is there a way that I can import the files into the library and have it omit the file extension?

                if not, is there a way that I can set the class names in a batch and not have it use the file extentions?

                if not, is there an Flash Extention or plug in that will allow batch renaming using regular expression or wildcards?