XML Flash 播放器

发布于 2024-11-19 14:03:34 字数 3444 浏览 1 评论 0原文

我想放置一个 Flash 图像库来读取 XML 并在我的网站上显示相关图像,但是我希望能够使用其 id 以编程方式获取 XML 中的某个幻灯片。例如,我的 XML 有 x 个幻灯片(我刚刚复制并粘贴了幻灯片并更改了 id)。作为示例,id 喜欢获取 id 为 2 的幻灯片元素。 如果我在 XSLT 中使用 XPath,我会执行类似“location/image_gallery/slideshow[@id = 2]”的操作。

<location>
<image_gallary>
    <slideshow id="1" width="230" height="145" speed="2">
       <image url="graphics/chesterfield.jpg" title="Market Walk" href="htle.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" /> 
    </slideshow>

    <slideshow id="3" width="230" height="145" speed="4">
       <image url="graphics/chesterfield.jpg" title="rket Walk" href="http://www.google.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" />
    </slideshow>

    <slideshow id="2" width="230" height="145" speed="3">
       <image url="graphics/chesterfield.jpg" title="rket Walk" href="http://www.google.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" />
    </slideshow>
</image_gallery>
</location>

*note that the id's can be in any order, i can hard code the actionscript to get to a particular slideshow, however id like to be able to programatically use the id and then call it in my xslt. Any help would be appreciated.

Im using actionscript 2.0. Here is what i have

import mx.transitions.Tween;
import mx.transitions.easing.*;

var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("xml/london_gb.xml");

myShowXML.onLoad = function() {

_root.myWidth = myShowXML.firstChild.childNodes[0].firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.childNodes[0].firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.childNodes[0].firstChild.attributes.speed;

_root.myImages = myShowXML.firstChild.firstChild.firstChild.childNodes;
_root.myImagesNo = myImages.length;

trace(myImages.length);

createContainer();
callImages();

};

function createContainer() {

_root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

myContainer_mc.lineTo(_root.myWidth,0);
myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
myContainer_mc.lineTo(0,_root.myHeight);
myContainer_mc.lineTo(0,0);

myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;

};

function callImages() {

_root.myMCL = new MovieClipLoader();
_root.myPreloader = new Object();
_root.myMCL.addListener(_root.myPreloader);

_root.myClips_array = [];

_root.myPreloader.onLoadComplete = function(target) {

_root.myClips_array.push(target);
target._alpha=0;

if (_root.myClips_array.length == _root.myImagesNo) {

moveSlide();
myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
}

}

for (i=0; i<_root.myImagesNo; i++) {

temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i,    myContainer_mc.getNextHighestDepth());

_root.myMCL.loadClip(temp_url,temp_mc);
}

};

function moveSlide (){

current_mc = _root.myClips_array[_root.target_mc];
new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);

_root.target_mc++;

if (_root.target_mc >= _root.myImagesNo){
_root.target_mc = 0;
}

next_mc = _root.myClips_array[_root.target_mc];
new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);

};

Id like to put a flash image gallery that reads an XML and displays the relevant images on my website, however id like to be able to programatically get at a certain slideshow in my XML using its id. for example, my XML has x number of slideshows(i've just copied and pasted the slideshows and changed the id). As an example id like to get at slideshow elements with the id 2.
If i was using XPath in XSLT i would do something like "location/image_gallery/slideshow[@id = 2]".

<location>
<image_gallary>
    <slideshow id="1" width="230" height="145" speed="2">
       <image url="graphics/chesterfield.jpg" title="Market Walk" href="htle.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" /> 
    </slideshow>

    <slideshow id="3" width="230" height="145" speed="4">
       <image url="graphics/chesterfield.jpg" title="rket Walk" href="http://www.google.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" />
    </slideshow>

    <slideshow id="2" width="230" height="145" speed="3">
       <image url="graphics/chesterfield.jpg" title="rket Walk" href="http://www.google.co.uk/" />
       <image url="graphics/cranley.jpg" title="History" href="http://www.google.co.uk/" />
    </slideshow>
</image_gallery>
</location>

*note that the id's can be in any order, i can hard code the actionscript to get to a particular slideshow, however id like to be able to programatically use the id and then call it in my xslt. Any help would be appreciated.

Im using actionscript 2.0. Here is what i have

import mx.transitions.Tween;
import mx.transitions.easing.*;

var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("xml/london_gb.xml");

myShowXML.onLoad = function() {

_root.myWidth = myShowXML.firstChild.childNodes[0].firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.childNodes[0].firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.childNodes[0].firstChild.attributes.speed;

_root.myImages = myShowXML.firstChild.firstChild.firstChild.childNodes;
_root.myImagesNo = myImages.length;

trace(myImages.length);

createContainer();
callImages();

};

function createContainer() {

_root.createEmptyMovieClip("myContainer_mc",_root.getNextHighestDepth());

myContainer_mc.lineTo(_root.myWidth,0);
myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
myContainer_mc.lineTo(0,_root.myHeight);
myContainer_mc.lineTo(0,0);

myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;

};

function callImages() {

_root.myMCL = new MovieClipLoader();
_root.myPreloader = new Object();
_root.myMCL.addListener(_root.myPreloader);

_root.myClips_array = [];

_root.myPreloader.onLoadComplete = function(target) {

_root.myClips_array.push(target);
target._alpha=0;

if (_root.myClips_array.length == _root.myImagesNo) {

moveSlide();
myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
}

}

for (i=0; i<_root.myImagesNo; i++) {

temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i,    myContainer_mc.getNextHighestDepth());

_root.myMCL.loadClip(temp_url,temp_mc);
}

};

function moveSlide (){

current_mc = _root.myClips_array[_root.target_mc];
new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);

_root.target_mc++;

if (_root.target_mc >= _root.myImagesNo){
_root.target_mc = 0;
}

next_mc = _root.myClips_array[_root.target_mc];
new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);

};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遗弃M 2024-11-26 14:03:34

_xmlContainer.imageGallary.slideshow.@id[0];

试试这个。

_xmlContainer.imageGallary.slideshow.@id[0];

try this one.

掩耳倾听 2024-11-26 14:03:34

添加这一行

next_mc.onRelease = function() {
    getURL(_root.myImages[target_mc].attributes.href,"_blank");
}; 

在该行下面

next_mc = _root.myClips_array[_root.target_mc];

add this line

next_mc.onRelease = function() {
    getURL(_root.myImages[target_mc].attributes.href,"_blank");
}; 

below this line

next_mc = _root.myClips_array[_root.target_mc];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文