Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
像我一样吗? import flash.net.URLLoader; import flash.events.Event; import flash.net.URLRequest; var loader:URLLoader = new URLLoader_Flash_Actionscript 3 - Fatal编程技术网

像我一样吗? import flash.net.URLLoader; import flash.events.Event; import flash.net.URLRequest; var loader:URLLoader = new URLLoader

像我一样吗? import flash.net.URLLoader; import flash.events.Event; import flash.net.URLRequest; var loader:URLLoader = new URLLoader,flash,actionscript-3,Flash,Actionscript 3,像我一样吗? import flash.net.URLLoader; import flash.events.Event; import flash.net.URLRequest; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE,xmlloaded); var xml:XML = new XML(); var amountofvid:Number=0; var currentvide

像我一样吗?
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,xmlloaded);

var xml:XML = new XML();
var amountofvid:Number=0;
var currentvideo:Number=0;

btn_prev.addEventListener (MouseEvent.CLICK, prevvid);
btn_next.addEventListener (MouseEvent.CLICK, nextvid);

loader.load(new URLRequest('videos.xml'));

function xmlloaded (e:Event) {
    xml=XML(e.target.data);
    amountofvid=xml.video.length ()-1;
    changevid();
}

function nextvid (e:Event) {
    currentvideo++;
    changevid();
}

function prevvid (e:Event) {
    currentvideo--;
    changevid();
}

function changevid():void {
    var cv:Number=Math.abs(currentvideo);

    if (cv>amountofvid) {
        currentvideo=cv=0;
    }
    if (currentvideo<0) {
        currentvideo=cv=amountofvid;
    }

    vid.source = xml.video.@src[cv];
    title.text = xml.video.@title[cv];

}
package  {

import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;    

public class mediaPlayer extends Sprite {

    private var loader:URLLoader;
    private var xml:XML;
    private var amountofvid:Number=0;
    private var currentvideo:Number=0;

    public function mediaPlayer() {

        loader = new URLLoader();
        loader.addEventListener(Event.COMPLETE,xmlloaded);
        btn_prev.addEventListener (MouseEvent.CLICK, prevvid);
        btn_next.addEventListener (MouseEvent.CLICK, nextvid);
        loader.load(new URLRequest('videos.xml'));

    }

    private function xmlloaded (e:Event) {
        xml = new XML();
        xml=XML(e.target.data);
        amountofvid=xml.video.length()-1;
        changevid();
    }

    public function nextvid (e:Event) {
        currentvideo++;
        changevid();
    }

    public function prevvid (e:Event) {
        currentvideo--;
        changevid();
    }

    private function changevid():void {
        var cv:Number=Math.abs(currentvideo);

        if (cv>amountofvid) {
            currentvideo=cv=0;
        }

        if (currentvideo<0) {
            currentvideo=cv=amountofvid;
        }

        vid.source = xml.video.@src[cv];
        title.text = xml.video.@title[cv];

    }

}

}
public class mediaPlayer extends Sprite {
// package encloses the class and identifies its scope
package you.com.app
{
    //imports
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.display.Sprite;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.text.TextField;

    /**
     * ... declare your class, whatever it may extend and any interfaces
     */

    public class MediaPlayer extends Sprite
    {
        // variables now include an access modifier to define their scope (private, here)
        private var xml             :XML;
        private var amountofvid     :Number=0;
        private var currentvideo    :Number=0;
        private var loader          :URLLoader;
        private var vid             :MovieClip; //or video component or whatever
        private var title           :TextField;
        private var btn_prev        :SimpleButton;
        private var btn_next        :SimpleButton;
        private var currentvideo    :int;

        /**
         * constructor - must match class name. returns statement omitted
         */
        public function MediaPlayer()
        {
            // call superclass
            super();
            //initialize procedure
            init();
        }

        private function init():void
        {
           //build display list
            assembleDisplayObjects();

            //grab data
            retreiveData();

        }

        private function retreiveData():void
        {
            loader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, xmlloaded);
            loader.load(new URLRequest('videos.xml')); 
        }

        private function xmlloaded (e:Event):void  
        {
            xml = new XML();
            xml=XML(e.target.data);
            amountofvid=xml.video.length ()-1;
            changevid();

            addEventHandlers(); //when data has loaded, activate clickables
        }

        private function assembleDisplayObjects():void
        {
            // create or instantiate display objects, and into the display list
            // adjust x,y values as needed
            vid = new MovieClip();
            this.addChild(vid);

            title = new TextField();
            this.addChild(title);

            btn_next = new SimpleButton();
            this.addChild(btn_next);

            btn_prev = new SimpleButton();
            this.addChild(btn_prev);
        }

        private function addEventHandlers():void
        {
            //centralized event listener control

            btn_prev.addEventListener (MouseEvent.CLICK, prevvid);
            btn_next.addEventListener (MouseEvent.CLICK, nextvid);
        }

        private function nextvid (e:Event):void 
        {
            currentvideo++;
            changevid();
        }

        private function prevvid (e:Event):void  
        {
            currentvideo--;
            changevid();
        }

        private function changevid():void 
        {
            var cv:Number=Math.abs(currentvideo);

            if (cv>amountofvid) {
                currentvideo=cv=0;
            }
            if (currentvideo<0) {
                currentvideo=cv=amountofvid;
            }

            vid.source = xml.video.@src[cv];
            title.text = xml.video.@title[cv];
        }

    }   

}