PDA

View Full Version : onEnterFrame problems



titoqan
January 20th, 2007, 06:40 PM
Hello,

I am trying to load a swf using the onEnterFrame. this is what I have on the first frame of my main_swf

onEnterFrame = function (){
_root.createEmptyMovieClip("compass",1);
loadMovie ("compass.swf", compass_mc);
}

When I publish I just get a blank swf.

When I just use

loadMovie ("compass.swf", compass_mc);
I have an empty _mc with the instance name of "compass_mc"
I get the swf to load but no animation.

Any pointers?

Thanks
Titoqan

TheCanadian
January 20th, 2007, 06:54 PM
_root.createEmptyMovieClip("compass_mc", 1);
loadMovie("compass.swf", compass_mc);
You don't need it in an onEnterFrame event.

stringy
January 20th, 2007, 06:57 PM
you also need to change the code in compass
click on the arrow and in actions panel change to

onClipEvent(enterFrame)
{
this._rotation = this._parent.clip.degrees;
}

jjcorreia
January 20th, 2007, 06:57 PM
If you use onEnterFrame its just going to create the swf and try to load on every frame. Its like taking 1 step forward and 1 step back.

Remember, onEnterFrame is a frame event that will execute ever time your flash movie enters a new frame (hence the name :) )

titoqan
January 21st, 2007, 04:16 AM
A big thank you!!

jjcorreia, I thought that I had a "stop()" in that same frame so that it would only play once. But it is still cleaner and easier without it. Thanks.

I have another question and it stems off of stringy's comment ( BTW good catch), I am now loading another swf for music and have gotton nearly all my buttons to work properly but the play button. Here is a simple tree diagram showing my layout

main_swf
|__music_swf
|__movieclip w/instance name that holds music and framelabels for play and stop
|__Movieclip Menu
|__Button that start music
|__Action script as follows
on (release)
{
stopAllSounds();
this._parent.police_mc.gotoAndPlay("play");
eval(mcoff)._visible = true;
}

I can't seem to find the right path for the button to start the music

Originally I had this working by itself and I was able to use _root.police_mc.gotoAndPlay("play");


Should I start a new thread or leave it here?

Thanks again!
Titoqan

my tree lost its limbs....
Both movie clips are at the same level and the button is in one of the movie clips.

PS. I would attach a fla but since we are dealing with mp3's it will be to BIG

jjcorreia
January 21st, 2007, 04:22 AM
A big thank you!!

jjcorreia, I thought that I had a "stop()" in that same frame so that it would only play once. But it is still cleaner and easier without it. Thanks.


No problem ;)

stop() has no effect on EnterFrame events. It only stops the current timeline from playing, but EnterFrame events dont depend on a timeline playing to work. They will execute continuously until the instance they have been attached to has been removed, or they have been deleted, eg delete onEnterFrame.

titoqan
January 21st, 2007, 04:51 AM
No problem ;)

stop() has no effect on EnterFrame events. It only stops the current timeline from playing, but EnterFrame events dont depend on a timeline playing to work. They will execute continuously until the instance they have been attached to has been removed, or they have been deleted, eg delete onEnterFrame.


Thanks ! IT is nice to understand not just to be spoonfed. :)

I have to admit that I do use other people's scripts that are way over my comprehension because I am trying to learn something ... and that they are so cool!

Titoqan

FizixMan
January 22nd, 2007, 03:47 PM
If you want to use an event that will only fire once (even with the stop() command) try using onLoad/on(Load) or onClipEvent(Load)

jjcorreia
January 22nd, 2007, 04:08 PM
If you want to use an event that will only fire once (even with the stop() command) try using onLoad/on(Load) or onClipEvent(Load)

Never use onClipEvents. They were deprecated several versions ago and restrict versatility. They used to be handy, but now they are a very bad coding practice (you cant even use them period in AS 3.0). Additionally, onLoad events are not really needed much anymore as you can execute code in the contructors of custom classes or when you create the object itself.