Movieclip A contains movie clips B(back1) and C.
Frame one of movieclip A contains this code:
back1.visible = false;
So clip B is intended to start out invisible, then
The script of movie clip C contains a press handler that tells movieClip B to become visible.
The error message generated when Frame one of movieclip A is entered is:
Symbol 'mainContentBox' 1046: Type was not found or was not a compile-time constant: back1.
You only need to have the line: back1.visible = false;
An ENTER_FRAME event is not what its name suggests. What it does is it fires at the frame rate of the file, as if it was continuously entering a frame. It has nothing to do with actually entering that frame. So just having that line by itself is sufficient to make it happen in that frame.
As for the error, how is that name assigned to the movieclip B? It should be assigned to the movieclip via entering that name in the Properties panel field shown as <Instance Name> when you select it on the stage. And that movieclip also needs to exist in frame 1 in order for it to be targeted by that code. I would have expected a different error though if mis-naming or non-presence is the issue
Yes, that listener/handler wouldn't be causing the error, but is not needed for what you were doing.
Is that the entire error message? If you comment out that line do you still get the error?
Can you show a screenshot that includes that movieclip, the timeline, the properties panel and the actionscript (It'll be large)
Also, before you test the file again, go into your Flash Publish Settings and select the option to Permit Debugging. That might add some info to the error message.
Well, some progress. I deleted clip B and recreated it from scratch.
Now for some reason the command to make it invisible at the start is working fine.
But the command to make it reappear that is located in movieClip C is not working. I get this message:
ReferenceError: Error #1065: Variable back1 is not defined.
thanks for the help
For what I understand you need to direct the comand to make back1 visible, to parent. That is, your back1 and movieclip C are in the same level, and want to call back1 inside moviclip C, so you need to tell C where back1 is.
Inside C, try something like:
I usually don't code in timeline, but I would keep every code inside the frame and not in the objects itself. May result in bigger difficulties if you want to debug something.
See if this helps.
Yes, that worked. (although I had already tried it earlier and it didn't work at that time.)
Wow, I am getting a lot closer, thanks to the help.
What I don't seem to have a handle on is how to get commands across to objects that are residing in different levels. I can use 'parent' and 'root' now, but I don't know how to (for instance) add an event listener(mouse click) to clip B that triggers a removeChild at the root level. If I put the command at the root level, it says the clip B variable is not defined; if I put the command in Clip B it says The supplied DisplayObject must be a child of the caller.
I assume there is some way to direct commands across all these virtual chasms but I cannot find a Help topic that addresses it.
Yes there is
But you have to plan a bit ahead of what you're going to do. I only use root or parent in the infimous last resort. For one side, this may confuse you if you end the project and want to get back later on. Probably you have forgotten how everything was organized, and you will spent too much time just to figure what is the parent or the root... they have no names.
Last I've always read that everytime this is possible don't use, it's considered bad practice, probably by the reason I stated earlier, or even others.
For example you have a MovieClip A and inside it a MovieClip B. if you want to call a method of B from A, well it's easy mvB.methodToCall(), right?
But consider this. You want to remove B with a button that is inside B. You can't, because the compiler will tell you that, the child must be removed from the parent, i.e., from B you have to remove it from A.
Two options: whether you remove with a parent call, or you can do it wil a function callback.
This last option is what I always do, with no trouble at all. Basically when you instantiate B, one of the arguments will be a method name, that exists in A... say deleteB(). When you press the button in B to delete it, B will call this function, that it knows it's in A, then the A removes B.
It's simpler than it sounds.
Visit this blog entry, that has an example of how to do it.
Try with a basic example justo test it, and then move to your project.
I think it's very clear, but be free to ask.