Solved

Flash Onrollover Function

Posted on 2004-09-16
3
564 Views
Last Modified: 2012-05-05
I am tring to get the text to change color on rollover.  However, the below function is not working as desired.  Ideally, I would like to loop through each movieclip to be able to create a rollover color for each.



for (i=0; i<3; i++) {
      _root.createEmptyMovieClip("menuName"+i, 600+i);
      eval("_root.menuName"+i).createTextField("recentBroadcast"+i+"_txt", 501+i, 435, 45+(i*17), 140, 20);
      eval("menuName"+i+".recentBroadcast"+i+"_txt").html = true;
      eval("menuName"+i+".recentBroadcast"+i+"_txt").htmlText = _"hello world";
      myFormat = new TextFormat();
      myFormat.color = 0x000000;
      myFormat.url = "www.yahoo.com";
      myFormat.font = "Arial";
      myFormat.bold = "true";
      eval("menuName"+i+".recentBroadcast"+i+"_txt").setTextFormat(myFormat);
}


this.menuName0.onRollover = function() {
      rollOverformat = new TextFormat();
      rollOverformat.color = 0xFFCE6C;
      this.recentBroadcast0_txt.setTextFormat(rollOverformat);
};





0
Comment
Question by:splendorx
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
muso120999 earned 125 total points
ID: 12074689
Hi, I've changed your code slightly, as you are using i to create the text field name, as they are unique within a numbered movieclip this is unnecessary.  I added the rollOut too!

for (i=0; i<3; i++) {
      _root.createEmptyMovieClip("menuName"+i, 600+i);
      _root["menuName"+i].createTextField("recentBroadcast_txt", 501+i, 435, 45+(i*17), 140, 20);
      _root["menuName"+i].recentBroadcast_txt.html = true;
      _root["menuName"+i].recentBroadcast_txt.htmlText = "hello world";
      myFormat = new TextFormat();
      myFormat.color = 0x000000;
      myFormat.url = "www.yahoo.com";
      myFormat.font = "Arial";
      myFormat.bold = "true";
      _root["menuName"+i].recentBroadcast_txt.setTextFormat(myFormat);
      _root["menuName"+i].onRollOver = function() {
            rollOverformat = new TextFormat();
            rollOverformat.color = 0xFFCE6C;
            this.recentBroadcast_txt.setTextFormat(rollOverformat);
      };
      _root["menuName"+i].onRollOut = function() {
            rollOverformat = new TextFormat();
            rollOverformat.color = 0x000000;
            this.recentBroadcast_txt.setTextFormat(rollOverformat);
      };
}
0
 
LVL 10

Expert Comment

by:muso120999
ID: 12074786
By the way, there isn't any particular reason that I took out the eval's other than I find it easier to read
0
 
LVL 1

Author Comment

by:splendorx
ID: 12074802
Again, Thanks for the help Muso!!!  Great work!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now