0

提前感谢大家的帮助。我做了一个 100% flash 背景拉伸...这是 main.as 的代码:

package {

import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.net.navigateToURL;
    import flash.net.URLRequest;
import flash.events.MouseEvent;


public class Main extends MovieClip

{
    public function Main()
    {
        init();

        checkResize();

    clip_mc.addEventListener(MouseEvent.CLICK, siteNav1);

    clip_amministra.addEventListener(MouseEvent.CLICK, siteNav2);


    clip_chisiamo.addEventListener(MouseEvent.CLICK, siteNav4);

    }

    function siteNav1(e:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.amicolibro.org/index.php"), "_self");

    }

    function siteNav2(e:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.amicolibro.org/log-in-amministratore.php"), "_self");

    }


    function siteNav4(e:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.amicolibro.org/chi-siamo.php"), "_self");

    }                           

    private function init():void
    {
        stage.frameRate=31;

        bg_mc.x=0;
        bg_mc.y=0;
        bg_mc.width=stage.stageWidth;
        bg_mc.height=stage.stageHeight;

        clip_mc.x=stage.stageWidth/6.3;
        clip_mc.y=stage.stageHeight/2.2;

        clip_amministra.x=stage.stageWidth/1.3;
        clip_amministra.y=stage.stageHeight/2;


              clip_chisiamo.x=stage.stageWidth/10;
        clip_chisiamo.y=stage.stageHeight/1.19; 

    }

    private function checkResize():void
    {
        stage.addEventListener(Event.RESIZE, resizeStage);
    }

    private function resizeStage(event:Event):void 
    {
        init();
    }

}
}

是否可以按比例调整按钮 clip_mc、clip_amministra、clip_chisiamo 的大小?

谢谢

4

2 回答 2

0

我以这种方式解决了:

包裹 {

import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.net.navigateToURL;
    import flash.net.URLRequest;
import flash.events.MouseEvent;


public class Main extends MovieClip

{
    public function Main()
    {
        init();

        resizeHandler();

        checkResize();

    clip_mc.addEventListener(MouseEvent.CLICK, siteNav1); 

    clip_amministra.addEventListener(MouseEvent.CLICK, siteNav2);

    clip_chisiamo.addEventListener(MouseEvent.CLICK, siteNav4);


    }

    function siteNav1(e:MouseEvent):void {                                       
    navigateToURL(new URLRequest("http://www.amicolibro.org/index.php"), "_self");

    }

    function siteNav2(e:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.amicolibro.org/log-in-amministratore.php"), "_self");

           }

    function siteNav4(e:MouseEvent):void {
    navigateToURL(new URLRequest("http://www.amicolibro.org/chi-siamo.php"), "_self");

    }


    private function init():void
    {
        stage.frameRate=31;

        bg_mc.x=0;                           
        bg_mc.y=0;
        bg_mc.width=stage.stageWidth;
        bg_mc.height=stage.stageHeight;

        clip_mc.x=stage.stageWidth/6.3;  
        clip_mc.y=stage.stageHeight/2.2;  

        clip_amministra.x=stage.stageWidth/2.7; 
        clip_amministra.y=stage.stageHeight/4.9; 


            clip_chisiamo.x=stage.stageWidth/10;
        clip_chisiamo.y=stage.stageHeight/1.19;

        }       


    private function resizeHandler(event:Event=null):void  //resize buttons

          {

           var sw:Number = stage.stageWidth;
           var sh:Number = stage.stageHeight;



          clip_mc.width = sw /8;         // clip_mc is 1/8 as wide as the stage..can change this number to be whatever works best
      clip_mc.height = sh /8;    // clip_mc is 1/8 as high as the stage..can change this number to be whatever works best

          clip_amministra.width = sw /10;     // clip_amministra is 1/10 as wide as the stage..can change this number to be whatever works best
      clip_amministra.height = sw /10;    // clip_amministra is 1/10 as high as the stage..can change this number to be whatever works best


      clip_chisiamo.width = sw /6;        //clip_chisiamo is 1/6 as wide as the stage..can change this number to be whatever works best
      clip_chisiamo.height = sh /6;     // clip_chisiamo is 1/6 as high as the stage..can change this number to be whatever works best



      clip_mc.scaleX <= clip_mc.scaleY ? (clip_mc.scaleX = clip_mc.scaleY) : (clip_mc.scaleY = clip_mc.scaleX); // keeps clip_mc proportional 

      clip_amministra.scaleX <= clip_amministra.scaleY ? (clip_amministra.scaleX = clip_amministra.scaleY) : (clip_amministra.scaleY = clip_amministra.scaleX); // keeps clip_amministra proportional

      clip_chisiamo.scaleX <= clip_chisiamo.scaleY ? (clip_chisiamo.scaleX = clip_chisiamo.scaleY) : (clip_chisiamo.scaleY = clip_chisiamo.scaleX); // keeps clip_chisiamo proportional


                 }

      private function checkResize():void
    {
        stage.addEventListener(Event.RESIZE, resizeStage);
    }

      private function resizeStage(event:Event):void 
    {
        init();
    }
    }
}

谢谢

于 2012-07-28T11:46:49.960 回答
0

如果对象靠得太近或重叠,听起来您想要一种调整对象大小的方法?

这是您可以解决此问题的一种可能方法。有更好的方法可以做更多的工作,但这是最简单的。

做一个简单的相对大小。这不会很精确,但会非常快并且可能会满足您的需求。假设 400x500(例如,调整这些值直到获得正确的数量)是舞台在它们开始重叠之前可以达到的本机按钮大小的最小值,然后将其用作您的 init() 方法(以及两个新的全球:

    private function init():void
    {
        var minWidth:Number = 400; //change this number to be whatever works best
        var minHeight:Number = 500; //change this number to be whatever works best

        stage.frameRate=31;

        bg_mc.x=0;
        bg_mc.y=0;
        bg_mc.width=stage.stageWidth;
        bg_mc.height=stage.stageHeight;

        clip_mc.x=stage.stageWidth/6.3;
        clip_mc.y=stage.stageHeight/2.2;

        clip_amministra.x=stage.stageWidth/1.3;
        clip_amministra.y=stage.stageHeight/2;

        clip_chisiamo.x=stage.stageWidth/10;
        clip_chisiamo.y = stage.stageHeight / 1.19; 

    //this is the new stuff
        var scaleAmount:Number = 1;
        if (stage.stageWidth < minWidth || stage.stageHeight < minHeight) {
            if (minWidth / stage.stageWidth < minHeight / stage.stageHeight) {
                scaleAmount = (minWidth / stage.stageWidth);
            }else{
                scaleAmount = minHeight / stage.stageHeight;
            }
        }

        //do this for all your buttons scaleX and scaleY properties, i'm assuming clip_mc, clip_amministra and clip_chisiamo are some of your button instances.
        clip_mc.scaleX = scaleAmount;
        clip_mc.scaleY = scaleAmount;

        clip_amministra.scaleX = scaleAmount;
        clip_amministra.scaleY = scaleAmount;

        clip_chisiamo.scaleX = scaleAmount;
        clip_chisiamo.scaleY = scaleAmount;
    }
于 2012-07-25T17:13:01.063 回答