PDA

View Full Version : mc.onData Vs onClipEvent(data) What is the difference??


pragathikanth
03-26-2003, 08:39 AM
Hi All,

I have a problem with onLoad/onData function.

Here’s what I am trying to do. Load a swf file in to an mc (myMC)
and I have this code on main timeline (_root ) to check if the swf is loaded into myMC.

//-------- code------------------
myMC.onData = function(){
trace("File loaded");
}


//I am loading the file on press of a button
// --------- loading image.swf into myMC---------

btn.onRelease = function(){
loadMovie("image.swf","_root.myMC")
}

/*
The above code should work right? some how it does not.
if I write the same thing on a ClipEvent it works.
*/
// onClipEvent check if the clip has recided data.

onClipEvent(data){
trace("File loaded");
}

The reason why I dont want to use onClipEvent is to avoid attaching any code to the MC’s.

Can some one please explain what is the difference between these two methods and how to check if the data is loaded into an MC if I have to write the code on the root.

Thanks for your time.

senocular
03-26-2003, 09:20 AM
this is more common with onLoad since that is what is normally used to handle the loading of movieclips being loaded in with loadMovie. onData is typical for loadVariables recognition.

What happens is, when a movieclip has a new swf loaded into it, all variables and functions originally set for that initial clip are cleared to make way for the new swf being loaded in. This includes any onLoad (or onData for that matter) function you may have defined. The reason they dont clear while ON the movieclip is because... well the code is physically attached to that object and remains even when the new swf is added.

There are several workarounds for this problem like this one
http://chattyfig.figleaf.com/ezmlm/ezmlm-cgi?1:mss:49174

chewbacca nine
03-26-2003, 03:01 PM
sweet link, thanks.

pragathikanth
03-26-2003, 04:01 PM
Hmmm, that explains, I always thought when onLoad is used it would function like the onClipEvent, but then I should have thought abt it harder. If it did, why would they have two ways of going about it.
Anyways I am clear now, I had been breaking my head over this for a day now. Thanks a lot for your help "senocular". Will sleep peacefully and think about the other problem, Just a thought would you have any idea about how to go about capturing a double click on a listBox item?? Well it would be great if you could help me with this too :)

Thanks a lot again for your help and your time.

mmaster
03-26-2003, 07:06 PM
I tried the code in that link as is, and it didn't work for me. I never saw the trace output in my Flash MX. Has anybody got it working?

pragathikanth
03-27-2003, 08:49 AM
Yes, I did and it works fine It shows the trace in the output window.

You need to have the test.swf file in the same folder. It should work, it did for me.

December
06-02-2006, 07:32 AM
Sorry for bringing up this thread again, but it shows exactly whats my current problem.

And senocular's link is a dead link now :( There should be more workarounds for this prob. Can anyone please post some other link to a workaround relating to this onData prob?

Thx a lot

Greetz, December

Glen Charles Rowell
06-05-2006, 06:29 AM
I know this is old but I wanna see that link too :(