-
Senior Member
can i run a script from an external file on runtime -no #include-
hi.. i want to import a script from an external file but after compiling the swf, so i cant use #include...
is that possible..????
-
why cant you use #include?? it does include the code at runtime from the swf and i'm pretty sure you can also setup the file in includes to be dynamic, i.e. chosen by the user using a text input or a box.
if you store the file name as a variable you can just say
[AS]#include varName;[/AS}
in this way you can change the value of the variable (provided it is a string) and provided it is a valid value, it will load that file
Just cos you're paranoid, does'nt mean that they aint out to get you
-
Senior Member
do u mean something like this..
[AS]
file = "1.txt";
#include file
[AS]
it gives me an error "Malformed #include directive #include file"
it seems that the included file must be specified and between quotations..
-
You can't use that method with a variable to define your #includes since the #include files are compiled before any variables are parsed, therefore the reference doesn't exist yet.
-
hmmm, so it seems, i have just been trying this myself as i was curious. it makes sense now really. Apologies, we all learn something new everyday!
If however you use an aribitrary number of scripts which are predetermined before compile, you can just include them ALL, and then just write a function to decide which to use during runtime. In this way you could jump between files.
Just cos you're paranoid, does'nt mean that they aint out to get you
-
its amazing how many people still think #include is used during runtime. any line beginning with a '#', like #include or #initclip is read only by the compiler, and is removed when the compiler finnishes.
you wouldnt be able to include script at runtime because the AS interpreter canot read uncompiled bytecode - the player would have to compile the code for it to be readable, and this wouldnt be a feasable option because of the small, simple nature of the flash player.
you could however load a swf with just code on frame one. you could even rename it too "mycode.AS" if you wanted.
This information is subject to change without notice and
is provided "as is" with no warranty.
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
|