Solved

Flash Onrollover Function

Posted on 2004-09-16
3
566 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

948 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