www.webdeveloper.com
Results 1 to 2 of 2

Thread: FLASH: Select Next Item in Datagrid

  1. #1
    Join Date
    Jul 2008
    Posts
    10

    FLASH: Select Next Item in Datagrid

    Is it possible to change the focus in the Datagrid through ActionScript? Right now, I have a Datagrid with a list of external .flv's. When the user selects one, the video begins playing. I would like to create a "next" and "last" button that will change focus on the Datagrid and play the video. Here is what I currently have to play a selected video.

    PHP Code:
    function cellPress(evt_obj:Object) {
        var 
    item mydgrid.selectedItem;
        
    ttmydgrid.selectedItem.name);
        var 
    fName mydgrid.selectedItem.name
        playMovie
    (fName);
    };

    function 
    playMovie(what) {
        
    this.videoContainer._width vidWidth;
        
    this.videoContainer._height vidHeight;
        
    stopVideo();
        
    initNetStream();
        
        
    ns.setBufferTime(5);
        
    this.videoContainer.attachVideo(this.ns);
        
    ns.play(what);

    How can I adapt this to make a playNextMovie function? Thanks for your help. I look forward to your suggestions.

  2. #2
    Join Date
    Mar 2007
    Location
    Athens, Greece
    Posts
    177
    Hi,

    May try this (I added also a "previous" and "fisrt" buttons functionality.. Just in case you may need them):

    Use it in a frame eg.1 of your main -root- clip. Requires 4 buttons, in this example named: "nextButton", "previousButton", "firstButton", "lastButton" ):
    AS:
    PHP Code:
    function cellPress(evt_obj:Object) { 
        var 
    item mydgrid.selectedItem
        
    ttmydgrid.selectedItem.name); 
        var 
    fName mydgrid.selectedItem.name 
        playMovie
    (fName); 
        
    trace(item.label+"  "+mydgrid.selectedIndex)

    }; 

    // This allows for example the user to use the arrow keys to select a data grid item
    mydgrid.addEventListener("change"cellPress)


    function 
    playMovie(what) { 
        
    this.videoContainer._width vidWidth
        
    this.videoContainer._height vidHeight
        
    stopVideo(); 
        
    initNetStream(); 
         
        
    ns.setBufferTime(5); 
        
    this.videoContainer.attachVideo(this.ns); 
        
    ns.play(what); 



    var 
    SelectedIndex=0
    var ScrollTop=0


    nextButton
    .onRelease=function(){
        
    SetSelected(1)
    }

    previousButton.onRelease=function(){
        
    SetSelected(-1)
    }

    function 
    SetSelected(Step:Number){
        
    SelectedIndex=mydgrid.selectedIndex+Step
        
    if (!SelectedIndexSelectedIndex=
        ScrollTop
    =SelectedIndex
        UpdateGrid
    ()    
    }

    firstButton.onRelease=function(){
        
    SelectedIndex=0
        ScrollTop
    =0
        UpdateGrid
    ()
    }

    lastButton.onRelease=function(){
        
    SelectedIndex=mydgrid.length-1
        ScrollTop
    =mydgrid.length-mydgrid.rowCount+1
        UpdateGrid
    ()    
    }

    function 
    UpdateGrid(){
        
    with (mydgrid){
            
    setFocus()        
            
    vPosition=ScrollTop        
            selectedIndex
    =SelectedIndex        
        
    }
        
    cellPress(mydgrid)    

    Cheers!

    Kostas
    K. Zotos online portfolio (3D, Web, Programming): http://www.in3d.eu/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles