[Papervision3D] Stoping a DAE Loop

Andre Assalino Andre.Assalino at chemistrygroup.co.uk
Wed Oct 22 08:18:42 PDT 2008


Easy fix actually! I hadn't looked at the DAE class in detail.

So basically I added the following to the class:


        private var _loop:Boolean = false;


My Dae constructor now has a 3rd parameter, for loops:

        public function DAE(autoPlay:Boolean=true, name:String=null, loop:Boolean = false)
        {
            super(name);
            _autoPlay = autoPlay;
            _rightHanded = Papervision3D.useRIGHTHANDED;
            _loop = loop;
        }


And then the "project" function gets an if statement, where before it was:

                var time:Number = elapsed / duration;

                for each(var channel:AbstractChannel3D in _channels)
                {
                    channel.updateToTime(time);
                }

It changes to:

                var time:Number = elapsed / duration;

                if (time == 0 && !_loop)
                {
                    stop();
                }
                else
                {
                    for each(var channel:AbstractChannel3D in _channels)
                    {
                        channel.updateToTime(time);
                    }
                }

It works like a charm.

Hope it helps someone else too :)

Cheers



On 22/10/08 15:24, "John Grden" <neoriley at gmail.com> wrote:

sorry, rewind needs to be updateToFrame, not updateToTime ;)

On Wed, Oct 22, 2008 at 9:23 AM, John Grden <neoriley at gmail.com> wrote:
I've been doing this when the ANIMATION_COMPLETE fires (which I was believing was when the animation frames had all been parsed, not when the animation had completed playing):

private function handleAnimationComplete(e:FileLoadEvent):void
        {
            _channels = animatedAirplane.getAnimationChannels();

            trace("channel count", _channels.length);
            rewind();

            _numFrames = 0;
            _currentFrame = 1;

            for each(var channel:AbstractChannel3D in _channels)
            {
                _numFrames = Math.max(_numFrames, channel.keyFrames.length);
                channel.updateToFrame(_currentFrame);
            }

            //trace("read the channels");
            dispatchEvent(e);
        }

I also have these helper functions:

public function rewind():void
        {
            trace("channels length", animatedAirplane.getAnimationChannels().length);
            for each(var channel:AbstractChannel3D in _channels)
            {
                channel.updateToTime(1);
            }
        }

        public function gotoFrame(frame:Number):void
        {
            for each(var channel:AbstractChannel3D in _channels)
                channel.updateToFrame(frame);
        }


but to be honest, it's not working very well, I can't see to get the animation to stop on the first frame successfully.  On top of that, the false flag for autoplay doesn't seem to work either.  I've talked to Tim about it just this last week, and there's only one line in DAE that deals with that flag.  So I'm not sure what the issue is.


On Wed, Oct 22, 2008 at 9:14 AM, Andre Assalino <Andre.Assalino at chemistrygroup.co.uk> wrote:
Thanks for the tips.

Cristoph, your's wouldn't work because I want it to NOT loop and what you're saying just affects the autoPlay.

And Avery, using a timer could be bad, because if there's cpu lag, it might affect the animation and stop before it reaches the end. Right?

So there should be an animation listener and I could just go ON_FINISH, dae.stop();

I'm guessing that doesn't exist then?

Cheers,
Andre


On 22/10/08 10:05, "Avery" <numonesong at yahoo.com> wrote:

You could set up a timer with a stop action

var t = new Timer(3000, 1);

 <http://www.rogeraverymusic.com/><http://www.rogeraverymusic.com/><http://www.rogeraverymusic.com/><http://www.rogeraverymusic.com/>


--- On Wed, 10/22/08, zOrder <christoph.henzelmann at smeet.de> wrote:
From: zOrder <christoph.henzelmann at smeet.de>
Subject: Re: [Papervision3D] Stoping a DAE Loop
To: papervision3D at osflash.org
Date: Wednesday, October 22, 2008, 9:31 AM

you can use the autoplay flag

var dae:DAE = new DAE(false);

then then the first frame of your animation will be displayed unless
 you
switch to play


Christoph



Andre Assalino wrote:
>
> Hi guys,
>
> Is there a way to prevent a DAE animation from looping automatically?
>
> I only wanted it to play once and stop.
>
> Cheers all,
>
> André Assalino
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>




André Assalino
Head of Flash
Chemistry Communications Group Plc
Direct Line: +44 (0)20 7751 9288

ISP Agency of the Year 2008
ISP Grand Prix 2008

P Please consider the environment before printing this e-mail.

Ideas that Transform Relationships
________________________________________________________

Chemistry Communications Group plc: www.chemistrygroup.co.uk <http://www.chemistrygroup.co.uk><http://www.chemistrygroup.co.uk>
Melbray Mews, 158 Hurlingham Road, London, SW6 3NG. Company No. 4051458

The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the intended recipient(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. If you have receive this e-mail in error, please notify the sender. The views expressed in this email are those of the individual and not necessarily those of Chemistry Communications Group plc. Chemistry email is for business use only. Chemistry Communications Group plc accepts no liability for any damage caused by any virus transmitted by this e-mail.


_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org






André Assalino
Head of Flash
Chemistry Communications Group Plc
Direct Line: +44 (0)20 7751 9288

ISP Agency of the Year 2008
ISP Grand Prix 2008

P Please consider the environment before printing this e-mail.

Ideas that Transform Relationships
________________________________________________________

Chemistry Communications Group plc: www.chemistrygroup.co.uk
Melbray Mews, 158 Hurlingham Road, London, SW6 3NG. Company No. 4051458

The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the intended recipient(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. If you have receive this e-mail in error, please notify the sender. The views expressed in this email are those of the individual and not necessarily those of Chemistry Communications Group plc. Chemistry email is for business use only. Chemistry Communications Group plc accepts no liability for any damage caused by any virus transmitted by this e-mail.




More information about the Papervision3D mailing list