Be a Supporter!

Affect Instances Inside Instances?

  • 183 Views
  • 2 Replies
New Topic Respond to this Topic
Fatelogic
Fatelogic
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 13
Artist
Affect Instances Inside Instances? 2013-04-04 00:50:59 Reply

Hello gurus and mighty flash programmers of the forum... It's been a while since I was here, so I came today with a pretty strange question today (why not?).

Basically, as the title implies... I'm trying to find out a way (if there is one, I hope) to affect an instance INSIDE another instance (or more specifically, an instance INSIDE a symbol... sorry, I sort of mix them up, but listen to my question and you'll understand my point... I guess.)

Thing is as follows:

I'm developing (or at least trying to...) a very very alpha sort of ''Dress up'' game. I created the model of this girl as a symbol composed of many other symbols inside it (like frontal hair, eyes, shoulders, arms, etc.). The animation cycle is all fine and dandy, no problem with it.

Thing is that now I want to put that symbol (the ''girl'' symbol) in the main timeline, and add (into the main timeline) two buttons (two arrows, left and right) for the user to click in order to, for now, change her eyes color from ''blue'' to ''golden'' (I want it to work like this because I'll go on adding more options from which to choose, but this serves just right as a testing of the mechanic.)

The ''girl'' symbol, among all the other symbols she's composed of, has two ''sets of eyes'' overlaped, being the first set the ''blue eyes'' at a default alpha transparency of 1, and the second set, the ''golden eyes'', at a default transparency of 0. I named both instances of both sets of eyes ''ModelBlueEyes'' and ''ModelGoldenEyes'' respectively.

Once I put the ''girl'' (with those two declared instances INSIDE her) symbol into the timeline, I created two arrow buttons, naming their instances both ''EyeColorSelectorLeftArrow'' and ''EyeColorSelectorRightArrow'' (I know it's a lengthy name, but I like knowing which thing is which clear as day so... yeah...), and then proceeded to create a simple AS3 code for it to work (I already knew it wouldn't, but I wanted to give it a shot, just for the hell of it).

My actual code for those buttons stands like this:

EyeColorSelectorRightArrow.addEventListener(MouseEvent.CLICK , fl_ClickToChangeEyeColor01);

function fl_ClickToChangeEyeColor01(event:MouseEvent):void
{
if (actualeyecolorblue==true){
actualeyecolorgolden = true;
actualeyecolorblue = false;
ModelGoldenEyes.alpha = 1;
ModelBlueEyes.alpha = 0;
this.removeEventListener(Event.ENTER_FRAME,fl_ClickToChangeE yeColor01);
}

else if (actualeyecolorgolden==true){
actualeyecolorgolden = false;
actualeyecolorblue = true;
ModelBlueEyes.alpha = 1;
ModelGoldenEyes.alpha = 0;
this.removeEventListener(Event.ENTER_FRAME,fl_ClickToChangeE yeColor01);
}

else{
}
}

EyeColorSelectorLeftArrow.addEventListener(MouseEvent.CLICK, fl_ClickToChangeEyeColor02);

function fl_ClickToChangeEyeColor02(event:MouseEvent):void
{
if (actualeyecolorblue==true){
actualeyecolorgolden = true;
actualeyecolorblue = false;
ModelGoldenEyes.alpha = 1;
ModelBlueEyes.alpha = 0;
this.removeEventListener(Event.ENTER_FRAME,fl_ClickToChangeE yeColor02);
}

else if (actualeyecolorgolden==true){
actualeyecolorgolden = false;
actualeyecolorblue = true;
ModelBlueEyes.alpha = 1;
ModelGoldenEyes.alpha = 0;
this.removeEventListener(Event.ENTER_FRAME,fl_ClickToChangeE yeColor02);
}

else{
}
}

Obviously, as soon as I intended to test it, the error messages popped up telling me that the program was unable to find where the ''ModelGoldenEyes'' and ''ModelBlueEyes'' instances where declared (since they're declared INSIDE the girl's symbol, not in the main timeline).

My question is... is there a way to tell (in AS3 language) something along the lines of: "Look, goddamit, you have to look for those instances INSIDE the instances that compose the whole of the ''girl'' symbol''? (I know it sounds rudimentary, but that was what I mummbled while scratching my head in front of the computer so... true facts...)

If the question sounds stupid or whatnot, please excuse the crudeness... I'm no programmer, so it's like writting in Ancient Noldor for me...

Anyway, thanks for your tips and help, they'll be greatly appreciated :D

Fate out!

Fatelogic
Fatelogic
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 13
Artist
Response to Affect Instances Inside Instances? 2013-04-04 00:55:53 Reply

EyeColorSelectorRightArrow.addEventListener(MouseEvent.CLICK , fl_ClickToChangeEyeColor01);
...
...
...
this.removeEventListener(Event.ENTER_FRAME,fl_ClickToChangeE yeColor01);

Before anyone mentions this... yeah, I just noticed that dumb move... I'm gonna change that now xD

Fatelogic
Fatelogic
  • Member since: May. 3, 2012
  • Offline.
Forum Stats
Member
Level 13
Artist
Response to Affect Instances Inside Instances? 2013-04-04 02:46:47 Reply

Forget it, I managed to find a somewhat roundabout way of doing this... it included root variables, nesting movieclips and a bunch of torture for a programming newb such as me but... it worked xD