A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: eval (#include links.as)???

  1. #1
    Member
    Join Date
    Apr 2003
    Location
    India
    Posts
    35

    eval (#include links.as)???

    Hi guys

    does anybody know how to use #include with eval()?

    I have a if statement

    if(x==1)
    {
    //I want to load one.as here

    }

    else if (x==2)
    {
    //I want to load two.as here

    }


    thanks in advance
    "When u think from ur heart and feel from ur mind...u find urself in a midst of whirlpool of illusions" - DJ

  2. #2
    Senior Member dipkya's Avatar
    Join Date
    Mar 2001
    Location
    Mumbai (India)
    Posts
    158
    Why do you need Eval for this?

    you can try something like this. Whatever your condition is.

    var myname = false;
    if (myname) {
    #include "one.as"
    } else {
    #include "two.as"
    }
    dipkya
    ---------------------------------------------------------------
    SO MUCH HAVE TO DO, SO LITTLE HAS DONE!

  3. #3
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    #include include AS files when the movie is compiled. It cannot be used to load script during runtime.

    to do this you need to put the script in an swf and load that instead.

    /Mirandir

  4. #4
    Member
    Join Date
    Apr 2003
    Location
    India
    Posts
    35
    I am trying to make an updatable directory in flash

    so I want the user to have total control.....
    the .as file will be updated by another program
    and a flash exe will read that file and display its contents

    m taking all the values of combobox from diff .as files

    I tried

    if (place.getSelectedItem().label == "NY") {
    #include "NY.as"
    }

    where "place" is the instance name of combobox


    but it gives syntax error...so i thought I might solve the prob with eval
    ...
    "When u think from ur heart and feel from ur mind...u find urself in a midst of whirlpool of illusions" - DJ

  5. #5
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Then you should build an "engine" that reads textfiles/xml and adapts the movie from that instead. Much easier to manage updates that way.

    /Mirandir

  6. #6
    Member
    Join Date
    Apr 2003
    Location
    India
    Posts
    35
    can i read XML without using a server??
    "When u think from ur heart and feel from ur mind...u find urself in a midst of whirlpool of illusions" - DJ

  7. #7
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    ofcourse you can!

    If you save it in an plain textfile. You can then load it with the xml object.

    /Mirandir

  8. #8
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    The syntax erro came i think because you should always put a line with just a ; folowing an include statement.

    You can load xml directly in flash using the xml object load function

    var my_xml = new XML()
    my_xml.onLoad = function()
    {
    //do something when it is load
    }
    my_xml.load("my_url_to.xml")

  9. #9
    Senior Mender trionik's Avatar
    Join Date
    Nov 2000
    Location
    Montréal,Canada
    Posts
    1,077
    You should use a server to load an xml file only when it is modified by the user and you don't want the file to load from the cache...

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