|
|
|
#1 |
|
Senior Member
Join Date: Jan 2003
Location: Nebraska
Posts: 440
|
For Loop and Array onPress Assignments
I have a script like this to assign a number of buttons to change a variable on rollover:
The problem I have is the scaleFactor array gets assigned to the variable named logoCount when you rollOver any of the move clips. So rolling over logo1 makes scaleFactor[logoCount]=true, but logoCount is irrelavant after this loop is done. I want it so when you rollOver logo1 then scaleFactor[1]=true and rolling over logo2 then scaleFactor[2]=true and so on. Anyone know a looping way to do this?
__________________
thecardchest - My full flash site. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
To answer your immediate question, you can create your own properties on buttons. I create a property called idx and use it to store the logoCount number.
Then, within the event handler, you can use this.property to refer to the thing you stored.
If it were me, I probably wouldn't store scaleFactor in a separate array, but would also assign scaleafactor to each individual button, just I'm doing with idx. I like to keep stuff associated with buttons or movieclips in the buttons or movieclips.
Last edited by jbum; 10-21-2004 at 06:13 PM. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2003
Location: Nebraska
Posts: 440
|
Oh yea duh, just a variable within the movie clip for each button. Thanks for the help man. I am actually just the opposite of you when it comes to buttons it seems. I like to keep all the events for buttons (and all code actually) in a seperate or root actionscript file so when changes need to be made to a bunch of things, I don't have to movie explore all over to find them.
__________________
thecardchest - My full flash site. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jan 2003
Location: Nebraska
Posts: 440
|
Or wait, I think I misread what you said wrong. By storing them in the buttons or clips, you meant in relative with your code, not actually in the actionscript for the thing?
__________________
thecardchest - My full flash site. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Yes, that's right.
I agree with you that it's best to keep all the actionscript in a single frame script so you don't go crazy having to find it. I just like to keep the variables associated with objects attached to those objects, rather than in separate data structures. It's an OOP thing... |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|