PDA

View Full Version : Including things (newbie)


ecks
06-06-2003, 03:44 AM
I just started messing around with ActionScript today, and I'm clueless, i tried reading, and either i didn't understand most of it, or i couldn't find what i need. I have an extensive knoweldge of vb, perl, php, and some java so im not new to programming. Can someone point me in the right direction? Basically what im trying to do is include text from a file, and include images into the thing at runtime, like, when a user clicks on a button, www.domain.com/image5.gif would appear, hit next, image6 etc..

Thanks,
ecks

CyanBlue
06-06-2003, 04:02 AM
Howdy and Welcome... ;)

To load the content of the text file or the output from the PHP script, we use loadVariables() function in F5, and LoadVars() object in FMX...

To load external image, we use loadMovie() function to do that, but the only file type Flash can read is JPG...

There are several tutorials that you might want to try by yourself before you actually code what you are looking for... Go check out the tutorial area... Also do some searching at the forum with the given terms to find more information on those...

ecks
06-07-2003, 12:37 AM
aight thanks man, i'll read up on that stuff now :)

ecks
06-07-2003, 01:46 AM
ok, i tried loading it, and i get
_level0.MainText

my instance name/var name for my dynamic textbox is "MainText"

and the AS code is:
holder.LoadVar("http://solutions.idirectweb.com/thing.txt");

and thing.txt looks like

&MainText=bleh bleh bleh bleh blehb leh blehb le hkejksdfjlkasdfjdlslasjfsd&EOF=true

whats wrong :confused: :confused:

CyanBlue
06-07-2003, 02:46 AM
Can you show me the whole code??? Just seeing the bit by bit doesn't help that much whether the syntax is write or wrong... ;)

ecks
06-07-2003, 03:11 AM
LOL! that is my whole code.. i assume from that statement.. i'm missing alot

CyanBlue
06-07-2003, 03:24 AM
Ya... :)

Try this...data_lv = new LoadVars();
data_lv.onLoad = function ()
{
trace("Done loading text file...")
trace("MainText = " + data_lv.MainText);
trace("If you have a text field with the instance name");
trace("set to Main Text as well...");
_level0.MainText.text = data_lv.MainText;
}
data_lv.load("http://solutions.idirectweb.com/thing.txt");See if this gets you going further... ;)

A few things...

Do not use variable name for the text field unless you export to F5... That variable name is there for the backward compatibility only... But then, if you use LoadVare() object, there is no reason for you to use variable name since F5 won't do nothing on the LoadVars() commands... :)
Always put onLoad() handler before you actually use load()/send()/sendAndLoad() function... That's for your own good... ;)
LoadVarisbles()/LoadVars() won't load the data from other domain... Your Flash movie should be located within the given domain name, http://solutions.idirectweb.com/ in this case...

Let me know... :)

ecks
06-07-2003, 03:29 AM
seeing how i dont like to have things done for me, could you explain what each function you just used does, or tell me where i can read about em?

CyanBlue
06-07-2003, 03:47 AM
Well... There isn't much I can explain right there...

Anyways... ;)
// Define a new instance of the LoadVars() object
data_lv = new LoadVars();
// Define a function that will be executed once data has been
// fully loaded via the load() function...
data_lv.onLoad = function ()
{
// Just tracing out whatever I want to say here...
trace("Done loading text file...")
// Once the data has been loaded, it will be automatically
// embedded into the LoadVars() instance, data_lv in this case...
// So, the variable name that you have specified in the text file, MainText,
// is newly created and assigned into it, data_lv.MainText...
trace("MainText = " + data_lv.MainText);
trace("If you have a text field with the instance name");
trace("set to Main Text as well...");
// Assigning the data to the text field on the _level0...
_level0.MainText.text = data_lv.MainText;
}
// Actual command that invokes loading...
data_lv.load("http://solutions.idirectweb.com/thing.txt");Check out the Flash ActionScript Dictionary for more details... ;)

ecks
06-07-2003, 04:22 AM
thanks, now one last thing, how would i go about refreshing it before it grabs the data? cause if i update the text file, it dont change on the flash until i view the text file in internet explorer

CyanBlue
06-07-2003, 10:36 PM
Howdy...

Change this line...

data_lv.load("http://solutions.idirectweb.com/thing.txt");

to be this...

data_lv.load("http://solutions.idirectweb.com/thing.txt?uniqueID=" + getTimer());

and see if that does the job for you and let me know... ;)