Welcome, Guest. Please login or register.
Did you miss your activation email?
02/08/12, 14:31
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  change text color on rollover from dynamic text
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: change text color on rollover from dynamic text  (Read 5321 times)
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« on: 02/09/09, 21:49 »

I have file that pulls data from mysql with php into a dynamically created text field. Everything works great, the data is getting place properly... the buttons are active but I want the color of text the to change on roll over and that is where I am getting stuck.... any ideas?

Code:
System.useCodepage = true;
myData = new LoadVars();
myData.load("heights.php?"+Math.random());
myData.ref = this;
myData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
this.ref.clip = createEmptyMovieClip("clik", 100);
this.ref.clip.createTextField(["color1"+i], 3, 300, 300, 100, 20);
this.ref.clip["color1"+i].selectable = false;
this.ref.clip["color1"+i].textColor = 0x000000;
this.ref.clip["color1"+i].text = this["color"+i];
this.ref.clip.onRelease = function() {
trace("click");
};
this.ref.clip.onRollOver = function() {
trace(clip.color1);
this.ref.clip["color1"+i].textColor = 0x000000;
};
this.ref.clip.onRollOut = function() {
this.ref.clip.color1.textColor = 0xff0000;
};
// load title text
// load color 1 text
}
} else {
trace("Error loading data");
}
};


Thanks in advanced.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #1 on: 02/10/09, 06:14 »

Use a TextFormat object to apply the color to your text

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #2 on: 02/10/09, 13:56 »

Thank you.

I have implemented TextFormat but it is still not working...

Code:
System.useCodepage = true;
myData = new LoadVars();
myData.load("heights.php?"+Math.random());
myData.ref = this;
myData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
this.ref.clip = createEmptyMovieClip("clik", 1);
this.ref.clip.createTextField(["color1"+i], 1, 300, 300, 100, 20);
this.ref.clip["color1"+i].text = this["color"+i];
var myFormat:TextFormat = new TextFormat();
myFormat.align = "center";
myFormat.font = "Arial Bold";
myFormat.size = 16;
myFormat.color = 0xFFF000;
this.ref.clip["color1"+i].textBox.embedFonts = true;
this.ref.clip["color1"+i].textBox.selectable = false;
this.ref.clip["color1"+i].textBox.antiAliasType = "advanced";
var myOverFormat:TextFormat = new TextFormat();
myOverFormat.align = "center";
myOverFormat.font = "Arial Bold";
myOverFormat.size = 10;
myOverFormat.color = 0xFF0000;
this.ref.clip["color1"+i].setTextFormat(myFormat);
clik.onRelease = function() {
trace("click");
};
this.ref.clip.onRollOut = function() {
this.ref.clip["color1"+i].setTextFormat(myOverFormat);
trace("RollOver");
};
this.ref.clip.onRollOut = function() {
this.ref.clip["color1"+i].setTextFormat(myFormat);
trace("RollOut");
};
}
} else {
trace("Error loading data");
}
};

Cannot see where I am going wrong...
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #3 on: 02/10/09, 14:32 »

Since you're inside a loop, i is overwrited each time and keeps just the last value. Copy the variable into the MC timeline, something like this

this.ref.clip.nr i
this
.ref.clip.onRollOut = function() {
	
this.ref.clip["color1"+this.nr].setTextFormat(myOverFormat);
};
this.ref.clip.onRollOut = function() {
	
this.ref.clip["color1"+this.nr].setTextFormat(myFormat);
};

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #4 on: 02/18/09, 19:40 »

Thank you!!!
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!