A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: scroll bars integration.

  1. #1
    Senior Member
    Join Date
    May 2000
    Posts
    814

    scroll bars integration.

    I have a scroll bar example working in a test file, on it's own on the stage, but i'm having issues integrating it into a loop that builds my content.

    The xml feed is populating the repeated text boxes, the traced values all seem ok. The only thing that i cant get working is the damn scrolling movement of the content and the scroll bar track.

    the traces on my thumbDown, thumbUp, and thumbMove all fire. i have a feeling it is something to do with the stage event listener or the fact that the NewsBlock() is imported from my library. That's my best guess after about three hours of messing about with this.

    Any clues welcome.
    cheers

    Actionscript Code:
    function createMyNews():void {
        //This will be used to represent a menu item
        var newsBlock:NewsBlock;
        var dots:Dots;
       
       
       
        //Counter
        var i:uint = 0;

            //Loop through the links found in the XML file
            for each (var link:XML in myXML.link) {

            newsBlock = new NewsBlock();
            newsBlock.id = i;
       
            imageLdr = new Loader();
            imageURL = myXML.link[i].@image;
            imageURLReq = new URLRequest(imageURL);
            imageLdr.load(imageURLReq);
            newsBlock.imageHolder.addChild(imageLdr);
           
           
    //*********i think the problem lies below here************************//       
           
    var yOffset:Number;
    var yMin:Number = 0;
    var yMax:Number = newsBlock.scrollBox.sb.track.height - newsBlock.scrollBox.sb.thumb.height;
    newsBlock.scrollBox.sb.thumb.buttonMode = true;

    newsBlock.scrollBox.content.news_text.condenseWhite = true;
    newsBlock.scrollBox.content.news_text.multiline = true;
    newsBlock.scrollBox.content.news_text.autoSize =  TextFieldAutoSize.LEFT ;
    newsBlock.scrollBox.content.news_text.wordWrap =  true ;
    newsBlock.scrollBox.content.news_text.text = link.@news;


    trace(newsBlock.scrollBox.content.news_text.height);


    if(newsBlock.scrollBox.content.news_text.height <= newsBlock.scrollBox.sb.height) {
                    newsBlock.scrollBox.sb.visible = false;}
                   
    if(newsBlock.scrollBox.content.news_text.height >= newsBlock.scrollBox.sb.height){
                    newsBlock.scrollBox.sb.visible = true;}
                   
               
                   
                   
                   
    newsBlock.scrollBox.sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
    stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);


    //*********i think the problem lies above here************************//       
       



       
            newsBlock.dateTxt.text = link.@date;
            newsBlock.headlineTxt.text = link.@headline;
       
           

            newsBlock.x = i* newsWidth;
            newsBlock.y = 30;


            newsHolder.addChild(newsBlock);
           
            dots = new Dots();
            dots.id = i;
            dotCollection.push( dots );
           
            dots.x = dotsOrigin + (i* dotsGap);
            dots.y = newsBlock.y + outline.height + 20;
           
           
            //Make the button look like a button (hand cursor)
            dots.buttonMode = true;
            dots.mouseChildren = false;
           
            //Add event handlers (used for animating the buttons)
            dots.addEventListener (MouseEvent.MOUSE_OVER, dotOverHandler);
            dots.addEventListener (MouseEvent.MOUSE_OUT, dotOutHandler);
            dots.addEventListener (MouseEvent.MOUSE_DOWN, dotPressHandler);
           

            dotsHolder.addChild(dots);

            //Increment the menu button counter, so we know how many buttons there are
            i++;
        }
       
       

    //*********i think the problem lies below here************************//   

    function thumbDown(e:MouseEvent):void
    {
        trace("down");
        stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
        yOffset = mouseY - newsBlock.scrollBox.sb.thumb.y;
    }



    function thumbUp(e:MouseEvent):void
    {
        trace("up");
        stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
    }



    function thumbMove(e:MouseEvent):void
    {
        trace("move");
       
       
        newsBlock.scrollBox.sb.thumb.y = mouseY - yOffset;
       
        if(newsBlock.scrollBox.sb.thumb.y <= yMin)
            newsBlock.scrollBox.sb.thumb.y = yMin;
           
        if(newsBlock.scrollBox.sb.thumb.y >= yMax)
            newsBlock.scrollBox.sb.thumb.y = yMax;
           
        var sp:Number = newsBlock.scrollBox.sb.thumb.y / yMax;

       
        TweenMax.to(newsBlock.scrollBox.content, 1, {y:(-sp*(newsBlock.scrollBox.content.height-newsBlock.scrollBox.masker.height)), ease:Expo.easeOut});


        e.updateAfterEvent();
    }

    //*********i think the problem lies above here************************//   
       
       
       
       
    //position the dots in the center

    var dotsWidth:int = dotsHolder.width;
    dotsHolder.x = -dotsWidth/2 + dots.width/2;

    TweenMax.to( dotCollection[ currentDot ].dotCenter, 0.25, {tint:0x0066CC, ease:Expo.easeOut});

    }

  2. #2
    Senior Member
    Join Date
    May 2000
    Posts
    814
    I just need a little clue on where to look, has anyone got an opinion.

    cheers
    Rat

  3. #3
    Senior Member
    Join Date
    May 2000
    Posts
    814
    can anyone give me a pointer, i'm still stuck. ;(

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