Few words defending enterframe...
AS1 required "manual" initialization of broadcaster objects while
Movieclip events where simple: on(release), on(enterframe)...
AS2 provides EventDispatcher class. Using it may be considered as
somehow more advanced technique.
But AS2 still allows using such shortcuts as:
- mc.onPress=function(){...}
- mc.onReleaseOutside=function(){...}
- mc.onEnterFrame=function(){...}
... which is very handy, simple to understand and follow; not only
for beginners.
AS3 forces all coders, including beginners to use events listening for
most user interaction cases, mouse clicks, key pressing and also
(user independent) controlling animation progress. Perhaps that is how
Adobe understood good practices and I wouldn't ever like to discuss
whether it's cool or not cool. Some criticize this approach as
favoring experienced coders.
Anyway, in my opinion handling enter_frame should not be
considered as a kind of sorcery/voodoo, particularly when somebody
wishes to learn more that drawing figures on the stage.
I think that with the release of AS3, controlling events dispatching
and listening becomes a rather basic and essential "skill" for a coder.
Sooner or later, Beno has to start using them (rather sooner).
Beno - a step by step tutorial for simple frames control with
enterframe:
http://www.bellaonline.com/articles/art54385.asp
*
I do not argue that adding code to stage is handy. It is a lot and I
am adding stop() very often to stop "hand-made" animations at some
point. But it is a shortcut that should be used (often) when somebody
is more familiar with the area.
Greg
November 25, 2009 (10:20:45 PM) Karl DeSaulniers wrote:
> You could do the stop frame in script.
> If(mc._currentfame == 20) {
> this.mc.stop();
> }
> But listen to them about the enterFrame. I learned the hard way too
> and what they are telling you is the right way and best way for you.
> GL
> Karl
> Sent from losPhone
> On Nov 25, 2009, at 2:57 PM, Paul Andrews <[email protected]> wrote:
>> beno - wrote:
>>> On Wed, Nov 25, 2009 at 3:36 PM, Barry Hannah <[email protected]>
>>> wrote:
>>>
>>>
>>>> Try:
>>>>
>>>> public function myLeftHand(e:Event=null):void {
>>>> //
>>>> }
>>>>
>>>>
>>>> The myLeftHand method is being called when an event fires, so the
>>>> event
>>>> must be passed in as a method parameter. "Event=null" allows the
>>>> event
>>>> to be optional - so you could also call it without dispatching an
>>>> event.
>>>>
>>>>
>>>
>>> This worked.
>>>
>> Yes, but just be aware that this technique works for this case, but
>> would make your code more complex if your event handling function
>> actually used the event parameter. Personally I would avoid this
>> technique for event handlers.
>>>
>>>> Whomever told you to use enterframe to have something happen on
>>>> frame 20
>>>> made a mistake. It's a valid way to get it working, I personally
>>>> think
>>>> an enterframe loop is a waste of resource for that case and, more
>>>> importantly, I just don't think you're there yet. Go back to
>>>> putting an
>>>> action on the timeline at frame 20.
>>>>
>>>>
>>>
>>> You have a good point, of course. But I am going to do this anyway.
>>> I will
>>> be calling this mc many times. Besides, I firmly believe that the
>>> "right"
>>> way to do this is calling the event as I enter frames.
>> It's not the right way for this situation.
>>
>> Enterframe operations are expensive. The more code that the flash
>> player is executing the greater the load on the processor. For the
>> trivial example that you have, it doesn't matter, but generally
>> think hard if enterframe is the right solution.
>>
>> In this case you are needlessly "watching" a movieclip to stop it at
>> frame 20, when you could simply add a stop action to the timeline.
>> Since that's all that you need to have the movieclip do, there's
>> utterly no point in making life complicated for no reason. If you
>> had a sophisticated behaviour (say stopping the movieclip at an
>> arbitrary frame), I might have some sympathy with the approach, but
>> otherwise it's complication for no reason. I have used the technique
>> on imported MovieClips that I have no access to, so it's a useful
>> technique but totally unnecessary here.
>>
>> In programming in general and flash in particular, simplicity is
>> preferable to complexity. Only make things as complex as they need
>> to be for the job and no more. There is a much mentioned anagram:
>> KISS - Keep It Simple Stupid, which makes the point most eloquently.
>>
>> Frame 20 awaits your stop() command.
>>
>> I think you may be learning some more things about flash but may be
>> picking up bad habits already.
>>
>> Paul
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders