Solved

Flash Onrollover Function

Posted on 2004-09-16
3
575 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

724 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