簡體   English   中英

當動態滾動文本到達底部時,可以調用Flash(AS3)函數嗎?

[英]Possible to call a Flash (AS3) function when dynamic scrolling text has reached the bottom?

在用戶滾動到Flash AS3中動態文本框的底部之后,想執行動畫。 如果重要,將動態加載文本。

這樣的事情應該可以解決問題:

        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
            }
        }

我搜索並最后在我的項目中進行部署。 它是工作代碼。 非常感謝您為我提供了大多數解決方案。

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;                                                                                                                                                                                                                                                                                                                                                                           
                            }
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM