开发者

I need to help about " Action Script 3 , public Function with Button "

开发者 https://www.devze.com 2023-02-28 20:57 出处:网络
Public function PencereyiGizle ( btn:Button ) { .... .... } I have a problem with the btn:Button 1046: Type was not found or was not a
Public function PencereyiGizle ( btn:Button )

{
....
....
}

I have a problem with the btn:Button

1046: Type was not found or was not a compile-time constant:Button..


package 
{
    import flash.display.MovieClip;
    import f开发者_如何学编程lash.display.NativeWindow;
    import flash.display.NativeWindowInitOptions;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.SimpleButton;


    public class PencereyiGizle extends MovieClip
    {
        public var natWindow:NativeWindow=new NativeWindow(
        new NativeWindowInitOptions());
        public var pencereyiAc_Btn:Button;

        public function PencereyiGizle(fro:Button)
        {
            pencereAc_Btn = fro;
            //Pencere ekleniyor
            natWindow.width = 500;
            natWindow.height = 400;
            natWindow.activate();
            natWindow.addEventListener(Event.CLOSING,pencereyiSakla);
            pencereyiAc_Btn.label = "Pencereyi Ac";
            pencereyiAc_Btn.addEventListener(MouseEvent.MOUSE_DOWN,pencereyiAktifEt);
        }
        //pencerenin kapanmasını engelleyip pencereyi gizliyoruz.;
        private function pencereyiSakla(e:Event):void
        {
            e.preventDefault();
            natWindow.visible = false;
        }

        //gizlenen pencereyi tekrar aktif hale getiriyoruz
        private function pencereyiAktifEt(e:MouseEvent):void
        {
            natWindow.activate();
        }
    }

}

N AIR;

import PencereyiGizle;

var firat:PencereyiGizle= new PencereyiGizle();
addChild(firat);

and then, i get that problem "1046: Type was not found or was not a compile-time constant:Button. "

I have a problem with the btn:Button


You should use the import statement to import "Button"

Depending on your requirements it could either be

  1. Spark Button

    import spark.components.Button;

  2. MX Button

    import mx.controls.Button

UPDATE: Looks like this page has an answer to your question. Specifically check THIS answer


you problem is your class PencereyiGizle is looking for a button to be passed as a reference in the constructor which you are not doing

var firat:PencereyiGizle= new PencereyiGizle();
addChild(firat);

you need to pass either an instance name of a button

var firat:PencereyiGizle= new PencereyiGizle( someButton );
addChild(firat);

or create a new button and pass it along

var someButton:Button = new button
var firat:PencereyiGizle= new PencereyiGizle( someButton );
addChild(firat);
0

精彩评论

暂无评论...
验证码 换一张
取 消