Groups | Blog | Home
all groups > flash actionscript > january 2005 >

flash actionscript : onClipEvent whith movieclip created at runtime



Pluda
1/22/2005 5:32:50 PM
Hello,

I have one movieclip in stage, and using onClipEvent (load)everything works
good.

now If I want to create one movieclip at runtime, and use

mymovieclip.onClipEvent (load)

I get one error saying

Expected a field name after '.' operator.

But If I use

mymovieclip.onLoad = function()

Flash crashes...

How should I use this?

Thanks!
kglad
1/22/2005 5:54:14 PM
you should use preload-type code to determine when a swf has completed loading
into a dynamically created movieclip. if you're not loading anything into your
dynamically created movieclip there's not much reason to use any type of onLoad
handler: as soon as you execute your createEmptyMovieClip() statement your
newly created movieclip is instantiated.
Pluda
1/22/2005 6:20:40 PM
Hello Kglad, thanks for help

Yes, i'm not loading anything into my movieclip, I need to assign some
variables wich may then be used to make this work.

I'm trying to untherstand how this works:

http://jrgraphix.net/research/flash_dock.php

That is made using one movieclip already in stage and using the onLoad and
onEnterFrame functions.
(the funny thing is that all images are in stage, they don't load anything
into movieclip either)

I wanted to make a similar thing, but creating buttons as they are needed,
thats why I post this question.

Many thanks :-)
barn
1/22/2005 8:21:06 PM
If you're not loading anything into it, then just assign the variables after you dynamically create the clip:



createEmptyMovieClip("myClip", 0);
Pluda
1/22/2005 10:29:19 PM
Hello,

I had experienced passing the vars like you said,

movieclip.somevar="whatever";

but flash always says that some script in the movie is causing him to run
slowly and the computer may crash...
NSurveyor
1/22/2005 11:02:00 PM
Declaring a variable is probably not the cause of that error. Usually it is a
for loop or while or other loop that potentially will go on forever, for
example:

for(p = 0;p != 1;p += 2){
trace(p);
}

Do you have any other script in your movie?
Pluda
1/22/2005 11:10:53 PM
Hello NSurveyor, no, I don't have any more script.

Basycally, I know how to buil my own menu, but I need the maths...

For more hours I spend reading the code, I can't untherstand how that works

using _xscale I get that efect, but not the 180 degrees round.

Thats why I'm trying to use that code
AddThis Social Bookmark Button