PDA

Volledige versie bekijken : Waar plaats ik de code


tha beaver
%Europe/Berlin %828 %2006, 19:53
Hoi flashers,

kan iemand mij uitleggen waarom actionscript op de main timeline 1 keer wordt uitgevoerd en op de timeline van een movieclip continue?

Nee, niet helemaal waar, op de timeline van de movieclip wordt iets alleen meerdere malen uitgevoerd als de timeline langer dan 1 frame is.

Hoe raar is dat??

Roenes
%Europe/Berlin %839 %2006, 20:09
Staat er toevallig geen stop(); in je mc? Want dan komt dat frame constant voorbij en zal constant die code worden uitgevoerd :)

tha beaver
%Europe/Berlin %866 %2006, 20:48
Roenes,

Ja dat klopt en dat vind ik ook logisch, echter wat ik niet begrijp is waarom dit met een moviclip met 1 frame niet zo werkt.?

Voorbeeld:

Neem een MC met 10 frames zet op frame 1:
a = 1
trace (a)
het output panel geeft om de tien frames 1 weer.

Neem een MC met 1 frame
a = 1
trace (a)

het output panel geeft 1 keer 1 weer.

Dat vind ik onlogisch

iZe
%Europe/Berlin %877 %2006, 21:03
Ik citeer Keith Peters in Actionscript Animation (bij een voorbeeld waarbij hij één frame heeft met een 'ball'-movieclip en op de _root de code: ball._x++) :


(...)
If you test the movie now, nothing much happens. Actually, what does happen is that Flash adds one to the x-position of the ball, and then displays the result. When you have a movie consisting of only one frame, Flash executes the code on that frame, renders and displays the result, and that's pretty much the end of that. What you need to do is to run that one line over and over. One of the simplest ways to do that is to add another frame to the timeline.
(...)
Now, Flash executes and displays frame 1, and then moves to frame 2. There is no new code to execute there, and nothing has changed on stage, so it just displays the same thing again. The magic is that, by default, Flash will loop back to frame 1 of a timeline after it has hit the final frame.
(...)

Sapience
%Europe/Berlin %880 %2006, 21:08
edit: ik was net wat later dan iZe, dus mijn post is eigenlijk onnodig....

das idd wat raar...

mijn theorie:
bij de '10' movieclip, speelt ie frame 1, frame 2, ... frame 10,
en gaat dan weer verder bij frame 1, maar hij is dan 'vergeten'
oftewel heeft het uit het geheugen geramt, dat a=1.

als hij maar 1 frame 'ziet', en daarin staat 1 maal a=1 en trace (a)
dan gaat hij misschien met opzet niet loopen, omdat de progra-
mmeur dat dan hoogstwaarschijnlijk ook niet zo had bedoeld.
een soort 'gebruiksgemakje ' van macromedia/adobe?

zie ook bijlage.