Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Data inside the rollover state of a button? 1

Status
Not open for further replies.

Kirderf

Technical User
Oct 4, 2000
183
0
0
US
I have a panoramic store that:
1. the user can rollover the pricetag (a button) and
2. have the price, name, category and html link of the item display inside the rollover state of the button.

Is there a way to pull that data into a button using the instance name as a variable? I have a similar button for each tag and need the data to be different for each item.

Is this something that anyone has attempted?



I'd gladly pay you on Thursday
for a hamburger today!
 
Does anyone know how can I make the instance name of a movie clip a variable?

Thank you.

I'd gladly pay you on Thursday
for a hamburger today!
 
Thanks a lot Kenneth for your help.
for example:
Button1 (which is actually movieclips with on(rollOver)
Instance1 of button1
Instance2 of button1
Instance3 of button1

So is there a way to grab the instance name of the button
and use it inside another line of code?

example:
{(grab instance name of button that is rolled over & put it here.display_mov.dynamic_txt.text = this.matchingInstanceName;
};


I'd gladly pay you on Thursday
for a hamburger today!
 
If I HAVE TO use "on(rollOver)" then it would be:
Code:
// assuming your button and "display_mov" are on the same timeline
on (rollOver) {
	this._parent.display_mov.dynamic_txt.text = this._name;
}

Kenneth Kawamoto
 
is there a method for getting a movieclip instance name?"

Like getInstanceName or something like that?

Maybe that is what I should be asking.
Thanks again.

I'd gladly pay you on Thursday
for a hamburger today!
 
Everything works with one small glitch which I have exhausted all my options over.
I get an undefined for my output when I use this._name inside the function.

when I hardcode this.instanceName it works fine.

myData = new LoadVars();
myData.onLoad = function() {
trace (_name);
info.text =this._name;//returns "undefined"
};
myData.load("myText2.txt");


I'd gladly pay you on Thursday
for a hamburger today!
 
In this bit of your code:
Code:
myData.onLoad = function() {
   trace (_name);
   info.text =this._name;
};
you're trying to get the _name of myData, which is a LoadVars Class instance. LoadVars has no "_name" so you get undefined. "_name" property is for MovieClip, Button, TextField and Video Classes only.

Kenneth Kawamoto
 
So how can I get the name of the movieclip and place it into the code without hardcoding it?

myData.onLoad = function() {
trace (_name);
info.text =this.hardcodedName;//this works
};

I'd gladly pay you on Thursday
for a hamburger today!
 
Even when I put a variable outside the MyDate fuction I can not pull the information in like I would if it was hardcoded.
//my full code
var i:String=_name;
myData = new LoadVars();
myData.onLoad = function() {
trace (_name);
info.text =this.i;
};
myData.load("myText2.txt");
(this code is in the movieclip called mc_one. When I put the line:
info.text = this.mc_one;
I get exactly the output I need.

See my problem? Sorry to be such a pain, but...its killing my last brain cell.

I'd gladly pay you on Thursday
for a hamburger today!
 
Code:
//Timeline of "mc_one"
myData = new LoadVars();
myData.parent = this;
myData.onLoad = function() {
	trace(this.parent._name); // "mc_one"
	this.parent.info.text = this.parent._name; // "mc_one"
};
myData.load("myText2.txt");

Kenneth Kawamoto
 
Sorry to butt in Kenneth

One solutiom - untested


myData = new LoadVars();
myData.parent = this;
myData.onLoad = function() {
switch (this.parent._name) {
case 'mc_one':
this.parent.info.text = this.mc_one;
break;
case 'mc_two':
this.parent.info.text = this.mc_two;
break;
default:
};
myData.load("myText2.txt");
switch (this.parent._name) {
 
I finally understood what you wanted:
Code:
myData = new LoadVars();
myData.parent = this;
myData.onLoad = function() {
	this.parent.info.text = this[this.parent._name];
};
myData.load("myText.txt");
Important: remove "Var:" from the TextField.

However, this is not the most efficient way to do this thing - you're creating LoadVars Object again and again on every rollover and loading the text file again and again. Totally unnecessary. But that's another matter...

Kenneth Kawamoto
 
That is exactly what I was trying to make happen. I have never pulled data in from a database, so the text file solution was all I could imagine working at this point.

I would be open for any suggestions for pulling in data a better way. I have tried a few tutorials, but to no avail. Thank you so much for helping.

Here is my project to date:

Any other suggestions or points to tutorials on this would be great. I will learn this if it mames me.

I'd gladly pay you on Thursday
for a hamburger today!
 
I would suggest to load the data at the beginning of the movie at _root timeline, then control everything from _root. You need to load the data only once. It's not a good idea to load data on each rollover.

Kenneth Kawamoto
 
Can I help you on anything before I ask another question?
I have run into another snag putting this one deeper into another movieclip.


I'd gladly pay you on Thursday
for a hamburger today!
 
Oh, I see you posted. Thanks for you help(again). I am in a little above my head on how to store the data and retrieve it. I thought I would be able to manipulate everything once i got it to work, but it is not that easy for me. My biggest problem is with targeting and displaying the data. I am okay with targeting movie clips.

I'd gladly pay you on Thursday
for a hamburger today!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top