Skip navigation
Currently Being Moderated

Excel table into Flash as MovieClip ....best way ?

Sep 17, 2012 8:22 AM

Hi,

Flash CS5

Is this feasible and what is the procedure to use ?

 

Hope AS3 is the place to post this.

 

We have an excel table of bus routes indicating settlements they run to/from/through, one settlement per column, 5 columns of settlements, some columns are empty, each row is a service number.

Fictional example:-

                125         Oxford                 Aylesbury                            Woking   

                156         Coventry             Wolverhampton               Birmingham        StokeOnTrent

 

We wish the user to be able to scroll up down and maybe left right this excel table viewing it in Flash.

 

We need the user to be able to hover over a row and have the settlements for a route appear on the map only whilst the route in the table is hovered over. Is hover possible or would mouse click on a route in the excel table be necessary ?

 

Each exists as a movieclip of spot and text, instance name being the name in the excel table. Flash instance naming dislikes gaps so StokeOnTrent has to be written as such, no apostrophes etc.

 

We hope to convert names like Stoke On Trent into gapless names using excel then use this gapless tables contents in flash AS3 for control of visibility whilst displaying the gappy text table in the scroll pane for the user.

…or is there a better way ? Can AS3 strip out gaps and apostrophes ?

 

I can see how a movieClip can be made into a scrollPane with left right up/down scrolls.

 

How should we go about getting the excel table into the movie clip for scroll pane use with a live link so that any changes to the excel file update in the scroll table in flash ?

 

A non flash person will be adding bus route data to the excel table.

 

What if a route requires another column to indicate more settlements ?

 

Envirographics

 
Replies
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 17, 2012 9:39 AM   in reply to Envirographics

    excel can export a comma delimited file (csv) and flash can load that file type and parse its data.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2012 10:19 AM   in reply to Envirographics

    Flash can read a xls or xlsx file, you nedd (like say Kglad) convert the file to a simple text file (save in excel as csv or using a PHP project), the you can read the new file and insert the information inside a Data Grid, where the format is defined in flash, because de data grid is a flash component

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 17, 2012 10:57 AM   in reply to Envirographics

    changes (including adding columns) to your excel table will update your csv file IF you publish an updated file.

     

    parsing the csv file in flash requires you to add actionscript code and if you are not clever with your code (or cannot anticipate the changes in the csv file that might be made), you'll need to update your actionscript.

     

    use the actionscript string/array methods, you should be able to maniuplate the data strings to suit your needs.

     

    the data won't be parsed into a movieclip.  you will probably want to display your data in flash and to do that, as mentioned by esdebon, a datagrid is usually ideal.

     

    and the datagrid has itemrollover and itemrollout events that you can use to display additional info about datagrid items.

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 21, 2012 10:01 AM   in reply to Envirographics

    use the flash string methods to manipulate your data.

     

    loading a csv file and displaying the contents in a datagrid:

     

    import flash.net.URLLoader;

    import flash.events.Event;

    import flash.net.URLRequest;

    import fl.data.DataProvider;

    import fl.controls.DataGrid;

     

    var urlLoader:URLLoader = new URLLoader();

    urlLoader.addEventListener(Event.COMPLETE,completeF);

    urlLoader.load(new URLRequest("Book1.csv"));

    var dg:DataGrid

     

    function completeF(e:Event):void{

        var dataS:String = e.target.data;

        var dataA:Array = dataS.split("\n").join("").split("\r");

        var dpA:Array = [];

        var itemA:Array;

        for(var i:int=0;i<dataA.length;i++){

            itemA = dataA[i].split(",");

            dpA.push({"col1":itemA[0],"col2":itemA[1],"col3":itemA[2]});

        }

        var dp:DataProvider = new DataProvider(dpA);

        dg.columns = ["col1","col2","col3"]

        dg.dataProvider = dp;

    }

     

    p.s.  don't mark your questions as helpful.  mark responses that you think might help others.

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 21, 2012 10:56 AM   in reply to Envirographics

    you have no file at that location with that name.

     

    you should save your fla and then add that csv file to the same directory.

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 24, 2012 7:01 AM   in reply to Envirographics

    to remedy the 1046 error, import the DataGrid class:

     

    import fl.controls.DataGrid

     

    and the path you mentioned in your message is different than the path mentioned in your recent 2044 error message:

     

    P:\C\Envirographics\Flash Projects\test simple csv datagrid

     

    is not the path in

     

    file:///P|/C/Envirographics%20DATA/Flash%20Projects/5th%20test%20simple%20csv%20datagrid/Simple.csv

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 24, 2012 7:04 AM   in reply to Envirographics

    if you have the correct import statement and an as3 datagrid in your library, you won't see the 1046 error.

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 24, 2012 7:46 AM   in reply to Envirographics

    the 1009 error is caused by not having a datagrid on stage named dg when that code executes.

     
    |
    Mark as:
  • kglad
    62,117 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 24, 2012 8:14 AM   in reply to Envirographics

    you're welcome.

     

    there should shortly, if there's not now, be a link to this thread.

     

    p.s.  please mark helpful/correct responses.  in particular, you might want to point to message 6.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points