multiple movieclips, 3 functions with unique targets

This is a discussion on multiple movieclips, 3 functions with unique targets within the Macromedia Flash forums in Adobe Tools category; (cs3,as2) I was wondering if there's an easier way of getting these functions to work for about 150 different buttons? I just put three of the blocks of code in here to show you what it looks like across more than one. On the gotoAndStop actions, the name is a frame label on a seperate swf file. the name used everywhere else is an instance name on a dynamic textbox located inside a movieclip. All this script is located in an external .as file. Thanks so much for reading. aaronkotowski.fade.person.text = "Aaron Kotowski"; aaronkotowski.onRollOver = function() { gotoAndStop("aaronkotowski"); aaronkotowski.fade.person.textColor = ...

Go Back   Application Development Forum > Adobe Tools > Macromedia Flash

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-02-2008, 03:06 PM
convrgr
Guest
 
Default multiple movieclips, 3 functions with unique targets

(cs3,as2)
I was wondering if there's an easier way of getting these functions to work
for about 150 different buttons? I just put three of the blocks of code in here
to show you what it looks like across more than one. On the gotoAndStop
actions, the name is a frame label on a seperate swf file. the name used
everywhere else is an instance name on a dynamic textbox located inside a
movieclip. All this script is located in an external .as file. Thanks so much
for reading.


aaronkotowski.fade.person.text = "Aaron Kotowski";
aaronkotowski.onRollOver = function() {
gotoAndStop("aaronkotowski");
aaronkotowski.fade.person.textColor = 0x666666;
};
aaronkotowski.onRelease = function() {
getURL("http://www.aaronkotowski.com", "_blank");
};
aaronkotowski.onRollOut = function() {
aaronkotowski.fade.person.textColor = 0xffffff;
};

albertnormandin.fade.person.text = "Albert Normandin";
albertnormandin.onRollOver = function() {
gotoAndStop("albertnormandin");
albertnormandin.fade.person.textColor = 0x666666;
};
albertnormandin.onRelease = function() {
getURL("http://www.albertnormandin.com", "_blank");
};
albertnormandin.onRollOut = function() {
albertnormandin.fade.person.textColor = 0xffffff;
};

aliciarose.fade.person.text = "Alicia Rose";
aliciarose.onRollOver = function() {
gotoAndStop("aliciarose");
aaronkotowski.fade.person.textColor = 0x666666;
};
aliciarose.onRelease = function() {
getURL("http://www.aliciajrosephotography.com/", "_blank");
};
aliciarose.onRollOut = function() {
aliciarose.fade.person.textColor = 0xffffff;
};

Someone gave me this code below to try but it makes the button have the same
name over and over? What am I doing wrong?

myArray_array=[{mcName:"aaronkotowski",
url:"http://www.aaronkotowski.com"},{mcName:"albertnormandin",
url:"http://www.albertnormandin.com"},{mcName:"aliciarose",
url:"http://www.aliciajrosephotography.com"}];
for(var i=0; i<myArray_array.length; i++){
var myMc = this[myArray_array[i].mcName];
myMc.fade.person.text = "Alicia Rose";
myMc.myRoot = this;
myMc .index= i;
myMc.onRollOver = function() {
gotoAndStop(this.myRoot.myArray_array[this.index].mcName);
this.fade.person.textColor = 0x666666;
};
myMc.onRelease = function() {
getURL(this.myRoot.myArray_array[this.index].url, "_blank");
};
myMc.onRollOut = function() {
this.fade.person.textColor = 0xffffff;
};
}

Reply With Quote
  #2  
Old 10-03-2008, 11:09 AM
clbeech
Guest
 
Default Re: multiple movieclips, 3 functions with uniquetargets

the code looks... well... ok - but the line:

myMc.fade.person.text = "Alicia rose";

is the problem. this is assigning the same text to all instances, you can
change this by adding a new propertiy to each Object within the Array,
something like - mcText:"Alicia Rose", (differnet for each object of course)
and then use that prop to assign the field, similar to the other methods used
in there - eg.

myMc.fade.person.text = this[myArray_array[i].mcText];


Reply With Quote
  #3  
Old 10-06-2008, 09:16 AM
convrgr
Guest
 
Default Re: multiple movieclips, 3 functions with uniquetargets

myArray_array=[
{mcName:"aaronkotowski", mcText:"Aaron Kotowski",
url:"http://www.aaronkotowski.com"}

So when I add that extra mcText portion to the array, how do I go about
declaring the mcText, you said this,
myMc.fade.person.text = this[myArray_array.mcText];
but that seems to make the output undefined, so I must be not declaring it
correctly elsewhere...Thanks!

Reply With Quote
  #4  
Old 10-14-2008, 01:06 AM
clbeech
Guest
 
Default Re: multiple movieclips, 3 functions with uniquetargets

I'm sorry - I should have used the 'attach code' button - the line I used
contains an ' i ' variable used in the loop as the index value - this is also
the BB code for 'italics' in the forum post sooo.... it should have been:


myMc.fade.person.text = this[myArray_array[i].mcText];

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:11 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.