dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: netstream buffer or ???

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    293

    netstream buffer or ???

    hi all - anyone know the answer to this question?

    i have an fla that calls external classes to get things working, in that class there is a call to set up and connect to a netstream function/object - that creates the connection and attaches the video to play using this
    PHP Code:
            }
            
            private function 
    loadVideo(n:String):void{
                if(
    video !== null){
                    
    removeChild(video);
                    
    video null
                
    }
                
                if(!
    imageArray[n]['video']){    
                    return;
                }
                
                
                
                var 
    connection:NetConnection = new NetConnection();;
                var 
    stream:NetStream;
                
    trace("playing video");
                
    video = new Video();
                
    connection.connect(null);
                
    stream = new NetStream(connection);
                
    stream.client this;
                
                
    addChild(video);
                
    video.attachNetStream(stream);
                
    stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(){});

                
    stream.bufferTime 1;
                
    stream.receiveAudio(true);
                
    stream.receiveVideo(true);
                
    trace(videoPath imageArray[largeImageItem]['video']);
                
    stream.play(videoPath imageArray[largeImageItem]['video']);
                
                
    addChild(video);
                
                
            } 
    the first click/viewing works fine, so i close it and then choose another flv to play - but this time the flv will only play, say 5-10 seconds of new flv - then the flv freezes and doesn't play any more of the flv.

    there is some script that functions on the click of the 'close' button that is this:
    PHP Code:
            /**
             * FUNCTION
             * _______________________________________________________________________________________________________________________________________
             * 
             * hide large image when close on controlpanel is clicked.
             * @eventType MouseEvent
             * @param none
             * 
             */
            
            
    private function hideLargeImage(event:MouseEvent):void
            
    {
                
    /**
                 * remove eventlistener from stage for zooming large image.
                 * 
                 * @fixed 06/11/08
                 * @comment listener is now removed properly after closing large image zoom viewmode
                 * 
                 */

                
    stage.removeEventListener(MouseEvent.MOUSE_WHEELzoomLargeImage);

                
    /**
                 * @version 2.0
                 * remove previous and next image buttons.
                 * 
                 */
                
                
    Tweener.addTween(prevThumbnailContainer, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(prevThumbnailContainer);
                    
    prevThumbnailContainer null;
                }  } );            
                
                
    Tweener.addTween(nextThumbnailContainer, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(nextThumbnailContainer);
                    
    nextThumbnailContainer null;
                }  } );            
                
                
    Tweener.addTween(video, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(video);
                    
    video null;
                    
    SoundMixer.stopAll();  

                }  } );
                
                
    /**
                 * hide tooltip on click.
                 * 
                 */
                
                
    removeTip();
                
                
    /**
                 * set help box status to false for proper loading next time.
                 * 
                 */
                
                
    helpShowStatus == false;
                
                
    /**
                 * fade out help box.
                 * 
                 */
                
                
    Tweener.addTween(helpBox, { _autoAlpha:0time:0.5delay:} );
            
                
                
    /**
                 * set image info status to false for proper loading next time.
                 * 
                 */
                
                
    imageDescriptionShowStatus false;
                
                
    /**
                 * fade out image info container if displayed.
                 * 
                 */
                            
                
    Tweener.addTween(imageInfoBoxContainer, { _autoAlpha:0time:0.5delay:} );
                
                
    /**
                 * fade out zoomcontainer with large image.
                 * @onComplete remove large image containers.
                 * 
                 */
                
                
    Tweener.addTween(zoomContainer, { _autoAlpha:0time:0.5delay:0.25onComplete:removeContainer } );
                
            } 
    in particular these lines
    PHP Code:
                Tweener.addTween(video, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(video);
                    
    video null;
                    
    SoundMixer.stopAll();  

                }  } ); 
    that kills the audio and video
    this works and fades out all of the elements including the netstream - and the movie works as it should, but then if another flv gets chosen - it goes a bit bonkers and won't play any more than a few second of the flv.
    this happens if you choose the same flv or a totally different flv.

    is this something to do with the buffering? is it to do with the way the close function works? should i be using additional code to play the netstream smoothly?

    anyone know?

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    What happens when you eliminate the Tweener, since in your original function the video is also removed?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    do you mean
    PHP Code:
    onComplete:function():void {
                    
    removeChild(video);
                    
    video null;
                    
    SoundMixer.stopAll();  

                }  } ); 
    i get errors

    do you think that is where my troubles are? what should I be looking at doing? new to as3 - new to netstream - lots to get to grips with.
    Is my script okay though? or is this where the errors are coming from?

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Remove that with the Tweener and take care of braces.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...okay i tried that - got rid of the tweener line and killed the braces - i also had to move the three lines up to the beginning of the function to stop the errors,
    PHP Code:
    private function hideLargeImage(event:MouseEvent):void
            
    {
                
    /**
                 * remove eventlistener from stage for zooming large image.
                 * 
                 * @fixed 06/11/08
                 * @comment listener is now removed properly after closing large image zoom viewmode
                 * 
                 */
                    
    removeChild(video);
                    
    video null;
                    
    SoundMixer.stopAll();  

                
    stage.removeEventListener(MouseEvent.MOUSE_WHEELzoomLargeImage);

                
    /**
                 * @version 2.0
                 * remove previous and next image buttons.
                 * 
                 */
                
                
    Tweener.addTween(prevThumbnailContainer, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(prevThumbnailContainer);
                    
    prevThumbnailContainer null;
                }  } );            
                
                
    Tweener.addTween(nextThumbnailContainer, { _autoAlpha:0time:0.5delay:0onComplete:function():void {
                    
    removeChild(nextThumbnailContainer);
                    
    nextThumbnailContainer null;
                }  } );            
                

                
                
    /**
                 * hide tooltip on click.
                 * 
                 */
                
                
    removeTip();
                
                
    /**
                 * set help box status to false for proper loading next time.
                 * 
                 */
                
                
    helpShowStatus == false;
                
                
    /**
                 * fade out help box.
                 * 
                 */
                
                
    Tweener.addTween(helpBox, { _autoAlpha:0time:0.5delay:} );
            
                
                
    /**
                 * set image info status to false for proper loading next time.
                 * 
                 */
                
                
    imageDescriptionShowStatus false;
                
                
    /**
                 * fade out image info container if displayed.
                 * 
                 */
                            
                
    Tweener.addTween(imageInfoBoxContainer, { _autoAlpha:0time:0.5delay:} );
                
                
    /**
                 * fade out zoomcontainer with large image.
                 * @onComplete remove large image containers.
                 * 
                 */
                
                
    Tweener.addTween(zoomContainer, { _autoAlpha:0time:0.5delay:0.25onComplete:removeContainer } );
                
            } 
    but this doesn't seem to have fixed it - the first flv chosen will play right through but then i close it and choose a different one and it plays a few seconds (sometimes one or two sometimes ten) and then freezes.

    i am wondering if i added autoplay or a play button or a streaming player to the flv - do you think that would kind of force it to play smoothly?

    or is that not the problem?

    this is entire block of code that is used to create and connect the netstream - is the problem in there somewhere?
    PHP Code:
            /**
             * FUNCTION
             * _______________________________________________________________________________________________________________________________________
             * 
             * prepare stage for loading large image.
             * @param none
             * 
             */

            
    private function loadLargeImage():void
            
    {
                
    /**
                 * downloadscale preloader bar from previous preloading.
                 * 
                 */
                
                
    thumbmask.scaleX 0.01;
                
                
    /**
                 * fade out controlpanel.
                 * 
                 */
                
                
    Tweener.addTween(panel, { _autoAlpha:0time:0.5  } );
                
                
    /**
                 * fade in preloader for preloading large image.
                 * @onComplete proceedLoad, start preloading large image
                 * 
                 */
                
                
    Tweener.addTween(thumbloader, { _autoAlpha:1time:0.5delay:0.5onComplete:proceedLoad } );
            
            
                
                
            }
            
            private function 
    loadVideo(n:String):void{
                if(
    video !== null){
                    
    removeChild(video);
                    
    video null
                
    }
                
                if(!
    imageArray[n]['video']){    
                    return;
                }
                
                
                
                var 
    connection:NetConnection = new NetConnection();;
                var 
    stream:NetStream;
                
    trace("playing video");
                
    video = new Video();
                
    connection.connect(null);
                
    stream = new NetStream(connection);
                
    stream.client this;
                
                
    addChild(video);
                
    video.attachNetStream(stream);
                
    stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(){});

                
    stream.bufferTime 1;
                
    stream.receiveAudio(true);
                
    stream.receiveVideo(true);
                
    trace(videoPath imageArray[largeImageItem]['video']);
                
    stream.play(videoPath imageArray[largeImageItem]['video']);
                
                
    addChild(video);
                                        
    video.x                 int((stage.stageWidth video.width) * 0.5);
                
    video.y                 int((stage.stageHeight video.height) * 0.5);

                
            } 
    how do i add controls to it`?

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...this is the code that preceeds the load large image command
    should i be ref'ing loadvideo in there too?
    PHP Code:
            /**
             * FUNCTION
             * _______________________________________________________________________________________________________________________________________
             * 
             * fires when imageworlditem has been doubleclicked.
             * @eventType ImageWorld3dItemEvent
             * 
             */

            
    private function imageWorldItemClick(event:ImageWorld3dItemEvent):void
            
    {
                
    /**
                 * hide help box if visible.
                 * 
                 */
                
                
    if (helpShowStatus == true)
                {
                    
    Tweener.addTween(helpBox, { _autoAlpha:0time:0.25 } );
                    
    helpShowStatus false;
                }
                    
                
    /**
                 * receive current large image value from target
                 * 
                 */
                
                
    largeImageItem event.value;
                
                
    /**
                 * disable buttonmode for viewport
                 */
                
                
    viewport.buttonMode false;
                
                
    /**
                 * remove eventlisteners from stage
                 * 
                 */
                
                
    stage.removeEventListener(MouseEvent.MOUSE_DOWNdragStartCircleMode);
                
    stage.removeEventListener(MouseEvent.MOUSE_UPdragStopCircleMode);
                
    stage.removeEventListener(MouseEvent.MOUSE_DOWNdragStartFlatMode);
                
    stage.removeEventListener(MouseEvent.MOUSE_UPdragStopFlatMode);
                
    stage.removeEventListener(MouseEvent.MOUSE_WHEELscrollWheelCircle);
                
    stage.removeEventListener(MouseEvent.MOUSE_WHEELscrollWheelFlat);
                
                
    /**
                 * remove eventlisteners from all thumbnails.
                 * 
                 */

                
    for (var countThumbs:uint 0countThumbs imageAmountcountThumbs++)
                {
                    var 
    _imageWorldItem:ImageWorld3dItem rootnode.getChildByName("imageworlditem" countThumbs) as ImageWorld3dItem;
                    
    _imageWorldItem.removeListeners();
                }
                
                
    /**
                 * fade in alphaBlendMask to hide thumbnails.
                 * @onComplete loadLargeImage, prepare stage for loading large image.
                 * 
                 */

                
    Tweener.addTween(alphaBlendMask, { _autoAlpha:1time:0.5onComplete:loadLargeImage } );
            } 
    there is so much code to this project i am suffering from snow blindness!

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...hmm, still not getting very far with this - is there a way to close/unload/remove the netstream connection when the close button is clicked?

    i dropped the files/folder etc... onto the server and then went to the url of the swf of this.

    when the initial thumb is clicked it goes to the largeimage and begins to load the flv - i see that in the activity window - but if i close it and return to the original view of thumbnails - that flv carries on loading - and if i click on a different thumb - the flv for that also starts loading!

    how do i tell the netstream to stop and drop the connection?

    or am i still not getting it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center