473,788 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global MouseEvents...

rrocket
116 New Member
Is there a way to encompass all buttons/movie clips in the rollover function instead of writing them out for everyone you plan to use on a page?

Something like this:
Expand|Select|Wrap|Line Numbers
  1. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OVER, TabRollOver);
  2. function TabRollOver(event:MouseEvent):void {
  3.     this.name.alpha = .5;
  4. }
  5. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OUT,TabRollOut);
  6. function TabRollOut(event:MouseEvent):void {
  7.     this.alpha = 1;
  8.     }
Instead of having to do it this way:
Expand|Select|Wrap|Line Numbers
  1. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OVER, TabRollOver);
  2. function TabRollOver(event:MouseEvent):void {
  3.         AvailableLoads_mc.alpha = .5;
  4.  
  5.  
  6. }
  7. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OUT,TabRollOut);
  8. function TabRollOut(event:MouseEvent):void {
  9.         AvailableLoads_mc.alpha = 1;
  10. }
In that case I would only have to write out the initial line to call the function instead of recreating functions for each individual part even if they all do the same thing.
Oct 31 '07 #1
3 1915
xNephilimx
213 Recognized Expert New Member
Hi rrocket.
What you can do is name the buttons with a prefix name and a correlative number, so you can add the event listeners with a for, like this:

Expand|Select|Wrap|Line Numbers
  1. /*
  2. suppose you have the buttons b1, b2, b3 and b4
  3. */
  4.  
  5. for(var i:uint = 1; i < 5; i++) {
  6.     var b:DisplayObject = this.getChildByName('b'+i);
  7.     b.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
  8.     b.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
  9. }
  10.  
  11. function onRollOver(e:MouseEvent):void {
  12.     e.target.alpha = 0.5;
  13. }
  14.  
  15. function onRollOut(e:MouseEvent):void {
  16.     e.target.alpha = 1;
  17. }
  18.  
  19.  
As you can see, the event holds it's target (that in this case is the button that recieved the event) so you can access the event's current target by e.target then access any property or method the target has.

Best regards,
The_Nephilim

Is there a way to encompass all buttons/movie clips in the rollover function instead of writing them out for everyone you plan to use on a page?

Something like this:
Expand|Select|Wrap|Line Numbers
  1. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OVER, TabRollOver);
  2. function TabRollOver(event:MouseEvent):void {
  3.     this.name.alpha = .5;
  4. }
  5. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OUT,TabRollOut);
  6. function TabRollOut(event:MouseEvent):void {
  7.     this.alpha = 1;
  8.     }
Instead of having to do it this way:
Expand|Select|Wrap|Line Numbers
  1. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OVER, TabRollOver);
  2. function TabRollOver(event:MouseEvent):void {
  3.         AvailableLoads_mc.alpha = .5;
  4.  
  5.  
  6. }
  7. AvailableLoads_mc.addEventListener(MouseEvent.ROLL_OUT,TabRollOut);
  8. function TabRollOut(event:MouseEvent):void {
  9.         AvailableLoads_mc.alpha = 1;
  10. }
In that case I would only have to write out the initial line to call the function instead of recreating functions for each individual part even if they all do the same thing.
Nov 2 '07 #2
rsdev
149 New Member
Hi,

I would write a class that extends the MovieClip class then in the library for each movieclip that you want to use the function tick to enable runtime actionscript and enter the path to your class.

here's an example:

class as.MyMovieClipC lass extends MovieClip
{
//write your functions here
}

then in the movieclip linkage - as.MyMovieClipC lass

Then save the class in the source directory in a folder named "as".

This is how I work in AS 2.0 to create OOP app's.
Nov 4 '07 #3
xNephilimx
213 Recognized Expert New Member
That's a good one too. But it's more suitable for a big app, and extending with really usable and cool features, all depends on the project.
In AS3 though it's a little difference, but I don't know about flash, I just use AS3 with Flex, and flash tends to ease things a little when coming to this kind of stuff.

Best regards,
The_Nephilim

Hi,

I would write a class that extends the MovieClip class then in the library for each movieclip that you want to use the function tick to enable runtime actionscript and enter the path to your class.

here's an example:

class as.MyMovieClipC lass extends MovieClip
{
//write your functions here
}

then in the movieclip linkage - as.MyMovieClipC lass

Then save the class in the source directory in a folder named "as".

This is how I work in AS 2.0 to create OOP app's.
Nov 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
102757
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions> <instructions> def bar: <instructions>
1
2231
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
7
2689
by: Lyn | last post by:
Hi and Season's Greetings to all. I have a question regarding the use of a qualifier word "Global". I cannot find any reference to this in Access help, nor in books or on the Internet. "Global" seems to be recognised by Access in at least three cases:- 1) "Global Const". Recently someone in this group helped me resolve a problem, and it involved the use of a Global Const. By Googling "Global Const", I got plenty of hits -- but they...
33
3052
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
10
6771
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what that means and all, but what I'm wondering is what's the best way around it? Say, for example, I want a function that takes a username and a password and returns true or false if it's a successful login, and I want any page or usercontrol in the...
9
8660
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang Su Gatlin, casual mention was made about using static variables as an alternative to using global variables. This caused me to think of the following: '-----Begin module code
3
2774
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Defining_Functions doesn't actually give any insight.
8
13208
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project compiles & runs fine locally, but when I copy to the production machine, I get this error: Parser Error Message: Could not load type 'Global'. Source Error: Line 1: <%@ Application Codebehind="Global.asax.vb" Inherits="Global" %> Source...
15
2575
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the Global class. Note: I use these shared variables for read only values that are set at application start. It would appear the 2.0 doesn't like you to use shared variables in the global class. How do I convert my 1.1 applications to 2.0 without...
1
29383
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.