A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: externally visible definition

  1. #1
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169

    externally visible definition

    i keep getting the error following error:

    5007: An ActionScript file must have at least one externally visible definition.

    the scenario is a simple fla file that includes an external actionscript file. If i copy the code from the external actionscript file into the frame where the include code is, there is no change, i still get the error. the external actionscript file doesn't have any packages or classes, just a few functions and other stuff like that
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  2. #2
    Member
    Join Date
    Dec 2006
    Posts
    52

    Cow Icon

    im pretty sure you need to declare a class, and declare it in a package.

    Code:
    package
    {
    	public class MyClass
    	{
                 public static function myFunction()
                 {
                        //stuff goes here
                 }
            }
    }
    if you want to seperate out some functions from your main script, make a class like above, and declare your functions static.

    to call them simply write
    Code:
    MyClass.myFunction();
    (replacing myclass and myfunction withwhatever youve called them).

    I hope this isn't wrong and is somewhat helpfull (im used to just using classes).

    oh and you need to save the file as the same name as your class, ie in this case save your file as MyClass.as


    chur

  3. #3
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you don't have to have a class. plain old functions are fine, just make sure to write them just like you would in frame, like so
    PHP Code:
    // contents of utils.as
    function test(a,b,c){
    trace(a+b+c);

    which would make the test function available to an FLA that had the .as included, like so
    PHP Code:
    include "utils.as" 
    note that in AS3 you omit the "#" from AS2

  4. #4
    Member
    Join Date
    Dec 2006
    Posts
    52
    :P well ill be quiet then.

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The class needs to be public. Then it is visible.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Member
    Join Date
    Dec 2006
    Posts
    52
    Quote Originally Posted by cancerinform
    The class needs to be public. Then it is visible.
    so you do actually NEED a class? not just loose functions?

  7. #7
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169
    no i don't want classes, just loose functions. i've done what moagrius said to do, but it didn't help
    Sand Monkey

    Flying is learning how to throw yourself at the ground and miss!

  8. #8
    Member
    Join Date
    Dec 2006
    Posts
    52
    pronounce your functions public

    ie
    public function myFunc()
    {}

  9. #9
    Member
    Join Date
    Dec 2006
    Posts
    52
    and if you still are getting problems do put them in a package

    Code:
    package
    {
    
        public function myFunc()
       {}
    
    }

  10. #10
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    not sure where the confusion is here.

    you absolutely can put functions in a .as file, include that file and use those functions.

    make a new .as, call it "test.as". put this in
    PHP Code:
    function somefunc(){
        
    trace("somefunc");
    };
    function 
    anotherfunc(a,b){
        
    trace("argument a is " a);
        
    trace("argument b is " b);
    }; 
    create a new fla. put this
    PHP Code:
    include "test.as"

    somefunc();
    anotherfunc("A","B"); 
    save it in the same directory as test.as. test movie. it'll trace.

  11. #11
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Quote Originally Posted by sand_monkey
    no i don't want classes, just loose functions. i've done what moagrius said to do, but it didn't help
    What exactly did you do originally that gave you this error? Did you import a class or an as file?
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center