00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

onLoad events for runtime MCs

301 Views | 4 Replies
New Topic Respond to this Topic

onLoad events for runtime MCs 2006-08-08 19:26:46


I'll explain this as best as I can.

I am using a list of data as a guide to constructing a level. My engine cycles through the list and attaches movieclips identified by the list. The movieclip symbols fall into two categories, ones that follow standard initialization procedure after they've been attached and those with unique initialization procedure. The problem is, in order to recognize that the movieclip has unique procedures and to know what those procedures are, the movieclip has to have variables and functions declared instantly. I can't use onClipEvent(load) because they are runtime mcs and declarations on the first frame of the mc don't take affect until the next frame. Any ideas on how I can get variables and functions to get initialized as soon as the movieclip is attached?

I want it to work like this:

_root.attachMovie("theMC","MC"+i",depth);
if(_root["MC"+i].standard == true) {
//standard functions;
} else {
_root["MC"+i].uniqueFunction();
}

Response to onLoad events for runtime MCs 2006-08-08 19:30:41


A few words of advice:

When you attach a movieclip, THATS your onLoad event. So, for instance,

if(Key.isDown(Key.SPACE)){
_root.attachMovie(blah, blah, blah)
_root[blah+i].var1=true;
_root[blah+i].var2=7;
}

And so forth. However, if you wanna be sure, you can ALWAYS do.

_root[blah+i].onLoad = function(){
//vars are stored here;
}

Response to onLoad events for runtime MCs 2006-08-08 19:35:20


The problem is that it isn't unique to the instance, it's unique to the symbol in the library. Example: Every instance of chair is going to have the same startup procedure that is different from the startup procedure of table.

Response to onLoad events for runtime MCs 2006-08-08 19:55:44


you could still use onLoad
like
_root[mc+i].onLoad= function() {
whatever you want to do;
}


BBS Signature

Response to onLoad events for runtime MCs 2006-08-08 20:15:11


At 8/8/06 07:35 PM, Fat_Lifeguard wrote: The problem is that it isn't unique to the instance, it's unique to the symbol in the library. Example: Every instance of chair is going to have the same startup procedure that is different from the startup procedure of table.

I know, but do both table and chair have an instance name that is "chair"? if they dont, ive already proven a solution. Otherwise, you could store all the instance names in an array, and run and onLoad for that.