View Full Version : loadVars question
I once already asked this question but i guess I didn't make myself clear enough.
I have a picture gallery with about 50 items. When i roll over a picture i want description of it to appear in textfield. When i press on it i want to get text in 2 fields - Headline and bodyText.
I load text with loadvars. i could write every 50 items something like that
hedgehog.onRollOver = function() {
headLine.htmlText = loadVarsText.hedgehogHeadline;
};
and so on for 50 times .. and for RollOver, press , rollout etc. I guess there should be easier way to do this.
do i really have to write for each 50 buttons different RollOver, RollOut actions where i write which variable to pick from txt i loaded. Or is there way to use on every button same script and use some other script to detect which button was pressed and change text in textfield according to this?
CyanBlue
06-10-2003, 11:31 AM
Well... I guess it all depends on how you name all that movieclips and how you organize things...
For example...mc_arr = new Array("hedgehog", "whatever1", "whatever2" ... );
for (i = 0 ; i < mc_arr.length ; i++)
{
this[mc_arr[i]].onRollOver = function()
{
headLine.htmlText = loadVarsText[mc_arr[i] + "Headline"];
}
// same to the rollOut...
}???
wow! Thanx :) i guess i need something like that.
Arrays is a thing i don't understand .. but i give it a try.
Sorry to bother you again.
Tried it .. but why doesn't this work?
CyanBlue
06-10-2003, 01:12 PM
First of all, your code is not working because there is no code in the file... You might want to check it again... ;)
And, your text file... My textPad doesn't recognize anything in there... What language is it???
Well... That's not the point actuallly...
If you are loading something from the text file, it has to be this format...
Variable1=value for this variable blah blah&Variable2=value for the second variable and such and such...
You know what I mean??? Some variable name=some text that goes into the variable, and use '&' in between the variables as a divider...
text is mac format unicode i think
and inside it is :
foxHeadline=nice fox, isn't it?&horseHeadline=Grey horse&fishHeadline=a lovely shark&foxBodytext=Jabberwockies tickled one slightly speedy Klingon, although&horseBodytext=One botulism mostly easily tastes five putrid pawnbrokers&fishBodytext=Two mostly bourgeois bureaux towed the putrid Macintosh
It loads text in boxes on my computer at least. But when i click buttons it removes text.
CyanBlue
06-10-2003, 01:29 PM
Well... Anyhow, that is not readable in PC...
And that is not the point... Your FLA file is empty... ;)
OMG! :( the previous attachment really didn't work
CyanBlue
06-10-2003, 02:27 PM
Change your for loop to be like this... ;)for (i=0; i<mc_arr.length; i++) {
this[mc_arr[i]].num = i
this[mc_arr[i]].onPress = function() {
Headline.htmlText = loadVarsText[mc_arr[this.num] + "Headline"];
bodyText.htmlText = loadVarsText[mc_arr[this.num] + "BodyText"];
};
}Let me know if you have further question... :)
Thank you! Thank you ! Thank you ! Cyan! :) :) :)
You're a lifesaver!
I've been looking for this couple of weeks already!
mjewitt
02-12-2004, 01:26 AM
Hello all.
I came across Nier's inquiry because I have a similar question but have yet to find an answer in the search. I've checked several blogs to no avail. My question is as follows:
I'm trying to loop through the buttons (collection) on the stage and change the properties (change alpha) for all of the buttons at once when an event happens such as onRelease. I can hardcode it for each button but was hoping that there is a dynamic way to do it. How would you do this if the instance names are not all named similar with a number tacked on the end of it (e.g. mybutton1_btn)
I can get all of the names of my instances with this code:
[AS]var i;
for (i in this) {
if (this[i] instanceof Object) {
trace(i);
}
}[AS]
I can get the name but not whether it's a button or a movie, etc.
Any suggestions for this newbie?
Thanks in advance:
Mike J
CyanBlue
02-12-2004, 06:07 AM
Howdy, Mike... :)
I don't see why it is a similar question, but try this... The else statement does not guarantee that it is going to be the button instance, so I just named it 'other' for you to see...var i;
for (i in this)
{
if (this[i] instanceof Object)
{
if (this[i] instanceof MovieClip)
{
trace("MovieClip " + i);
}
else
{
trace("Others " + i);
}
}
}Hope it's not that cold in Chicago... :)
mjewitt
02-12-2004, 01:36 PM
Thanks CyanBlue (aka. Mr. 7481 Posts)!
I didn't realize you could do instanceof Button. I was under the impression that it was only instanceof Object. Well I know that now.
Thanks again!
Mike
P.S. It cold in Chicago... just not the -20 like a few weeks ago.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.