-
Arabic Flash Guru
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!
-
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
-
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
-
:P well ill be quiet then.
-
Senior Member
The class needs to be public. Then it is visible.
- The right of the People to create Flash movies shall not be infringed. -
-
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?
-
Arabic Flash Guru
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!
-
pronounce your functions public
ie
public function myFunc()
{}
-
and if you still are getting problems do put them in a package
Code:
package
{
public function myFunc()
{}
}
-
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.
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|