第一帧中的类。

时间:2011-10-21 16:11:59

标签: actionscript-3 flash-cs5

好的,现在我做好了准备。我有完美的网站。但是当把每件东西压缩到一帧时。它停止工作。我唯一想改变的是我在IDE中删除了补间。

框架中的代码

stop();
import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.Strong;
import flash.events.Event;
var vektor:Array = new Array(I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII);
var menu:Wyjazd = new Wyjazd(vektor,firmaBTN,kontaktBTN,ofertaBTN,naglowek,tekst,dane);

ofertaBTN.addEventListener(MouseEvent.CLICK, test);
function test(e:MouseEvent):void
{
    trace(String("click"));
}

Wyjazd班的代码

package 
{
    import fl.transitions.Tween;
    import fl.motion.easing.*;
    import flash.filters.*;
    import flash.events.MouseEvent;
    import flash.display.Stage;
    import flash.display.MovieClip;
    import flash.ui.Mouse;
    import flash.display.*;
    import flash.events.Event;
    public class Wyjazd extends MovieClip
    {
        public function Wyjazd(ar:Array=null,firma:Object=null,kontakt:Object=null,oferta:Object=null,naglowek:Object=null,tekst:Object=null,dane:Object=null)
        {
            /*
            if (ar!=null)
            {

            init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
            }
            */
            if (stage)
            {
                init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
            }
            else
            {
                addEventListener(Event.ADDED_TO_STAGE, init);
            }

        }

        public function init(ar:Array,firma:Object=null,kontakt=null,oferta:Object=null,naglowek:Object=null,tekst:Object=null,dane:Object=null):void
        {

            //Zmienne "globalne" dla funkcji
            var time:Number;
            var wciecie:Number;
            var wciecie2:Number;
            var offset:Number = 15.65;
            var offset2:Number = 20;
            var posX:Array = new Array(12);
            var posY:Array = new Array(12);
            var spr:Array = new Array(12);
            var targetLabel:String;
            var wybranyOb:Object = ar[0];
            var names:Array = new Array('Szkolenie wstępne BHP','Szkolenie okresowe BHP','Szkolenie P.Poż','Kompleksowa obsługa P.Poż','Pomiar środowiska pracy','Szkolenie z udzielania pierwszej pomocy','Ocena ryzyka zawodowego','Przeprowadzanie postępowań po wypadkowych','Przeprowadzanie audytów wewnętrznych ISO','Hałas w środowisku komunalnym','Medycyna pracy','Szkolenia dla kierowców');
            //Pobieranie pozycji
            for (var i:Number = 0; i<ar.length; i++)
            {
                posX[i] = ar[i].x;
                posY[i] = ar[i].y;
                trace(String("klasa"));

            }



            //Filtry
            function increaseBlur(e:MouseEvent,docPos:Number):void
            {
                var myBlur:BlurFilter =new BlurFilter();
                myBlur.quality = 3;
                myBlur.blurX = 10;
                myBlur.blurY = 0;
            }
            //Funkcje
            function startPos():void
            {
                time = 0.2;
                for (var i:Number = 0; i<ar.length; i++)
                {
                    //if (wybranyOb.name == ar[i].name)
                    //{
                    //var wybranyPos:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],0.01,true);
                    //wybranyPos = new Tween(ar[i],"y",Linear.easeOut,-30,posY[i],time,true);
                    //}
                    //else
                    //{
                    var position:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
                    position = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
                    //}
                    //time = 0.2;
                }
                position = new Tween(naglowek,"x",Linear.easeOut,naglowek.x,2000,time,true);
                position = new Tween(tekst,"x",Linear.easeOut,tekst.x,2000,time,true);
                position = new Tween(dane,"x",Linear.easeOut,dane.x,2000,0.25,true);
            }

            //Nasłuchy
            oferta.addEventListener(MouseEvent.CLICK, wyskokOferta);
            oferta.addEventListener(MouseEvent.MOUSE_OVER,glowOferta);
            oferta.addEventListener(MouseEvent.MOUSE_OUT,unglowOferta);
            kontakt.addEventListener(MouseEvent.CLICK,wyskokKontakt);
            kontakt.addEventListener(MouseEvent.MOUSE_OVER,glowKontakt);
            kontakt.addEventListener(MouseEvent.MOUSE_OUT,unglowKontakt);
            firma.addEventListener(MouseEvent.CLICK,wyskokFirma);
            firma.addEventListener(MouseEvent.MOUSE_OVER,glowFirma);
            firma.addEventListener(MouseEvent.MOUSE_OUT,unglowFirma);
            function glowFirma(e:MouseEvent):void
            {
                var myGlow:GlowFilter=new GlowFilter();
                myGlow.color = 0xe6da13;
                myGlow.inner = true;
                firma.filters = [myGlow];
            }
            function unglowFirma(e:MouseEvent):void
            {
                firma.filters = [];
            }
            function glowKontakt(e:MouseEvent):void
            {
                var myGlow:GlowFilter=new GlowFilter();
                myGlow.color = 0xe6da13;
                myGlow.inner = true;
                kontakt.filters = [myGlow];
            }
            function unglowKontakt(e:MouseEvent):void
            {
                kontakt.filters = [];
            }
            function glowOferta(e:MouseEvent):void
            {
                var myGlow:GlowFilter=new GlowFilter();
                myGlow.color = 0xe6da13;
                myGlow.inner = true;
                oferta.filters = [myGlow];
            }
            function unglowOferta(e:MouseEvent):void
            {
                oferta.filters = [];
            }
            function wyskokKontakt(e:MouseEvent):void
            {
                startPos();
                var tweenKontakt = new Tween(dane,"x",Linear.easeOut,2000,350,0.25,true);

            }
            function wyskokFirma(e:MouseEvent):void
            {
                startPos();
                trace("Firma");
            }
            function wyskokOferta(e:MouseEvent):void
            {

                time = 0.2;
                wciecie = 52.5;
                wciecie2 = 67.45;
                for (var i:Number = 0; i < ar.length; i++)
                {

                    var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,oferta.x + wciecie,time,true);
                    tween = new Tween(ar[i],"y",Sine.easeOut,ar[i].y,oferta.y + wciecie2,time,true);

                    ar[i].addEventListener(MouseEvent.CLICK,onClick);
                    spr[i] = i;

                    time +=  0.02;
                    wciecie +=  offset;
                    wciecie2 +=  offset2;
                }
            }

            function onClick(e:MouseEvent)
            {
                startPos();
                time = 0.2;
                var k:Number = 0;
                targetLabel = e.currentTarget.name;

                for (var i:Number = 0; i < ar.length; i++)
                {
                    if (targetLabel==ar[i].name)
                    {
                        //wybranyOb = ar[i];
                        var tween:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
                        tween = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
                        tween = new Tween(naglowek,"x",Linear.easeOut,2000,60,0.2,true);
                        tween = new Tween(tekst,"x",Linear.easeOut,2000,500,0.25,true);
                        naglowek.text = names[i];


                    }
                    else
                    {
                        var tween1:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
                        tween1 = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
                    }
                    //time +=  0.02;
                }

            }


        }

    }
}

它看起来像框架。 http://www.dropmocks.com/mbe3j

1 个答案:

答案 0 :(得分:0)

你应该从init中获取所有(嵌套)函数。

所以它更像是这样:

package 
{
import fl.transitions.Tween;
import fl.motion.easing.*;
import flash.filters.*;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.display.*;
import flash.events.Event;
public class Wyjazd extends MovieClip
{
    public function Wyjazd(ar:Array=null,firma:Object=null,kontakt:Object=null,oferta:Object=null,naglowek:Object=null,tekst:Object=null,dane:Object=null)
    {
        /*
        if (ar!=null)
        {

        init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
        }
        */
        if (stage)
        {
            init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
        }
        else
        {
            addEventListener(Event.ADDED_TO_STAGE, init);
        }
    }

    public function init(ar:Array,firma:Object=null,kontakt=null,oferta:Object=null,naglowek:Object=null,tekst:Object=null,dane:Object=null):void
    {
        //Zmienne "globalne" dla funkcji
        var time:Number;
        var wciecie:Number;
        var wciecie2:Number;
        var offset:Number = 15.65;
        var offset2:Number = 20;
        var posX:Array = new Array(12);
        var posY:Array = new Array(12);
        var spr:Array = new Array(12);
        var targetLabel:String;
        var wybranyOb:Object = ar[0];
        var names:Array = new Array('Szkolenie wstępne BHP','Szkolenie okresowe BHP','Szkolenie P.Poż','Kompleksowa obsługa P.Poż','Pomiar środowiska pracy','Szkolenie z udzielania pierwszej pomocy','Ocena ryzyka zawodowego','Przeprowadzanie postępowań po wypadkowych','Przeprowadzanie audytów wewnętrznych ISO','Hałas w środowisku komunalnym','Medycyna pracy','Szkolenia dla kierowców');
        //Pobieranie pozycji
        for (var i:Number = 0; i<ar.length; i++)
        {
            posX[i] = ar[i].x;
            posY[i] = ar[i].y;
            trace(String("klasa"));
        }
        //Nasłuchy
        oferta.addEventListener(MouseEvent.CLICK, wyskokOferta);
        oferta.addEventListener(MouseEvent.MOUSE_OVER,glowOferta);
        oferta.addEventListener(MouseEvent.MOUSE_OUT,unglowOferta);
        kontakt.addEventListener(MouseEvent.CLICK,wyskokKontakt);
        kontakt.addEventListener(MouseEvent.MOUSE_OVER,glowKontakt);
        kontakt.addEventListener(MouseEvent.MOUSE_OUT,unglowKontakt);
        firma.addEventListener(MouseEvent.CLICK,wyskokFirma);
        firma.addEventListener(MouseEvent.MOUSE_OVER,glowFirma);
        firma.addEventListener(MouseEvent.MOUSE_OUT,unglowFirma);

    }

    public function glowFirma(e:MouseEvent):void
    {
        var myGlow:GlowFilter=new GlowFilter();
        myGlow.color = 0xe6da13;
        myGlow.inner = true;
        firma.filters = [myGlow];
    }
    public function unglowFirma(e:MouseEvent):void
    {
        firma.filters = [];
    }
    public function glowKontakt(e:MouseEvent):void
    {
        var myGlow:GlowFilter=new GlowFilter();
        myGlow.color = 0xe6da13;
        myGlow.inner = true;
        kontakt.filters = [myGlow];
    }
    public function unglowKontakt(e:MouseEvent):void
    {
        kontakt.filters = [];
    }
    public function glowOferta(e:MouseEvent):void
    {
        var myGlow:GlowFilter=new GlowFilter();
        myGlow.color = 0xe6da13;
        myGlow.inner = true;
        oferta.filters = [myGlow];
    }
    public function unglowOferta(e:MouseEvent):void
    {
        oferta.filters = [];
    }
    public function wyskokKontakt(e:MouseEvent):void
    {
        startPos();
        var tweenKontakt = new Tween(dane,"x",Linear.easeOut,2000,350,0.25,true);
    }
    public function wyskokFirma(e:MouseEvent):void
    {
        startPos();
        trace("Firma");
    }
    public function wyskokOferta(e:MouseEvent):void
    {
        time = 0.2;
        wciecie = 52.5;
        wciecie2 = 67.45;
        for (var i:Number = 0; i < ar.length; i++)
        {
            var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,oferta.x + wciecie,time,true);
            tween = new Tween(ar[i], "y", Sine.easeOut, ar[i].y, oferta.y + wciecie2, time, true);

            ar[i].addEventListener(MouseEvent.CLICK,onClick);
            spr[i] = i;

            time +=  0.02;
            wciecie +=  offset;
            wciecie2 +=  offset2;
        }
    }


    //Filtry
    public function increaseBlur(e:MouseEvent,docPos:Number):void
    {
        var myBlur:BlurFilter =new BlurFilter();
        myBlur.quality = 3;
        myBlur.blurX = 10;
        myBlur.blurY = 0;
    }
    //Funkcje
    public function startPos():void
    {
        time = 0.2;
        for (var i:Number = 0; i<ar.length; i++)
        {
            //if (wybranyOb.name == ar[i].name)
            //{
            //var wybranyPos:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],0.01,true);
            //wybranyPos = new Tween(ar[i],"y",Linear.easeOut,-30,posY[i],time,true);
            //}
            //else
            //{
            var position:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
            position = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
            //}
            //time = 0.2;
        }
        position = new Tween(naglowek,"x",Linear.easeOut,naglowek.x,2000,time,true);
        position = new Tween(tekst,"x",Linear.easeOut,tekst.x,2000,time,true);
        position = new Tween(dane,"x",Linear.easeOut,dane.x,2000,0.25,true);
    }

    public function onClick(e:MouseEvent)
    {
        startPos();
        time = 0.2;
        var k:Number = 0;
        targetLabel = e.currentTarget.name;

        for (var i:Number = 0; i < ar.length; i++)
        {
            if (targetLabel==ar[i].name)
            {
                //wybranyOb = ar[i];
                var tween:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
                tween = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
                tween = new Tween(naglowek,"x",Linear.easeOut,2000,60,0.2,true);
                tween = new Tween(tekst,"x",Linear.easeOut,2000,500,0.25,true);
                naglowek.text = names[i];
            }
            else
            {
                var tween1:Tween = new Tween(ar[i],"x",Linear.easeOut,ar[i].x,posX[i],time,true);
                tween1 = new Tween(ar[i],"y",Linear.easeOut,ar[i].y,posY[i],time,true);
            }
            //time +=  0.02;
        }
    }
}
}

如果这没有帮助,您应该发布更多详细信息。我不知道你是如何将所有内容压缩成单个框架的,但我建议你阅读更多关于面向对象编程的内容。

快速Google搜索产生了this article,这可能会帮助您在Action Script 3中使用面向对象的编程。