loadMovie and Referencing problem

hi.

Example: I have an swf called “test.swf”. In this Flashmovie i have an Instance of an Movieclip called “title”. I load test.swf in another Flashmovie called “main.fla” by

_root.container01.loadMovie(“test.swf”);

where container01 is an instance of an empty Movieclip.

From within main.fla I’d like to refer to the alpha value of the instance title by

_root.container01.title._alpha = 80;

but this does not work (title._alpha is undefined). What is wrong? Thanks in advance for any help…

bye
chris

Should work. Have you done a trace?

Also make sure your instance names are correct - Flash is case sensitive!

edit on second thought - it may depend on the order you have your code. If you are loading test.swf and then trying to alter the _alpha right away it may not happen. Flash fires so quick that the swf may not be fully loaded before you are trying to change the _alpha. If you were to put the code to change the _alpha on a button click then the referencing should work. If you want it to happen on its own then you should probably add preloader-like code to make sure that the swf has fully loaded before trying to fire off an code on the objects inside test.swf

hope that makes sense :hr:

hi lunatic,

thanks for the reply.

[quote=lunatic]Should work. Have you done a trace?
sure. the “undefined” is coming from the trace.

Actually, i have event handlers such as

_root.container01.btn01.onRollOver = function() {
_root.container01.titel.onEnterFrame = function() {
if (this._alpha<100) {
this._alpha += (100-this._alpha)/4;
} else {
delete this.onEnterFrame;
}
};
};

(and analogously for RollOut)

So, the title fades in when the mousearrow is going over an active zone (the btn01 is a active aera button and i have to place it in the externally loaded swf).

Anyways, meanwhile i place the code in the externall swf, but i would prefer to have the code all togehter in the main fla.

cheers,
chris

title._alpha may be undefined because title doesn’t exist yet at the time the code is called. You have to make sure the external swf has fully loaded before accessing objects contained within it. :slight_smile:

Oh and by the way when you use a tag like [noparse]

.

We also have some nifty actionscript, php, and code tags you can use in the same way, such as
[noparse]

your actionscript code here

[/noparse]
[noparse]

your php code here

[/noparse]
[noparse]

generic code here

[/noparse]

Wrapping your code in the appropriate tag will make it more readable, so those trying to help you can quickly scan for an error or read what you are trying to do much easier.

:hr: