Search code examples
actionscript-3importincludestring-literalsbraces

include/import separate AS3 file


I am trying to just include a .as file in my flash application. I'm sure it's not that difficult and I'm just getting something slightly wrong, but at the top of my code I always put:

include {"Le Bot src/Skill.as";}

OR

import {"Le Bot src/Skill.as";}

to try and include a separate .as file. But, when I use include it comes up with the error: expecting stringliteral before left brace and when I use 'import' it comes up with the errors:

expecting identifier before left brace 
expecting semicolon before left brace

I am just a beginner to AS3, is there any way to fix this problem? Btw, if I remove the two braces on either side, then it comes up with another error


Solution

  • import locationOfASFile.Skill;
    

    e.g. if your Skill.as file was located inside a directory named 'LeBotsrc' which was inside a directory named 'com'

    import com.LeBotsrc.Skill;
    

    Also your as package needs to reflect it's location. So inside Skill.as you would have

    package com.LeBotsrc {