Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Помощь добавления фото в поигрыватель (http://www.flasher.ru/forum/showthread.php?t=170464)

pickaxe 25.10.2011 14:57

Помощь добавления фото в поигрыватель
 
Вложений: 1
Подгружаю данные с XML файла. С текстом нет проблем. Автор, время, композиция, все ок. А вот картинку не могу вставить. Не отображается.

Вот проигрыватель
Вложение 27188

Вот скрипт
Код AS1/AS2:

var songs:Array = new Array();
var curtrack:Number = 0;
var playingsong:Sound = new Sound();
if (_root.playlist == undefined || _root.playlist == "") {
        _root.playlist = "playlist.xml";
}
 
var playlistXml:XML = new XML();
playlistXml.ignoreWhite = true;
playlistXml.load(_root.playlist);
playlistXml.onLoad = function() {
        loadSongs();
        loadplaylistbox();
        if (_root.autostart == "false") {
                toggleplaypause();
        }
};
 
 
function loadSongs() {
        for (songIndex=0; songIndex<playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
                var songdata:Object = new Object();
                for (songNode=0; songNode<playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes.length; songNode++) {
                        switch(playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].nodeName){
                        case "number":
                                songdata.number = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        case "image":
                                songdata.image = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        case "time":
                                songdata.time = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        case "creator":
                                songdata.artist = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        case "title":
                                songdata.title = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        case "location":
                                songdata.location = playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode].childNodes[0].nodeValue;
                                break;
                        }
                }
                songs[songIndex] = songdata;
        }
}
function loadSong(track) {
        playingsong = new Sound();
        playingsong.loadSound(songs[track].location, true);
        playingsong.start(0);
        updatevolume();
        playingsong.onSoundComplete = function() {
                loadSong((curtrack+1)%(songs.length));
        };
        playpause.gotoAndStop(1);
        playpause.playpausebutton.onPress = function() {
                toggleplaypause();
        };
        songdisplay.text = songs[track].number+"  "+songs[track].artist+" - "+songs[track].title;
        eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".playlistitemhighlight")._alpha = 4;
        eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlistitemhighlight")._alpha = 20;
        curtrack = track;
}
function loadplaylistbox() {
        for (songIndex=0; songIndex<playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
                playlistbox.playlistitemcontainer.attachMovie("playlistitem", "playlistitem"+songIndex, playlistbox.playlistitemcontainer.getNextHighestDepth(), {_x:0, _y:42*songIndex});
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtextn").text = songs[songIndex].number;
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtextn").loadMovie = songs[songIndex].image;
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtexttm").text = songs[songIndex].time;
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtexta").text = songs[songIndex].artist;
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtextt").text = songs[songIndex].title;
                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).songindex = songIndex;
        }
}
playpause.playpausebutton.onPress = function() {
        toggleplaypause();
};
function toggleplaypause() {
        if (playpause._currentframe == 1) {
                playpause.gotoAndStop(2);
                playpause.curpos = playingsong.position;
                playingsong.stop();
        } else {
                playpause.gotoAndStop(1);
                playingsong.start(playpause.curpos/1000, 0);
        }
        playpause.playpausebutton.onPress = function() {
                toggleplaypause();
        };
}
onEnterFrame = function () {
        if (songdisplay.movingright) {
                songdisplay.hscroll -= 10;
                if (songdisplay.hscroll<=0) {
                        songdisplay.movingright = false;
                }
        } else {
                songdisplay.hscroll += 10;
                if (songdisplay.hscroll>=songdisplay.maxhscroll) {
                        songdisplay.movingright = true;
                }
        }
        if (!draggingslider) {
                progressslider._x = (playingsong.position/playingsong.duration)*343+149;
                if (progressslider._x == 0) {
                        progressslider._x = 149;
                }
        }
        if (draggingplaylistscroller) {
                updateplaylistscroll();
        }
        if (draggingvolmeslider) {
                updatevolume();
        }
        tempsongtime = "";
        if (Math.floor(playingsong.position/60000) == 0) {
                tempsongtime += "0";
        } else {
                tempsongtime += Math.floor(playingsong.position/60000);
        }
        tempsongtime += ":";
        if (Math.floor((playingsong.position/1000)%60)<10) {
                tempsongtime += "0";
        }
        tempsongtime += Math.floor((playingsong.position/1000)%60);
        tempsongtime += "/";
        if (Math.floor(playingsong.duration/60000) == 0) {
                tempsongtime += "0";
        } else {
                tempsongtime += Math.floor(playingsong.duration/60000);
        }
        tempsongtime += ":";
        if (Math.floor((playingsong.duration/1000)%60)<10) {
                tempsongtime += "0";
        }
        tempsongtime += Math.floor((playingsong.duration/1000)%60);
        songtime.text = tempsongtime;
        //trace(Math.floor(playingsong.position/60000));
        //if(Math.floor(playingsong.position/1000)%60)
        //songtime.text=Math.floor(playingsong.position/1000)%60+"/"+Math.floor(playingsong.duration/1000)%60;
};
progressslider.onPress = function() {
        draggingslider = true;
        progressslider.startDrag(true, 149, progressslider._y, 343, progressslider._y);
};
progressslider.onRelease = progressslider.onReleaseOutside=function () {
        progressslider.stopDrag();
        playingsong.start(((progressslider._x-149)/343)*playingsong.duration/1000, 0);
        playpause.gotoAndStop(1);
        playpause.playpausebutton.onPress = function() {
                toggleplaypause();
        };
        draggingslider = false;
};
progressbar.onPress = function() {
        playingsong.start(((_xmouse-149)/343)*playingsong.duration/1000, 0);
        playpause.gotoAndStop(1);
        playpause.playpausebutton.onPress = function() {
                toggleplaypause();
        };
};
volumebar.onPress = function() {
        draggingvolmeslider = true;
        volumebar.volumeslider.startDrag(true, 0, volumebar.volumeslider._y, 120, volumebar.volumeslider._y);
};
volumebar.onRelease = volumebar.onReleaseOutside=function () {
        draggingvolmeslider = false;
        volumebar.volumeslider.stopDrag();
        updatevolume();
};
function updatevolume() {
        playingsong.setVolume((volumebar.volumeslider._x/120)*100);
}
previoussong.onPress = function() {
        loadprevioussong();
};
function loadprevioussong() {
        var loadtrack = (curtrack-1)%(songs.length);
        if (loadtrack<0) {
                loadtrack = songs.length-1;
        }
        loadSong(loadtrack);
}
nextsong.onPress = function() {
        loadnextsong();
};
function loadnextsong() {
        var loadtrack = (curtrack+1)%(songs.length);
        loadSong(loadtrack);
}
playlistscroller.onPress = function() {
        draggingplaylistscroller = true;
        playlistscroller.startDrag(true, 361, 118, 361, 280);
};
playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
        draggingplaylistscroller = false;
        playlistscroller.stopDrag();
};
playlistscrollup.onPress = function() {
        playlistscroller._y = Math.max(118, playlistscroller._y-10);
        updateplaylistscroll();
};
playlistscrolldown.onPress = function() {
        playlistscroller._y = Math.min(280, playlistscroller._y+10);
        updateplaylistscroll();
};
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta:Number) {
        playlistscroller._y = Math.min(280, Math.max(118, playlistscroller._y-delta));
        updateplaylistscroll();
};
Mouse.addListener(mouseListener);
playlistscrollbar.onPress = function() {
        playlistscroller._y = Math.min(280, Math.max(118, _ymouse));
        updateplaylistscroll();
};
function updateplaylistscroll() {
        playlistbox.playlistitemcontainer._y = -((playlistscroller._y-118)/118)*(playlistbox.playlistitemcontainer._height-249);
}
 
var myMenu = new ContextMenu();
var menubezz = new ContextMenuItem("Mp3 Player", visitswfspot);
myMenu.customItems.push(menubezz);
var menuplaypause = new ContextMenuItem("Play / Pause", toggleplaypause);
menuplaypause.separatorBefore = true;
myMenu.customItems.push(menuplaypause);
var menuprevioustrack = new ContextMenuItem("Previous Song", loadprevioussong);
myMenu.customItems.push(menuprevioustrack);
var menunexttrack = new ContextMenuItem("Next Song", loadnextsong);
myMenu.customItems.push(menunexttrack);
myMenu.hideBuiltInItems();
_root.menu = myMenu;


mooncar 25.10.2011 16:25

Это что за запись такая?
Код AS1/AS2:

eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtextn").loadMovie = songs[songIndex].image;

Используйте MovieClipLoader.
Или, если уж на то пошло, посмотрите синтаксис loadMovie - у метода либо у функции.

pickaxe 27.10.2011 11:13

Все равно не работает, не отображает


Часовой пояс GMT +4, время: 18:03.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.