# Multiple #includes

**URL:** <https://forum.kirupa.com/t/multiple-includes/113183>\
**Category:** Uncategorized\
**Created:** [June 15, 2004, 7:20pm UTC](https://forum.kirupa.com/t/multiple-includes/113183 "2004-06-15T19:20:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbuff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kbuff](https://forum.kirupa.com/u/kbuff)\
**Post date:** [June 15, 2004, 7:20pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/1 "2004-06-15T19:20:03Z")

</div>

[font=Arial]My issue isn’t with including several different .as files, but rather, having to include one .as file more than once. Here’s the situation:

functions.as - has some functions that are used commonly  
myClass.as - has class definition whose member functions require some procedures from functions.as  
myFlash.fla - Flash application which has instances of myClass and also requires use of functions.as

However, myClass.as doesn’t like to include functions.as…  
_ActionScript 2.0 class scripts may only define class or interface constructs._ (no matter where I place #include)  
although myFlash.fla can include it and will work without error.

Is there some convention I’m not aware of where I can use #include in a class definition file? And if so, will it create a problem with multiple declaration of the functions in functions.as? As far as I know, there is no equivalent to C++'s #define and #ifndef preprocessor directives in Actionscript 2.0… a possibility for future development? [/font]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 8:14pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/2 "2004-06-15T20:14:00Z")

</div>

if as 2.0, use extends and import - very similar to java and .net/c# inherit  
/\*  
import functions  
class myClass extends functions{  
}  
\*/

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 8:33pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/3 "2004-06-15T20:33:08Z")

</div>

> [@defcon4](#):
>
> if as 2.0, use extends and import - very similar to java and .net/c# inherit  
> /\*  
> import functions  
> class myClass extends functions{  
> }  
> \*/

Thanks, but no cigar.

The file _functions.as_ isn’t a class, so Flash goes ape on that code with similar errors as when #include’s used:[indent]_Syntax error. import functions_

_ActionScript 2.0 class scripts may only define class or interface constructs. class myClass extends functions_

…

[/indent]Which doesn’t actually bother me that much when it doesn’t work. _BECAUSE_,logistically, myClass _doesn’t_ extend functions because functions is not an object, it’s simply a collection of procedures. Therefore, myClass can’t inherit any attributes from it.

Any other ideas?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 15, 2004, 8:45pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/4 "2004-06-15T20:45:32Z")

</div>

#include cannot be used in AS 2.0 class files. You would either want to have that class inherit from a super class that implements those functions (thereby giving your class access to them), #include functions in .fla outside of the class file (which creates dependancies you will need to document), or create the class in AS 1.0 syntax.

import really offers nothing other than a method of shortening names/paths. It will not include outside scripts into another.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 17, 2004, 6:16pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/5 "2004-06-17T18:16:52Z")

</div>

@kbuff-  
all i can say is that was pseudo code. im not trying to write/declare your classes for you- i was simply providing a template for you to use your own logic and work off of. you will also find no #include in my example, hence i left it out because it wont work. if its a collection of procedures only and you have no desire to make it a standalone class, create a new as file and make it an intrinsic class.

intrinsic class functions{  
//wrap your vars/declarations in an as2.0 interface here-  
var whatever:String;

//write an as2.0 interface for each function in your as1.0 class - this give you access and requires a hell of a lot less code.

function myas10functionname(allow:Boolean):Void;  
function myas10functionname2(easyStuff:Object):Void;

}

as long as functions (as1.0 file you wanted to include) is used in your movie, the intrinic class will act as a wrapper/interface.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 17, 2004, 7:14pm UTC](https://forum.kirupa.com/t/multiple-includes/113183/6 "2004-06-17T19:14:45Z")

</div>

> [@defcon4](#):
>
> @kbuff-  
> all i can say is that was pseudo code. im not trying to write/declare your classes for you- i was simply providing a template for you to use your own logic and work off of.

Yeah, I picked up on that. As the filenames/classes I provided were all renamed and simplified to explain my situation more clearly.

Thanks for the suggestions. My problem really however is that I’m trying to do create something that sways from the concept of OOP. As I Computer Scientist, I can’t bring myself to declare the procedures collectively as an object (in one way or the other) because it would theoretically violate my practices of modularity and polymorphism.

In this case, it isn’t much of a problem because I can just redefine the (short) function I need as a private member of the class. I really just began this thread for future reference in cases where the functions may be longer or there may be the possibility to avoid replicating huge chunks of code.

Thanks anyways.
