I am trying to write a function to encompass the function and lengthy image loading script below....
but its troublesome.
As it stands it seems the code that is written first overides that which comes second, whichever way i put it, one half is nulled by the other...
any suggestions?
Hmmm..
That looks good !
I don't fully understand it and so as it doesn't work without fiddling... could you tell me what is the "p" bit!
(p = r.split("\r\n")
I've not seen the rsplit thing before.
does that split the function (r), (or fab.txt), between its commas or something along those lines ?
I have at the moment a text box on the stage called "WBfabricstext" and an empty movie clip called "loadit_mc" int which pics and text are loaded...... Are they now redundant with this script?
Any tips on editing - greatly appreciated as i'm not entirely sure what to change..... how this effects the other scripted function. i presume from reading through this new script its made all the old stuff redundant, but the pics are not appearing.
that code works without anything else, just open a new fla, paste it in the frame actions of the first frame, publish, close
code:
m = new LoadVars();
m.load("fab.txt");
m.onData = function(r) {
p = r.split("\r\n");
r and p are both arbitrary; the data recieved from the LoadVars is r (because of function(r)); we then take that and use the split command to turn it into an array of objects, with one 'cut' each time it encounters a carriage return (\r) or a end line (\n). each bit before or after becomes a distince object (an 'element' in an array) and assigned a sequential value based on order encountered
code:
for (var i = 0; i<p.length; i++) {
for as many times as there are elements in the new array, do this stuff:
This is all getting a bit above me!
i cant get my thoughts around the method you are using....
my copy has no breaks and is seporated into text files according to the button numbers. named; fab1.txt, fab2.txt......etc.
i wish to load jpegs into the mc on stage called "loadit_mc" and add to the following to do so.... if possible???
code:
function lv(id) {
trace("calling text file #" + id);
this["txtVars" + id] = new LoadVars();
this["txtVars" + id].load("../flashtestupdater/fab" + id + ".txt");
this["txtVars" + id].onLoad = function(success) {
if(success) {
trace("this.textfilevar=" + this.textfilevar);
WBfabricstext.text = this.textfilevar;
the preceding 'this' - or preceding instance name - means replace the referenced movieclip with the loaded file. this is an example of the loadMovie method.
if you wish to specify a target, you use the loadMovie function
code:
loadMovie("filename.jpg", targetmc);
but even if you did do that, it wouldnt work as is because you keep loading the movie into the same target clip
code:
this.loadMovie("images/WBfolio/folioWB"+ id +".jpg", loadit_mc);
keeps replacing loadit_mc over and over. try changing it to this
code:
this.loadit_mc.createEmptyMovieClip("jpg"+id, id);
this.loadit_mc["jpg"+id].loadMovie("images/WBfolio/folioWB"+ id +".jpg");
I have made it look for image 17 of 16 ! using the above, or similar, but cant fathom the identity thing for finding the button number and passing it to the load movie call.....?
before - and as posted, but this seems not to pick up the "id" property from the function. Therefore it loads, or attempts to load, WBfab.jpg on every call, ie from all buttons. No number value is added to the call.
odd!
ok you owe me lots of money. i spent 30 minutes thinking i thought i had smoked too much methamphetamine this morning; those are progressive jpegs - flash won't load them. resave as non progressive, and use the code at the end of this post (just delete everything in the frame as it is now). here are some problems:
your paths were wrong. they're corrected below.
you're assigning each button a variable "id" - which is attached to itself and fixed; common and good practice when you want to give mcs produced via loop a unique fingerprint.
code:
for (var i = 1; i<=numButs; i++) {
this["fabbut"+i].id = i;
however, in your function you also named the argument "id"
code:
function lv(id) {
- so you, me and the flash player are all wondering what id we're supposed to use. then, inside the LoadVars statement block (anything between curly braces), 'this' now means the LoadVars data. anyhow just paste this in and resave the jpegs and you'll be ok.
code:
function lv(id) {
this["txtVars"+id] = new LoadVars();
this["txtVars"+id].load("flashtestupdater/fab"+id+".txt");
this["txtVars"+id].onLoad = function(success) {
if (success) {
WBfabricstext.text = this.textfilevar;
loadit_mc.loadMovie("images/WBfabrics/WBfab"+id+".jpg");
}
};
}
numButs = 16;
for (var i = 1; i<=numButs; i++) {
this["fabbut"+i]._id = i;
this["fabbut"+i].onRelease = function() {
lv(this._id);
};
}
F....udge
I didn't spot that, obviously.
wot a first class ..... nit
I did forget about the paths, but i've a couple of copies on the go and they reside in different places for reasons i cant remember i've been bashing at this page for so long..... but they at least are something i can get my head around!
Think bashing my head with a blunt object will be this evenings entertainment.