Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Flash Onrollover Function

Posted on 2004-09-16
3
Medium Priority
?
583 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
Suggested Courses

609 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