0

我稍后在按下切换状态并播放视频时将相同的图像(播放按钮)添加到电影剪辑中。

我想要完成的是自动切换默认图像,因为该视频正在自动播放。

        //Setup thumb Container
         thumbs = new Sprite();
        thumbs.addEventListener (MouseEvent.CLICK, playVideo);
        thumbs.x = thumbs_x;
        thumbs.y = thumbs_y;
            thumbs.buttonMode = true;
            main_container.addChild (thumbs);
    //Call Function that gets all the thumbs using loader and adds it to the thumb movieClip

    callThumbs ();
    setDefaultButton ();

    function callThumbs ():void {



        for (var i:Number = 0; i < my_total; i++) {



                var thumb_url = my_videos[i].@THUMB;
                var thumb_loader = new Loader();
                thumb_loader.name = i;
                trace(thumb_loader.name);
                thumb_loader.load (new URLRequest(root_path + thumb_url));
                thumb_loader.contentLoaderInfo.addEventListener (Event.COMPLETE, thumbLoaded);
                thumb_loader.y = (thumb_height+210)*i;

    }

        function thumbLoaded (e:Event):void {
        var my_thumb:Loader = Loader(e.target.loader);
        thumbs.addChild (my_thumb);
    }


function setDefaultButton ():void {
thumbs.getChildAt(0).dispatchEvent(new MouseEvent(MouseEvent.CLICK));
//or 
thumbs.getChildByName('0').dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}

因此,这与单击第一张图像的作用相同,但它会自动发生。

这是我的错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at LowesPlayerCS4_fla::MainTimeline/setDefaultButton()
    at LowesPlayerCS4_fla::MainTimeline/processXML()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
4

1 回答 1

1

尝试将 thumb_Loader 添加到 callThumbs 中的显示列表而不是 thumbLoaded。

于 2011-12-01T21:08:41.890 回答