当动态滚动文本到达底部时,可以调用Flash(AS3)函数吗?

时间:2014-11-21 16:51:41

标签: actionscript-3 flash

在用户滚动到Flash AS3中动态文本框的底部后,想要执行动画。如果重要,则动态加载文本。

2 个答案:

答案 0 :(得分:2)

这样的事情可以解决问题:

        myTextField.addEventListener(Event.SCROLL, scrollHandler);

        function scrollHandler(e:Event):void {
            if (myTextField.scrollV >= myTextField.maxScrollV) {
                trace("You've Reached The End - It happens to us all eventually");
                //do your animation
            }
        }

答案 1 :(得分:0)

我搜索并最后部署在我的项目中。这是工作代码。非常感谢你给我提供了大部分解决方案。

private var mcScrolll:mcScroll;
        private var mcBolgee:mcBolge;
        private function Scroll_Method_New():void 
        {
            tempBGBmp = new TempBG();
            this.addChild(tempBGBmp);
            tempBGBmp.x = 0;            
            tempBGBmp.y = 0;


            if (!trainer_Maria_text)    
                trainer_Maria_text = new TextField();
            createTextWithXY(trainer_Maria_text, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at augue vitae est bibendum egestas. Fusce molestie felis nec arcu tincidunt dictum. Morbi dapibus vitae tortor non fringilla. Proin consectetur sapien ut eleifend ullamcorper. Duis blandit laoreet hendrerit. Duis sit amet massa sit amet tortor consequat dignissim sed vitae nisl. Vivamus vel lobortis odio. Sed id posuere dolor, eget auctor est. Donec sapien libero, bibendum ac .", 0, 0, 400, 41 );

            //trainer_Maria_text.scrollRect = view;
            //tempBGBmp.bar
            //trainer_Maria_text.scrollRect.x = 50;
            //trainer_Maria_text.scrollRect.y = 50;
             //trainer_Maria_text.scrollV = 1;


            /*mcScrollZone = new mcScrollZonecopy();
            this.addChild(mcScrollZone);
            mcScrollZone.x = 0;
            mcScrollZone.y = 0;*/

            mcScrolll = new mcScroll();
            this.addChild(mcScrolll);
            mcScrolll.x = 600;
            mcScrolll.y = 50;

            mcBolgee = new mcBolge();
            this.addChild(mcBolgee);
            mcBolgee.x = 600;
            mcBolgee.y = 50;

            var rect:Rectangle = new Rectangle(mcBolgee.x, mcBolgee.y, 0, mcBolgee.height - 90);

            //MouseWheelTrap.setup(stage);

            mcScrolll.addEventListener(MouseEvent.MOUSE_DOWN, StartDrag);
            //mcScrolll.addEventListener(MouseEvent.MOUSE_, StartDrag);

            mcScrolll.buttonMode = true;
            stage.addEventListener(MouseEvent.MOUSE_UP, StopStageDrag);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, ScrollBody);
            //mcScrollZone.mcText.addEventListener(Event.CHANGE, SetScroll);
            //tempBGBmp.addEventListener(Event.CHANGE, SetScroll);

            /*function SetScroll(event:Event):void
            { 
                            mcScrolll.y = 295;
                            //mcScrollZone.y = -(((mcScrolll.y - mcBolgee.y)*((mcScrollZone.height /*- mcMask.height*/)/(295 - mcBolgee.y)))) + mcBolgee.y;
                            tempBGBmp.y = -(((mcScrolll.y - mcBolgee.y)*((tempBGBmp.height /*- mcMask.height*/)/(295 - mcBolgee.y)))) + mcBolgee.y;
                            trainer_Maria_text.y = -(((mcScrolll.y - mcBolgee.y)*((trainer_Maria_text.height /*- mcMask.height*/)/(295 - mcBolgee.y)))) + mcBolgee.y;
            }*/
            var control:Boolean = false;
            function StopStageDrag(event:MouseEvent):void
            {
                            if(control)
                            {
                                    mcScrolll.gotoAndStop(1);
                                    control = false;
                                    mcScrolll.stopDrag();
                            }
            }
            function StartDrag(event:MouseEvent):void
            {
                            event.currentTarget.gotoAndStop(2);
                            control = true;
                            event.currentTarget.startDrag(false,rect);
            }
            function ScrollBody(event:MouseEvent):void
            {
                            //mcScrollZone.mcText.autoSize = TextFieldAutoSize.CENTER;
                            if(control)
                            {
                                //mcScrollZone.y = -(((mcScrolll.y - mcBolgee.y)*((mcScrollZone.height /*- mcMask.height*/)/(296 - mcBolgee.y)))) + mcBolgee.y;                                                                                                                                                                                                                                                                                                                                                                           
                                tempBGBmp.y = -(((mcScrolll.y - mcBolgee.y)*((tempBGBmp.height /*- mcMask.height*/)/(296 - mcBolgee.y)))) + mcBolgee.y;                                                                                                                                                                                                                                                                                                                                                                           
                                trainer_Maria_text.y = -(((mcScrolll.y - mcBolgee.y)*((trainer_Maria_text.height /*- mcMask.height*/)/(296 - mcBolgee.y)))) + mcBolgee.y;                                                                                                                                                                                                                                                                                                                                                                           
                            }
            }