1120: Access of undefined property _stop

一个人想着一个人 提交于 2019-12-11 17:33:24

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9854327/1120-access-of-undefined-property-stop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!