PDA

View Full Version : A Long shot but please help.


nathanleyton
04-22-2003, 04:11 PM
I am pretty much a basic flsh user although I understand the concepts.. I cannot find anything on this as it is quite specific.

I want to have a ComboBox Component reading its options from a txt file. I havn't a clue. i.e.
Combo BOx Options;

&News1&
&News2&
&News3&


I have made a txt file. like above not sure if correct. When a user chooses News1 I have another txt file called news1.txt I want that cantent to load into the news dynamic text box..and news2 and so on. Not a clue here. (sorry people)

Also I have another set of txt files called link1.txt, link2.txt and so on.. in them I have a URL to a picture.. I can get flash to load the picture just not sure how to make the component features pull the information..

I have included all my working files. it may make more sense.
I have not added any code yet. as I dont know where to start.

The code on there is from something else and should be ignorred.

Please help.. I know it is a lot to ask..

thanks people.

EsChEr
04-23-2003, 01:09 AM
add this code
loadTitles = new LoadVars();
loadTitles.load("titles.txt");
loadTitles.onLoad = function(success) {
if (success) {
for (i=1; i<=3; i++) {
profile.addItem(this["tit"+i], this["tit"+i]);
}
}
};

and titles.txt should have:

&tit1=news1&tit2=news2&tit3=news3&

nathanleyton
04-23-2003, 09:17 AM
loadTitles = new LoadVars();
loadTitles.load("titles.txt");
loadTitles.onLoad = function(success) {
if (success) {
for (i=1; i<=loadTitles.total; i++) {
profile.addItem(this["news"+i], this["news"+i]);
}
}
};
result = profile.getSelectedItem().label+".txt";
loadVarsText = true;
loadVarsText = new LoadVars();
loadVarsText.load(result);
loadVarsText.onLoad = function(success) {
if (success) {
loadtext.htmlText = this.loadtext;
} else {
}
};


the second part of the code I am trying to load a text file into scrolling text box the text file has exactly the same name as the entry into the Combo Box.. Can anyone see where I'm going wrong.. I am probably way off the mark..

Thanks For your help people I am learning a lot and it's fun.. Cheers:D

CyanBlue
04-23-2003, 09:37 AM
Here... Try this... ;)

Some editing has been applied to the text files as well...

Make sure you do not apply scaling to the text field itself...

And locate it to the exact pixel point to avoid the text blur...loadTitles = new LoadVars();
loadTitles.onLoad = function(success)
{
if (success)
{
for (i = 1; i <= loadTitles.total; i++)
{
profile.addItem("news" + i, "news" + i);
}
}
};
loadTitles.load("titles.txt");
//loadVarsText = true;
function loadContent()
{
result = profile.getSelectedItem().label + ".txt";
trace("result = " + result);
loadVarsText = new LoadVars();
loadVarsText.onLoad = function(success)
{
if (success)
{
trace("loaded successfully");
trace("loadVarsText[profile.getSelectedItem().label] = " + loadVarsText[profile.getSelectedItem().label]);
loadtext.text = loadVarsText[profile.getSelectedItem().label];
}
else
{
trace("loaded unsuccessfully");
}
}
loadVarsText.load(result);
}
profile.setChangeHandler("loadContent");

nathanleyton
04-23-2003, 10:03 AM
That works great cyan..

In future it wont say news1 news2 news3 it will have the titles.
I can see how you have done it. I dont understand it all mind.. I need to be able to set the dropdown list from the titles txt file.

I have tried messing with you code but keep ruining it.. I feel so dumb. (Can you reccomend a good book) I have been trough the actionscript for dummies book. Where is best to go from there.

But for now if you could help again I would be very greatfull.

Thanks again your kind people. as soon as I learn all this I will be on here helping out.

CyanBlue
04-23-2003, 10:11 AM
Well... This might do the job...loadTitles = new LoadVars();
loadTitles.onLoad = function(success)
{
if (success)
{
for (i = 1; i <= loadTitles.total; i++)
{
profile.addItem(loadTitles["title" + i], "news" + i);
}
}
};
loadTitles.load("titles.txt");
//loadVarsText = true;
function loadContent()
{
result = profile.getSelectedItem().data + ".txt";
trace("result = " + result);
loadVarsText = new LoadVars();
loadVarsText.onLoad = function(success)
{
if (success)
{
trace("loaded successfully");
trace("loadVarsText[profile.getSelectedItem().data] = " + loadVarsText[profile.getSelectedItem().data]);
loadtext.text = loadVarsText[profile.getSelectedItem().data];
}
else
{
trace("loaded unsuccessfully");
}
}
loadVarsText.load(result);
}
profile.setChangeHandler("loadContent");and this one is edited titles.txt file...&total=3&
&title1=title for news 1&
&title2=title for news 2&
&title3=title for news 3&

nathanleyton
04-23-2003, 10:21 AM
Can you reccomend some good books?? as I say I have done the basic Actionscript and want to extend. Books are sooo expensive and I dont want to get the wrong thing...

CyanBlue
04-23-2003, 10:26 AM
Books are sooo expensive and I dont want to get the wrong thing...Well... That is exactly the same reason why I have only one Flash book... ActionScript Definitive Guide by Colin Moock... The book does deal with the basic stuff, but I don't see it the book for the beginners...
I heard that Friends of Ed's books are all good... Might want to check on that... Also do some searching on the forum with 'book' or something to get more answer cuz I am not the one who can say which one is good and which one is not... (Remember that I have only one book... :D)
I have used Flash manual and Using Help to start learning Flash and used lots of forum information to learn more stuff that I know... ;)

nathanleyton
04-23-2003, 10:32 AM
you have been a real help.:)