Imagine a .fla with two symbols in it,one called "box" and one called "circle".The symbols are not on the Stage but there Linkage is set for Export.
What i want is to use LoadVars to import a .txt file called objects.txt which will set the symbols to the following x and y coordinates.
"box",50,100,
"circle",200,250,
1.What ActionScript would do this,keeping it simple and minimal with no trace functions and user friendly LoadVars names.
2.What form would the .txt file take.
Alan
I imagine two library symbols one called "box" and one called "circle".They are not on the Stage but the Linkage is set for them to export.
I want to use LoadVars to load in a .txt file called objects.txt which sets the two symbols to the following x and y locations
"box" 100,50 and "circle" 200,150
1.What ActionScript would achieve this,keeping it very simple
2.What would the objects.txt be like
Can Anyone help
Alan
Hello all you Action Script Boffins
I need you to help me on a LoadVars.
Imagine two Library Symbols that are not on the Stage but in the Library
With both of there Linkages Set to Export with the Movie.
One is called "box" and the other is called "circle".
What I want is to create a LoadVars that imports a .txt file called
"objects".txt that contains the following x and y co-ordinates of
the two Symbols
"box" 200,250
"circle" 100,150
1.What would the ActionScript need to be like keeping it Simple and Minimal
With no Trace Functions or Confusing Names
2.What would the.txt file be like including all the correct punctuation's.
Can you Help Alan
in Flash --
bring your movieclips to Stage with attachMovie(); // see help files
load text file and position clips -
Code:
lv = new LoadVars(); // create a loadvars object
lv.onLoad = function(){ // runs when all data has loaded
box._x = this.boxX*1; // all external variables are received
box._y = this.boxY*1; // as "strings", so <string*1> is used
circle._x = this.circX*1; // to convert "string" to number
circle._y = this.circY*1;
};
lv.load("coords.txt");
thank you for your help.I am in the local Library as i am not on the internet at home but i will try it out and let you know if it worked ,tomorrow.
Take Care
Alan
Hello all you Action Script Boffins
I need you to help me on a LoadVars Problem
Please imagine two Library Symbols that are not on the Stage but in the Library
With both of there Linkages Set to Export with the Movie.
One is called "box" and the other is called "circle".
What I want is to create a LoadVars Function that imports a .txt file called
"objects.txt", which holds the following x and y co-ordinates of
the two Symbols
"box" 200,250
"circle" 100,150
1.What would the ActionScript need to be like keeping it Simple and Minimal
With no Trace Functions or Confusing Names and the Script needs to be fully complete
As I have had replies that only give part of what I need and don’t work. No timewasters.
2.What would the "objects.txt" file be like including all the correct punctuation's.
Can Anyone Help Please
Alan
Hello all you Action Script Boffins
I need you to help me on a LoadVars Problem
Please imagine two Library Symbols that are not on the Stage but in the Library
With both of there Linkages Set to Export with the Movie.
One is called "box" and the other is called "circle".
What I want is to create a LoadVars Function that imports a .txt file called
"objects.txt", which holds the following x and y co-ordinates of
the two Symbols
"box" 200,250
"circle" 100,150
1.What would the ActionScript need to be like keeping it Simple and Minimal
With no Trace Functions or Confusing Names and the Script needs to be fully complete
As I have had replies that only give part of what I need and don’t work. No timewasters.
2.What would the "objects.txt" file be like including all the correct punctuation's.
Can Anyone Help Please
Alan
var obName:Array = new Array();
var xPos:Array = new Array();
var yPos:Array = new Array();
function loadData() {
var time:Date = new Date();
var sTime:String = ""+time.getFullYear()+time.getMonth()+time.getDate()+time.getHours()+time.getMinutes()+time.getSeconds()+time.getMilliseconds();
var vHolder:LoadVars = new LoadVars();
vHolder.onLoad = function(success:Boolean) {
if (success) {
loadFinnished(vHolder.dHolder);
delete vHolder;
} else {
loadFailed();
delete vHolder;
}
};
vHolder.load("objects.txt");
}
function loadFinnished(target:String) {
var sHolder:Array = target.split(",");
var j:Number = 0;
for (var i:Number = 0; i<sHolder.length; i++) {
obName[j] = sHolder[i];
i++;
xPos[j] = sHolder[i];
i++;
yPos[j] = sHolder[i];
}
delete j;
}
In the text file "objects.txt" you type this: &dHolder=box,200,250,circle,100,150. You have to type it like this, don't worry about the " marks because everything will be a string when it comes out. When you use the number it should work as numbers, if not then you do this: Number(xPos[0]); and this will return 200 as a number otherwise xPos[0] will be a string.
This should work. After executing the script it should return each variable in the different arrays of obName, xPos and yPos.
Sorry did not mean to upset anyone by saying NO TIMEWASTERS but i have come into contact with people who tend not to really answer your question and include lots of Functions that are copmpletly irrelevant to the problem.
I have been trying to resolve this for a few weeks now and i find it frustrating to have script missing or trace and time functions added together with misleading Names and Punctuations.
I also feel that it is often the people who help others alot who sometimes get fed up with people taking from them all of the time so they end up confusing people instead.Well the answer is simple.Yes it is a voluntary site and noone really has to help if they do not want to but if you do decide to offer help than dont get resentful and do it with a good spirit. Cheers
Hello all you Action Script Boffins
I need you to help me on a LoadVars Problem
Please imagine two Library Symbols that are not on the Stage but in the Library
With both of there Linkages Set to Export with the Movie.
One is called "box" and the other is called "circle".
What I want is to create a LoadVars Function that imports a .txt file called
"objects.txt", which holds the following x and y co-ordinates of
the two Symbols
"box" 200,250
"circle" 100,150
1.What would the ActionScript need to be like keeping it Simple and Minimal
With no Trace Functions or Confusing Names and the Script needs to be fully complete
As I have had replies that only give part of what I need and don’t work. No timewasters.
2.What would the "objects.txt" file be like including all the correct punctuation's.
Can Anyone Help Please
I HAVE ATTACHED THE.FLA THAT I AM TRYING TO MODIFY
Alan
CAN ANYONE ADAPT THE ATTACHED .FLA SO THAT THE OBJECTS iN THE CREATE WORLD FUNCTION ARE LOADED IN VIA A .txt called "objects.txt"
insted of hand coded in
Watch your attitude. The helps docs installed with flash explain exactly how to do it. The fact that you didn't list any specif confusions with that information, one would assume you failed to try and teach yourself first. Don't get mad at anyone who hasn't gone the extra mile if you haven't either. Btw, your answer is below.
You'd be better off using load() on an XML object. It's more structured than a url string and you don't have to parse it once loaded.
An XML load works pretty much like a LoadVars.load
You create an XML object, set it's ignoreWhite property to true (this helps flash skip over the spaces and hard returns between nodes), write an onLoad handling function, then load the xml file.
The key is that you are loading the data into the XML object. This can make reading your values confusing. Just keep scope in mind. From within the onLoad function, your scope is already relative to the XML object (since your running one of it's built in functions) so to refer to your data you use the this keyword (this.childNodes[0].firstChild[0]). From anywhere else in your code, you need to refer to the XML object itself (myXML.childNoded[0].firstChild[0]).
You dig down into and XML object with sort of a mix between dot notation and array references. box and circle are part of the immediate childNodes array. Each of those childNodes has childNodes. So to refer to the nodeValue of the first childNode of the first childNode you say the XML object name followed by the xml notation:
trace(myXML.childNodes[0].childNodes[0].firstChild.nodeValue); //this is like saying "myXML.box.xPosition.innerData.value"
would output 200
Code:
//create the XML object
myXML = new XML();
//tell it to ignore whitespace
myXML.ignoreWhite = true;
//set up a function to be called when the data is either fully loaded or
//if there is an error (ie. server down, bad path)
myXML.onLoad = function(success){
if(success){
trace("My loaded XML is :\n"+this);
trace("My box X value is :"+this.childNodes[0].childNodes[0].firstChild.nodeValue);
}else{
trace("There was an error.");
}
}
//now simply load the data
myXML.load("xmlData.xml");
//It's important to have onLoad() tell the flash movie it can start using the data
//Otherwise you could try to refer to data that hasnt fully loaded yet.
Please, you need to change the way you ask questions and deal with the answers. What I see here is a total lack of respect for those who tried to help you.
I know that you've already admitted a somewhat less correct attitude on your part but that's not the only problem.
You've posted the same question(s) - now and in the past - over and over in this and other forums, which clearly goes against the forum rules.
I highly recommend that you read the Forum Guidelines and comply with them so that you can help and be helped correctly. Like this everybody gets happy.
yes you are all right .I am not on the internet at home and use my local library facillities so i have to accept that i have not had the opprtunity to be as fastideous on my ActionScripting as in the past.However give me a break guys i am not stupid and i know a user friendly script when i see one.
I have decided not to drive any of you crazy any more and i shall try to resolve the problem myself
thanks for your time Alan
And i hope i have made you all feel Guilty
Excuse me for breathing but ever since i joined this website you have been trying to rail-road me into an argument .I thought i would let it pass as i have other things on my mind at the moment but you hvave finally won. I am reall ypissed off. I am newish to ActionScripting and i will be the first to appologise for certain things i have neglected in the past with regards to my Scripting but i really do not need you to act as my conscience.
The reaon i did not reply to you last time was because you did not answer my question correctly and i felt you were wasting my time.That is not the first time it has happened either. Lets not keep in touch
Excuse me for breathing but ever since i joined this website you have been trying to rail-road me into an argument .I thought i would let it pass as i have other things on my mind at the moment but you hvave finally won. I am reall ypissed off. I am newish to ActionScripting and i will be the first to appologise for certain things i have neglected in the past with regards to my Scripting but i really do not need you to act as my conscience.
The reaon i did not reply to you last time was because you did not answer my question correctly and i felt you were wasting my time.That is not the first time it has happened either. Lets not keep in touch
I wouldn't tolerate such attitude even if someone was paying me to program for them, not just trying to help! It's utterly rude to say to someone that they are wasting your time, when they are trying to help! More of it, no one here minds your lack of ActionScript knowledge .. but your lack of politeness, friendliness and good manners!
Personally I wouldn't even move my little finger to help you... not just because you are lazy and want someone else to do your entire work and you get everything "Simple and Minimal With no Trace Functions or Confusing Names and the Script needs to be fully complete" without making any effort ..but because I don't like you and I don't like the idea to WASTE my time on you.
Please, try to understand my words .. I am not saying this to offend you but trying to cause a change in your attitude and the way you communicate to this wonderful and friendly community.
Best Regards
Stan
while (2+2 == 4) {
drink ("bourbon");
}
gotoAndStop("bed");
Now Lets all have a reality check.I am a great Sponge ,i will be the first to admit it and i aint no different from anyone else.But i am also user friendly and i am polite and tolerant.I have been trying for months to get an answer to my Question and because of my nature I find it difficult to continue until I solve one step at a time.So i have arrived at an impasse.I dont feel i am being unreasonable to ask for ActionScript with NO FRILLS attached to it.
I also should point out that I do not ask many Questions on this Website as i believe that the only real person best equipped to teach is yourself.