1120:未定义的属性_stop的访问属性、未定义、_stop

2023-09-09 21:55:22 作者:男人有大姨夫才公平

我在通过AS3 Flash中创建一个视频播放器有问题,问题是,每当我尝试编译项目,编译错误显示:

i am having problem in creating a video player in flash via as3, the problem is that whenever i try to compile the project, the compiler error shows:

1120: Access of undefined property _stop.
1120: Access of undefined property _pause.
1120: Access of undefined property _play.
1180: Call to a possibly undefined method Button.
1120: Access of undefined property _prev.
1180: Call to a possibly undefined method Button.
1120: Access of undefined property _next.

和这个不断将尽可能多的我所提到的这些对象,所以请帮我解决这个问题。并且是新手所以有点难受,找出错误。

And this keeps on going as much i've mentioned these objects, so please help me solve this. and am newbie so a bit hard for me to find the error.

AS3:

import flash.events.MouseEvent;

var _xmlLoader      :URLLoader      = null;

var _urlRequest     :URLRequest     = null;

var _xml            :XML            = null;

var _netConn        :NetConnection  = null;

var _netstr         :NetStream      = null;

var _video          :Video          = null; 

var _currentVideoId :int            = 0;

var _isPlaying      :Boolean        = false;

var _soundTransform :SoundTransform = new SoundTransform();

var _volume         :int            = 1;

var _duration       :Number         = 0;

function Init():void

{
    _urlRequest = new URLRequest("vids.xml");

    _xmlLoader = new URLLoader();
    _xmlLoader = new URLLoader(_urlRequest);
    _xmlLoader.addEventListener(Event.COMPLETE, XMLLoaded, false, 0, true);
}

function XMLLoaded($e:Event):void
{
    _xml = new XML($e.target.data);
}

function SetupVideo():void
{
    _netConn = new NetConnection();
    _netConn.addEventListener(NetStatusEvent.NET_STATUS, OnStatusEvent, false, 0, true);
    _netConn.connect(null);

}

function OnStatusEvent(stat:Object):void
{
    trace(stat.info.code);
    switch(stat.info.code)
    {
        case "NetConnection.Connect.Success":
             SetupNetStream();
             break;
        case "NetStream.Play.Stop":
             _stop.enabled = false;
             _pause.enabled = false;
             _play.enabled = true;
             _isPlaying = false;
             _netstr.close();
             break;
    }
}

function SetupNetStream():void
{
    _netstr = new NetStream(_netConn);
    _netstr.addEventListener(NetStatusEvent.NET_STATUS, OnStatusEvent, false, 0, true);

    var $customClient = new Object();
    $customClient.onMetaData = onMetaData;

    _netstr.client = $customClient

    _video = new Video(500, 250);
    _video.smoothing = true;
    _video.y
    _video.x = stage.stageWidth/2 - _video.width/2;
    _video.attachNetStream(_netstr);
    addChild(_video);
}

function onMetaData($info:Object):void 
{
    _duration = $info.duration;
}

function SetupButtons():void
{
    _prev.addEventListener(MouseEvent.CLICK, PreviousVideo, false, 0, true);
    _next.addEventListener(MouseEvent.CLICK,NextVideo,false,0,true);
    _play.addEventListener(MouseEvent.CLICK, PlayVideo, false, 0, true);
    _pause.addEventListener(MouseEvent.CLICK, PauseVideo, false, 0, true);
    _stop.addEventListener(MouseEvent.CLICK, StopVideo, false, 0, true);
    _sound.addEventListener(MouseEvent.CLICK, SoundVolume, false, 0, true);

    _stop.enabled = false;
    _pause.enabled = false;
    _prev.enabled = false;
    _next.enabled = false;
}

function PreviousVideo($e:MouseEvent):void
{
    _currentVideoId -=1;

    _stop.enabled = true;
    _pause.enabled = true;
    _play.enabled = false;

    if(_currentVideoId < 0)
    {
        _currentVideoId = _xml.video.length()-1;
    }

    _videoName.text = _xml.video[_currentVideoId].@name;
    _netstr.play(String(_xml.video[_currentVideoId].@path));
}

function NextVideo($e:MouseEvent):void
{
    _currentVideoId +=1;

    _stop.enabled = true;
    _pause.enabled = true;
    _play.enabled = false;

    if(_currentVideoId == _xml.video.length())
    {
        _currentVideoId = 0;
    }
    _videoName.text = _xml.video[_currentVideoId].@name;
    _netstr.play(String(_xml.video[_currentVideoId].@path));
}

function PlayVideo($e:MouseEvent):void
{
    _play.enabled= false;
    _next.enabled = true;
    _prev.enabled = true;
    _stop.enabled= true;
    _pause.enabled= true;

    if(_isPlaying == false)
    {
        _isPlaying = true;
        _netstr.play(String(_xml.video[_currentVideoId].@path));
        _videoName.text = _xml.video[_currentVideoId].@name;
        addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
    }else{
        _netstr.resume();
    }
}

function PauseVideo($e:MouseEvent):void
{
    _play.enabled= true;
    _pause.enabled= false;
    _netstr.pause();
}

function StopVideo($e:MouseEvent):void
{
    _stop.enabled= false;
    _pause.enabled= false;
    _play.enabled= true;

    _isPlaying = false;
    removeEventListener(Event.ENTER_FRAME, Update);
    _netstr.close();
}

function Update($e:Event):void
{
    _track.value = (_netstr.time / _duration) * _track.maximum;
}

function SoundVolume($e:MouseEvent):void
{
    if( _volume == 1 )
    {
        _volume = 0;
        _sound.label = "Sound On";
    }else{
        _volume = 1;
        _sound.label = "Sound Off";
    }

    _soundTransform.volume = _volume;
    _netstr.soundTransform = _soundTransform;
}

Init();
SetupVideo();
SetupButtons();

即使我已经转换这个反对按钮的符号。

And even i've converted this objects to button symbols.

推荐答案

也许你忘了为对象,作为_stop,_pause,_play按钮等指定实例名称。

Probably you forgot to assign instance name for the objects, which used as a _stop, _pause, _play buttons etc.

和还检查库属性中的导出为动作脚本标志。

And also check the "Export for the ActionScript" flag in the properties in the library.