Hello, It is stated in various documents(marcomedia-press) that by defining button states in movieclips, it is possible to get button behaviour in movieclips. The states that can be defined are, " _up, _over, _down ". By adding any of these states as labels in movieclips, as with button states, this functionality/behaviour is automatically added to the movieclip. I do not get this to work unless I completely do the hand coding: adding stop() methods in the corresponding frames and program the on(..) event handlers to manouvre the program to the various frames. Can anybody tell me how to do this specifically with the STATES LABELING PRINCIPLE. Thanks
well, that's what you have to do. just because you have labelled frames won't make that movieclip act like a button. you need to attach actions to the movieclip: on(rollOver){ gotoAndPlay("rollover"); } on(press){ gotoAndPlay("down"); } on(release){ gotoAndPlay("up"); } on(rollOut){ gotoAndPlay("rollout"); }
frame#1 - stop(); - label _up frame#2 - label _over frame#3 - label _down drag to stage, give instance name - test add main timeline action - test.onPress=function(){ .. do stuff .. } the clip will now respond to rollOver/Out... as if it were a button. ( MX+) hth
I know that was my idea as well: manually coding does solve it. But at least you have to add a stop() at frame "up" otherwise still your movie clip runs through all frames again. I expect the "speciality" of the mentioned labeling having special meaning, why otherwise is this so specifically mentioned in macromedia's dictionary and " flash 2004 actionscript" books.
Bulls eye......so indeed there is special meaning to the labeling. Just in case, I tried to rename the labels by just adding an "x" after each labeltag. The frames were no longer visited like the button behaviour without the "x" addition. Thanks again
Jack gave the wright answer. Something went wrong with me identifying this in my previous postings.
there's no special meaning to the frame labels. you can call them anything you want, including adding an x at the end of the frame label, and that movieclip will still act like a button, as long as you reference the frame labels correctly.
there's no special meaning to the frame labels. you can call them anything you want, including adding an x at the end of the frame label, and that movieclip will still act like a button, as long as you reference the frame labels correctly.
Please try it. I have double checked it now adding the followoing code to the main timeline: test_mc.onPress=function(){ trace("pressed") }; test_mc.onRollOver=function(){trace("over")}; test_mc.onRelease=function(){trace("released")}; And well... this does work and creates the button behaviour in combination with the specific labeling. Changing the label name by adding the "x" does not give the clip button behaviour. I know it is not logical that this "extra" behaviour enters the scene, but it is just something special for this specific case. I wouldn't have know about it if I not read about this typical case in separate books which both did not elaborate enough for me to get the fully "howto". But that problem is solved now. Thanks for your reaction
if adding an "x" to the frame labels causes your movieclip to stop acting like a button it's because you didn't change to frame label references attached to your movieclip or made some other error. specifically, if you have frames labelled "upx","downx" and "overx" in the timeline of a movieclip that has an instance of mc1 on the _root timeline then the following code on the _root timeline will work perfectly well: mc1.onPress=function(){ this.gotoAndStop("downx"); } mc1.onRollOver=function(){ this.gotoAndStop("overx"); } mc1.onRollOut=function(){ this.gotoAndStop("upx");
Thank you for your response. Your code works indeed just as welI. I now have two perfect ways of having the movie clip behave like a button. Great response on this topic!
Don't see what you're looking for? Try a search.
|