A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: can i run a script from an external file on runtime -no #include-

  1. #1
    Senior Member sherif79's Avatar
    Join Date
    Jan 2001
    Location
    Essex, England
    Posts
    266

    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..????

  2. #2
    Multimedia Developer
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    41
    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

  3. #3
    Senior Member sherif79's Avatar
    Join Date
    Jan 2001
    Location
    Essex, England
    Posts
    266
    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..

  4. #4
    immoralator
    Join Date
    Dec 2001
    Location
    UK
    Posts
    270
    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.

  5. #5
    Multimedia Developer
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    41
    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

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Location
    Top Shelf
    Posts
    757
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center