Skip to main content
Participant
July 30, 2009
Answered

child script can't reference the parent script

  • July 30, 2009
  • 1 reply
  • 544 views

Hi,


I define a variable (var photo1Show:Boolean = false;) in the actionscript layer. I have a movie

clip component on stage at this level. I double click it to open it. This movie clip has an

actionscript layer were I place the code "parent.photo1Show = true;". when I test the

application, I get error:


1119: Access of possibly undefined property photo1Show through a reference with static type

flash.display:DisplayObjectContainer.


What's wrong? Also, I using Flash CS4.


King


Code extract
-----------------------------------------------------------------------
Parent frame: contains several layers. the two in question are the action and photo layer.

action layer:

// Prev and next botton navigation controls

var photo1Show:Boolean = false;
var photo2Show:Boolean = false;
var photo3Show:Boolean = false;
var photo4Show:Boolean = false;
var photo5Show:Boolean = false;

// Set your captions here
var caption1 = "Model poise 1";
var caption2 = "Model poise 2";
var caption3 = "Model poise 3";
var caption4 = "Model poise 4";
var caption5 = "Model poise 5";

// Set the name of the external folder your big pics and thumbs are in

var galleryFolder:String = "Nepali";

// Thumbs Setup, Create loader instances for each thumb

var pic1ldr:Loader = new Loader();

... The rest of the code within this layer is not important

--------------------------------------------------------------------------------------------------

photo layer:

Contains the movie clip frame_mc on on of its layer.

I double click thre movie clip object. It contians serveral layers action, photo1 through photo5

layers. photo1 through photo5 layers contains pictures what are in difference keyframes.

-------------------------------------------------------------

action layer:

stop();
parent.photo1Show = true;
parent.photo2Show = false;
parent.photo3Show = false;
parent.photo4Show = false;
parent.photo5Show = false;

This topic has been closed for replies.
Correct answer kglad

you need to cast the parent as a movieclip:

MovieClip(parent).photo1Show=true;

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 30, 2009

you need to cast the parent as a movieclip:

MovieClip(parent).photo1Show=true;