Solved

Best way to import external text in Flash

Posted on 2007-12-05
4
1,009 Views
Last Modified: 2010-04-21
Currently, we are using 15 spreadsheets to edit the data. We are creating a new EXE to manipulate the data in arrays in Flash 8 Pro. We will eventually use Flash CS3/Flex to manipulate the text.

I think the best method of importing the current data is to export the spreadsheets to a .TXT file and save into a string and manipulate the data then. However, when I export the spreadsheet to a tab-deliminated file, it seems to miss the initial tabs on the first row and only sees the last tab on the second row.

The example of the file is as follows:
matID      Benefit      KPIs      trueMatID      KPICount      KPI COUNTS
PFM_1      Test Text      PFM_2      86      -
PFM_2      Test Text      PFM_2      219      -

I have code that is the following:
tabPosition1 = textOnScreen.text.indexOf(Key.TAB);

Why does it not see the first tab location? Or what do I change so that it sees the first instance of a tab.

OR - is there a better way to import the spreadsheet data or a database solution for Flash? We are currently using Director and v12, but want to convert to Flash CS3/Flex soon.
0
Comment
Question by:msukow
  • 2
  • 2
4 Comments
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 20419702
Well...  There is no tab character in front of each line...  That is why you are not seeing one...

If you parse your data with the for loop, you can get all the elements...

A better approach would be saving the spreadsheet data to a database and have Flash call a server side script to fetch the data you look for...  Unfortunately a server side script is required if you use Flash unless you are using something liek AIR...

CyanBlue
var _lv:LoadVars = new LoadVars();

_lv.onData = function (raw)

{

//	trace(raw);

	var r_arr:Array = raw.split("\r\n");

	for (var i:Number = 0 ; i < r_arr.length ; i++)

	{

		trace(r_arr[i]);

		var t_arr:Array = r_arr[i].split("\t");

		for (var j:Number = 0 ; j < t_arr.length ; j++)

		{

			trace("\t" + t_arr[j]);

		}

	}

}

_lv.load("ExcelData.txt");

Open in new window

0
 

Author Comment

by:msukow
ID: 20419847
Looks pretty good -

However, we need to the the tool self-contained for half the clients - there will not be a server that we can connect to for at least 50% of the users (due to firewall restricts or lack of a internet connection in many areas in the world), the other half with have a connection and the firewalls issues will not be a concern. In that case we will be connecting directly to the database on our servers. We are interested in AIR and it looks like it may be what we need locally (especially if we wait 6 months before inplementing).

Will AIR be something that can be implemented easily, or is there training needed to set up the correct production environment?
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 20420119
Well...  AIR sounds like the tool you are looking for...  The big huddle will be that AIR uses ActionScript 3.0 which is somewhat new...  If you are comfortable with learning new language, it won't be that hard to achieve your goal...  ;)

The only concern is the timeframe...  It still is not a real product, so I don't know how much will be changing down the road and if you are allowed to create a commercial app with it...

CyanBlue
0
 

Author Closing Comment

by:msukow
ID: 31412860
Thanks for all thoughts as well.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now