This is a discussion on "Can I invoke a timeline from an external text file Array?" within the Flash & Multimedia Forum section. This forum, and the thread "Can I invoke a timeline from an external text file Array? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Can I invoke a timeline from an external text file Array?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Can I invoke a timeline from an external text file Array?
Hello all, forum newbie here! Not only that, but I'm also pretty new to intermediate Actionscript too so please please please, talk to me as if I were a four year old! Now my problem
I'm stuck. I am creating a presentation for a friend who works in the field of science. I've promised results before Friday :eek: I'm trying to get Actionscript to engage a timeline effect from an external text document containing specific data in an array format. So basically I have created a map of London divided by its postcodes eg: NW2, SE12, E2... Graphically, there are two layers to this representation of London, a complete map of every postcode in London grouped together in light grey beneath (see pic1), and on top a layer with each seperate postcode created as an individual movie with an alpha state of 0 (as in named by its instance as the postcode it represents) which, when triggered by the array is highlighted in red on the map (see pic2). ![]() pic1 ![]() pic2 Sorry about the pictures but thought it's the best way to explain what I mean! I have some script I got from Flashkit to trigger the data from an external file to highlight corrosponding areas of london by its postcode. Below is an example of the data in the external text document:
d-kam. EDIT: Forgot to explain that "estados*" is a consecutive day reference so in effect the movie has 153 days in it. I hope this all makes sense! |
|
|
|
|||
|
Hi and welcome to the site!
What you're asking is certainly not an 'intermediate' question! It's pretty difficult stuff in Flash. Mixing Actionscript with the timeline in a dynamic way is quite difficult, for various reasons. I would instead suggest that you put the map parts into one containing movieclip. You can then put certain Actionscript onto this movieclip that can act based on time, in a way. The following code can be placed on a movieclip:
If you're feeling confident you could write a function to try to fade in and out all of the areas individually, but I think it would be easier to have each in it's own movieclip that fades to a highlighted colour and back again. Then your script only has to tell each clip to play and it'll fade in, or out, depending on where it is already. There might be better ways to do this, but I can't think of any immediately. What you're doing is a little odd and I think that if you told us exactly what you were trying to achieve it might be easier to do another way. Let's say you want certain areas highlighted at different times... why not simply let the user click on the areas to highlight them and have a 'reset' button to clear all the areas back again. You could even hard code this to highlight certain groups, etc, etc. I don't think that would be unreasonable for a presentation? If whoever you're making this for wants to change the animations for different presentations then another idea might work. What about defining a time for each postcode as well in your source? In Flash, all you need to do is run the same script every x seconds, or when the user prompts, to move onto the next timeframe. If each postcode has a timeframe then you just scan through the list and highlight the appropriate areas. I can't help thinking that it would be easier to just preset the animations into Flash in the first place? Fiddling around with text files and getting the programming to work will probably take more time in the long run. From my experience, presentations aren't dynamic anyway. The way you have this setup already makes it fairly easy to create a hardcoded version that simply runs the same script you already have at particular places on the timeline - unless you have a really good reason not to? |
|
|||
|
Thanks you for your answer and warm welcome Sirkent! I think I need to re-explain what my problem is because I'm not sure if I explained it properly, although I'll definitly look into your suggestions
Movie objectives: 1: To create a flash movie that can process a large amount of data from an external file. 2: To have that processed data trigger movie events within the flash document. 3: To make it look cool! Movie specifics: -The data is actually confidential so I need to use an alternative for what it represents. I'll use rabbit populations for this purpose! -The main element for each movie is a map of London divided into postcodes. The map was created by myself by vectorising and cleaning up a jpeg I got off the net. I then broke this vector up and turned every postcode area into a movie and named it by its relevent postcode. The postcodes are the target for what the data represents, which as I said are *ahem* rabbit populations and in this case I want to represent which postcode/s had the highest populations for a given day/date. There will some days/dates that return no results. -The data was generated using excel and is in the following format
-The data needs to be shown over a period of time so that for each given day, the populations are shown for a specified period of time and then dissapear when the next day is processed. -A date for the data needs to be included within the movie relevent to the day for data shown on the map (so that estados1 would be 11th October 2004 for example). (I was just gonna do this myself by hand by putting a text box with the date in each frame and then sync it to the output of the data). That's it really. I can see how this probably a tall order for flash and am wondering if I should try out something else but it is for the visual effects in flash that I would like to use it, not its ease of use. Now to explain what I have. Here is the file with a sample of data called 'data.txt'. I got the code from flashkit.com from someone elses movie which seemed to offer exactly what I need except a timeline and the ability to read multiple lines of data... OK, so maybe not exactly what I needed but it seemed close! So this is what I am using as a script:
Many thanks, d-kam. |
|
|||
|
Forgot to say, yes the presentation doesn't need to be dynamic and will be hardcoded. It only needs to play, stop and start again. However the ability to change the data in the presentation by simply updating an external file would be extremely useful
d-kam. |
|
|||
|
OK, so I think I've decided on something for this movie but need some more scripting advice please
Quote:
The only thing is, I don't know how to make the external text doc communicate with flash. Could the data output commands such as...
d-kam PS: Sorry about all these posts! I hope you guys don't mind... |
|
|||
|
You couldn't import AS like that. If you wanted to import the code as well as the data then they would have to be in seperate files and then... what is the point?
You will simply need to specify variables in your data file, like this:
If you have each day on a seperate row, then you can even try something a little clever like this:
There's just a few ideas there, but you will need to use Flashvars, or XML in order to import your data and Flashvars using these methods is closest to what you've already shown me. However you will, of course, have to write the actionscript to use this data in Flash, you can't put it in the file with your data, at least, not as far as I'm aware. The only way of doing it would be to actually write an interpreter to process your commands and that would be particularly difficult! If you do want to do things such as gotoAndPlay(var) then you could also use the above... Just remember that the last variable on a line will have \r\n on the end of it. Also, sorry for literally expressing the development of my ideas in the post, but I think it follows through and should teach you about loadVariables and a good way of implementing them for this approach? |
![]() |
| Tags |
| invoke, timeline, external, text, file, array |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scrub external SWF timeline and video within that SWF | HeayyPops | Flash & Multimedia Forum | 0 | Oct 15th, 2007 22:46 |
| Load External .JS File Before Anything Else | tox0tes | JavaScript Forum | 1 | Jul 10th, 2007 14:03 |
| Is it possible to use an external text file for a variable | AdRock | JavaScript Forum | 2 | Sep 15th, 2006 17:25 |
| Load .swf file with External text in Another Flash document | ien | Flash & Multimedia Forum | 3 | Aug 31st, 2006 14:29 |
| loading external images into array | geminity | Flash & Multimedia Forum | 2 | Feb 14th, 2005 21:29 |