Help - Search - Members - Calendar
Full Version: Flash Actionscripting
Zymic Webmaster Forums > Web Design & Development > Graphic Design > Animation (Flash, GIFs, etc)
akila
//how can I transform these MovieClips into Buttons dynamically
//so I wont be coding them 1 by 1 and reduce length of my script and time for editing?thanks
//pre-conditions: 100 MovieClips on the stage with an instance names of mc_bbg1, mc_bbg2, and so on..
// each MovieClip has 2 states a vector shape with white and Gray fill


for (var i:Number = 1; i<101; i++) {
var instance_name = ("mc_bbg"+i);
trace(instance_name);
instance_name.onRollOver = function() {
instance_name.gotoAndStop("on");
//trace("Hit!");
};
instance_name.onRollOut = function() {
instance_name.gotoAndStop("out");
};
instance_name.onRelease = function() {
instance_name.gotoAndStop("out");
};
}


//I also tried this code: "mc_mobbg"+i.onRollOver = function().. but still did not work. thanks again.
bezz
QUOTE(akila @ Oct 5 2007, 06:57 AM) *
//how can I transform these MovieClips into Buttons dynamically
//so I wont be coding them 1 by 1 and reduce length of my script and time for editing?thanks
//pre-conditions: 100 MovieClips on the stage with an instance names of mc_bbg1, mc_bbg2, and so on..
// each MovieClip has 2 states a vector shape with white and Gray fill


for (var i:Number = 1; i<101; i++) {
var instance_name = ("mc_bbg"+i);
trace(instance_name);
instance_name.onRollOver = function() {
instance_name.gotoAndStop("on");
//trace("Hit!");
};
instance_name.onRollOut = function() {
instance_name.gotoAndStop("out");
};
instance_name.onRelease = function() {
instance_name.gotoAndStop("out");
};
}


//I also tried this code: "mc_mobbg"+i.onRollOver = function().. but still did not work. thanks again.

If each movie clip is the same thing, you can just have one copy of it in the library (make sure you check export for actionscript and give it a name) and use attachMovie() to duplicate the movie clip. Place the actionscript inside of the movieclip.
See this example:
http://www.bezzmedia.com/swfspot/tutorials...ating_an_Object
XyberForce
Uh...I think this is in the wrong thread, you see this is Graphic design. Anyways, Pretty much what Bezz said, but I wouldn't recommend converting them to buttons unless it's more convenient, otherwise it will be unneeded coding/hassle.
akila
QUOTE(XyberForce @ Oct 5 2007, 10:34 PM) *
Uh...I think this is in the wrong thread, you see this is Graphic design. Anyways, Pretty much what Bezz said, but I wouldn't recommend converting them to buttons unless it's more convenient, otherwise it will be unneeded coding/hassle.


ooops... Sorry I'm confused where I would post this thread but thankz anyway I'll be checkin' the link you've posted and try your suggestion. Ill put some animation on the states which I know buttons wouldn't offer this feat.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.