View Full Version : How do I control links in flash mx...
DeadFrog
05-18-2005, 07:12 PM
I have 5 empty mc's that load up jpegs...
I was wondering if anybody out there knew if there is a way to make those mc's links but through a text file or through actionscript, as the links will be changing all the time I don't want to have to go into Flash and change button properties all the time I'd rather do it dynamically through Actionscript or a loaded text file...did that make sense?
Also does anyone know how to add a listener to a movie clip (I think they are called listeners) I have a mc that scales it's width on rollOver but I want it to stay there and I can manage that by not adding a rollOut function but if I accidentally rollOver the mc again it'll play the rollOver action which I don't want it to do.
Thanks in advanced.
hupsohl
05-18-2005, 11:29 PM
For your second question, you can solve the rollover issue by adding a variable. I'm guessing that when you rollover, it plays the MC's timeline and stops on the last frame (or something similar)? If so, add a variable to the first frame of the main timeline, like
var isOver;
then on the last frame of your MC's timeline (where it stops) add
_root.isOver = true;
For your rollover code, you could do something like
on (rollOver) {
if (_root.isOver != true) {
this.gotoAndPlay(2);
}
}
When you rollover the MC, it will check to see if the variable is true or not. If it is true, it won't do anything. If it is false, it will play the rollover animation (this is assuming your MC has a stop() action on the first frame, and that frame 2 begins the animation).
Edit to include stuff about your first question:
For your first question, you can use a .txt file with the links that you would change, that way you wouldn't have to update the .swf. Make a .txt file, call it link.txt (for this example) and do your links like
&link1=http://www.URL.net
&link2=http://www.URL.com
Then in in the first frame of your timeline, put
myVars = new LoadVars();
myVars.load("link.txt");
myVars.onLoad = function(success) {
if (success) {
firstLink = this.link1;
secondLink = this.link2;
}
}
Then on your button, you can put
on (release) {
getURL(_root.firstLink, 0);
}
Change the firstLink to secondLink, etc for other buttons. When you need to change a link, just change it in the link.txt file for the appropriate button. Hope that helps.
DeadFrog
05-19-2005, 12:24 AM
Thank you very much...that helped...
DeadFrog
05-19-2005, 01:01 AM
Thank you so much for the help on the AS for this...
I tried your example and the rollOver to get the animation to stay still and it worked great but now I'm wondering how to get it to play back if I rollOver on a different button: So when that one is still and I rollOver somewhere else it causes the first button to play that animation back to it's normal state...?
I tried a few things and it kinda works but if I try and rollOver the mc twice it won't work the second time...
Thanks again, I really appreciate it.
DeadFrog
05-19-2005, 05:18 PM
Here is the .fla (zipped)
hupsohl
05-19-2005, 06:46 PM
I attached an example, I hope that's what you were looking for. I would have been finished sooner but work kept interrupting me ;)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.