Code on MC's created with createEmptyMovieClip

Is there any way to put code on an mc created with createEmptyMovieClip?

hmm. i dont know for sure but you might try like this, saying your mc was holder.


holder.onClipEvent(load){
play();
}

you know? something like that MIGHT work, i dont have flash in front of me so i dont know, but i am assuming thats how you would do it.

Yes. Just do it as you would with a normal mc that you made yourself.

Regards,
Viru.

thank you

:geek:

okay I am now attempting to target the clip with this code:
<hr>
this.createEmptyMovieClip(“clip1”, 1);
clip1.loadMovie(“welcome.swf”);
clip1._x = 320 ;
clip1._y = 320 ;

<b>this.“clip1”.onClipEvent(enterFrame)</b>{
percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100)
percentdisplay=percentloaded + "%"
if(percentloaded == 100 && !initialized){
play();
initialized=true
_visible=false
}
}
<hr>

and I am getting this error:

Scene=Scene 1, Layer=script, Frame=4: Line 43: Expected a field name after ‘.’ operator.
this.“clip1”.onClipEvent (enterFrame){

Any thoughts as to what field name is expected? I do not understand what I am need to do here…

I think it should be


MovieClip.clip1.onClipEvent(enterFrame){
etc..

Regards,
Viru

okay viru, you have given great advice so far so I am sure it will work

:}

I will test it out

Thanks!

Well I tried it and I am still getting the same message :crazy:

ok, sorry that was just the first thing i thought you should try. Is it possible to post your fla?

Viru.

Ok, hit me, i wasnt thinking straight, i’m pretty sure this will work,


Movieclip.clip1.onEnterFrame = function() {
//write the code you want to happen on each enterframe here.
}

Regards,
Viru.

no it is a really big file - I guess I could try deleted some of the unactive artwork and zipping it.

when you test the movie the external movie clips will not show up though…

this is my trouble- I am trying to put preloaders on the external swf’s without actually putting them in the swf’s themselves. I do not have that luxory as they are made with Wildform FX (text program) and it only outputs swf’s that you cannot add code to…

okay so like this:

code:
<hr>
this.createEmptyMovieClip(“clip1”, 1);
clip1.loadMovie(“welcome.swf”);
clip1._x = 320 ;
clip1._y = 320 ;

Movieclip.clip1.onEnterFrame = function() {
percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100)
percentdisplay=percentloaded + "%"
if(percentloaded == 100 && !initialized){
play();
initialized=true
_visible=false
}
}
<hr>

when I want to call the function I say?

Movieclip.clip1.onEnterFrame ();

I’m not sure. I am not very advanced in my as…if you couldn’t tell by my millions of questions…
(-:

I dont think you can call it like that. But its worth a try first. It that doesnt work create a function like this that you can call:


Movieclip.clip1.**preloaderFunc** = function() {
percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100)
percentdisplay=percentloaded + "%"
if(percentloaded == 100 && !initialized){
play();
initialized=true
_visible=false
}
}

And call it with

Movieclip.clip1.preloaderFunc();

Regards,
Viru.

P.S I’m still learning too :slight_smile:

[AS]_root.createEmptyMovieClip(“clip1”, 1);
clip1._x = 320 ;
clip1._y = 320 ;
clip1.onEnterFrame = function() {
if (this._url != _root._url) {
_root.preload(this);
}
}


function preload(clip) {
if (!loaded) {
if (clip.getBytesLoaded>0 && clip.getBytesLoaded>=clip.getBytesTotal) {
loaded = true;
}
var percent = (clip.getBytesLoaded()/clip.getBytesTotal());
loadBar._width = 100*percent; //replace 100 for your loadbar width
}
}
clip1.loadMovie(“welcome.swf”);

well viru it doesn’t seem to be working-

There are NO problems or errors with your code, I think the error lies within the code I was trying to use to get the preload working.

So I thank you because what you came up with is right-

Claudio I am going to have a look at what you have here. I was looking at your tutorial about preloading external swf’s with transition and trying to apply that to what I need to do. I was not able to do so and was hoping maybe you would write one without the transition :wink:

I thank you both!

Your welcome. And Claudio is very good, i’m sure anything he/she says will help you to no end.

V.

Yes Claudio provided great code but I am thinking that it is possibly preloading the movie clip (“clip 1”) and not the actual content that gets loaded into the clip.

Maybe I did not make my goal clear, or I could be wrong but it seems as though that is what it is doing…

:bounce: