A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Loading "clickable" text document

  1. #1
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20

    Loading "clickable" text document

    I'm trying to create a very large library of all craft that have been made for the old star wars game xwing alliance. Since new ships are being made by modders, and there are already hundreds of ships to catalogue, I wanted to make something simple to update.

    http://www.swcrusade.com/library/index.htm

    My plan is to make it so visitors can click on the ship names, and for example a (movie clip?) picture of the A-wing, with its technical details would load in the large black area.

    How do I make it so the text in the text document will affect the loading of pictures and stuff in the flash movie? Is it even possible?

    So far my text document just looks like this:

    my_text=RZ-1 A-Wing
    Alpha Class Xg-1 Assault Gunboat
    B-wing
    Cloakshape Fighter
    Dragonsbane
    E-Wing Type-C
    Firespray Attack Ship
    etc...

    I tried to put some action script stuff in beside the ships names, but I have no clue what I'm doing...

    And I got the scroll thing from: http://www.mediasparkles.com/resume/scrollbar.html

    Thank you ahead of time
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Your text file should look something like this:

    my_text=<a href="awing.htm">RZ-1 A-Wing</a>
    <a href="assault.htm">Alpha Class Xg-1 Assault</a>
    <a href="gunboat.htm">Gunboat</a>
    etc....
    B-wing
    Cloakshape Fighter
    Dragonsbane
    E-Wing Type-C
    Firespray Attack Ship
    etc...

  3. #3
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    I'll give it a try, but I don't understand: how will html, and perticularly the .htm extenstion manipulate the .swf? It'll be cool if it does! But I'd expect by making those links, what will happen is that they will open a new browser window or replace whats in the window that the craft library is already in? Is that the only way to do what I want?

    Thank you
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  4. #4
    Member
    Join Date
    Aug 2003
    Location
    Dryden, ON - Canada
    Posts
    71
    Wouldn't it be possible to do the following with your text document:

    RZ-1 A-Wing=1
    Alpha Class Xg-1 Assault=2
    Gunboat=3
    B-wing=4
    Cloakshape Fighter=5
    etc.
    .
    .
    .
    .
    <EOF>

    And then once the SWF file reads the text document in, have it actually place these in the right place of an array? Such as...

    var ships = new Array;
    ships[0] = <read in ship that equaled 1>;
    ships[1] = <read in ship that equaled 2>;
    etc.
    .
    .
    .
    ?

    I am just wondering for personal use, not so I can do the same thing mind you, but I am learning ActionScript myself and I would like to know for reference. Seeing if ActionScript's ability to read files is anything like the other languages I have learned.

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Yes, that will open pages. I honestly can't think of any script that will tell a movie to do something, from a loaded text field. HTML formatting works fine, for the most part, but actionscript inside a loaded text file has no way of working that I know of. Maybe someone else can answer?

  6. #6
    Member
    Join Date
    Aug 2003
    Location
    Dryden, ON - Canada
    Posts
    71
    No I wasn't asking if you could place AS inside a text file, I was asking if you could read the data from the text file and then make changes to variables based on those findings...

    Like if I was using the programming language C, I could read the text file in character by character and then decide how to deal with it. Or I could read the entire file in and then try to deal with it. Basically I'd have to separate the data in some way (whether by line carriage \n in C, or \r in AS) or by some other separating means. And in the case I stated above I could use both the line carriage and the '=' in order to determine such things... such as the line carriage would inform me that a name/value pair has been located. And the = character would inform me of where the name is separated from the value. Realistically, however, you would most likely have the items in the text file listed opposite in order to be more productive, such as:

    1=RZ-1 A-Wing
    2=Alpha Class Xg-1 Assault
    etc.

    Would you happen to know this one?
    Thanks

  7. #7
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    You could create links that use the asfunction protocol to call functions created by actionscript, eg

    <a href="asfunction:myLoadMovieFunction,file">Click to load file</a>

    then in the same timeline as the text field you can define the myLoadMovieFunction as something like,

    code:

    myLoadMovieFunction(file) {
    loadMovieNum(file, 1);
    }


  8. #8
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Hmmm, it never occured to me that asfunction would work from a loaded txt file. But why not?

  9. #9
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    I don't understand I'm not sure what you mean by the use of "file" in the various places. Do you mean to replace the word file with the name of my text file? I tried and although the word "Awing" turned into a link, clicking on it would do nothing I just might not know how to setup my frames for what your saying Below is what I have so far:



    I guess when you click on the "Awing" from the text file, I want to go to frame 3? Is this the hard way of loading movie clips for what I want to do?...

    Thank you again!

    EDIT: the error I get is:

    **Error** Symbol=main_mc, layer=text, frame=1:Line 1: Syntax error.
    myLoadMovieFunction(external.txt) {

    Total ActionScript Errors: 1 Reported Errors: 1
    Last edited by Starwars_Freak; 10-04-2003 at 06:49 PM.
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  10. #10
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    First create some individual swf files with the images and whatever text you want to be displayed with the image (you could make this so each ship has its own movie created about it), these movies can then be loaded into your main movie when needed.

    To do this on the main timeline of your main movie add a movie clip (this can be an empty clip) and give this the instance name shipHolder. it will be used to hold the loaded swf files with the images in them.

    Now also in the main timeline add the following frame action,

    code:

    function loadShipImage(file) {
    this.shipHolder.loadMovie(file);
    }



    Now in the text document you are loading you can add regular HTML hyperlinks (make sure the textfield you display the text in has HTML rendering turned on! ) that when clicked will call the loadShipImage function and supply it the filename of the swf file that needs loading, so one link in this file could be something like,

    <a href="asfunction:_root.loadShipImage,bigship.swf"> Click to see a picture of a big ship</a>
    <a href="asfunction:_root.loadShipImage,smallship.swf ">Click to see a picture of a small ship</a>

    assuming you had created swf files named bigship and smallship with images in them.

  11. #11
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    I tried adding in that action script (I put it in differnet places to try it out several times), and also created two .swf files holding ships, but it didn't work I guess the problem lies between the keyboard and the chair

    If someone could look over what I have and see what I'm doing wrong I'd be very greatful!

    http://www.swcrusade.com/images/swlibrary.zip
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  12. #12
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    The only problem is the shipHolder clip hasn't had its instance name set, the instance name is separate to the name given to the clip when you create it.
    click on the clip on the stage (flash displays it as a small white circle so you can find it) and look in the properties inspector. Fill in the name shipHolder in the instance name field here and it should all work

  13. #13
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    Awesome!!!!!!

    Thank you so very very much!
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  14. #14
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Ya, but I got to make one to see it work, "Unexpected File Format".

  15. #15
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    Woohoo! It works

    http://www.swcrusade.com/library/index.htm

    I took the .zip file down once catbert303 told me what was wrong If you want I can put it up again?
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

  16. #16
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    No, I got the zip when it was up, but you must have made it on a Mac, cause I can't open it in MX.

  17. #17
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    odd, I was able to open in on windows XP, but I can't remember if I opened it in MX or MX2004, so maybe it was an MX2004 file?

  18. #18
    Junior Member
    Join Date
    Oct 2003
    Location
    Ontario
    Posts
    20
    Oh I C what you mean. Its a Flash mx 2004 file I normally use just flash mx, but decided to give the new 2004 demo version a try. So far I find the layout improved, but since I'm not that great at flash, I'm not sure its worth it to upgrade for me.
    "The object of war is not to die for your country but to make the other bastard die for his."
    - General George Patton

    http://www.swcrusade.com/

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