关于网站问题的 AS3 幻灯片

发布于 2024-11-27 05:04:40 字数 2639 浏览 0 评论 0原文

我正在使用 as3 在 flash 中构建一个网站。我在主页上实现了一个 xml 幻灯片,但在更改页面时它不会消失。谁能告诉我如何删除其他页面上的它?

幻灯片代码:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var my_speed:Number;
var my_total:Number;
var my_images:XMLList;

var my_loaders_array:Array = [];
var my_success_counter:Number = 0;
var my_playback_counter:Number = 0;

var my_slideshow:Sprite = new Sprite();
var my_image_slides:Sprite = new Sprite();
var my_timer:Timer;
var my_prev_tween:Tween;
var my_tweens_array:Array = [];

var my_xml_loader:URLLoader = new URLLoader();
my_xml_loader.load(new URLRequest("slideshow_home.xml"));
my_xml_loader.addEventListener(Event.COMPLETE, processXML);


function processXML(e:Event):void
{

var my_xml:XML = new XML(e.target.data);
my_speed = my_xml. @ SPEED;
my_images = my_xml.IMAGE;
my_total = my_images.length();

loadImages();

my_xml_loader.removeEventListener(Event.COMPLETE, processXML);
my_xml_loader = null;

}

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

    var my_url:String = my_images[i]. @ URL;
    var my_loader:Loader = new Loader();
    my_loader.load(new URLRequest(my_url));
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    my_loaders_array.push(my_loader);

}
}

function onComplete(e:Event):void
{

my_success_counter++;
if (my_success_counter == my_total)
{

    startShow();

}

var my_loaderInfo:LoaderInfo = LoaderInfo(e.target); 
my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

}

function startShow():void
{

addChild(my_slideshow);
my_slideshow.addChild(my_image_slides);

nextImage();
my_timer = new Timer(my_speed*5000);
my_timer.addEventListener(TimerEvent.TIMER, timerListener);
my_timer.start();

}

function nextImage():void
{

var my_image:Loader = Loader(my_loaders_array[my_playback_counter]);
my_image_slides.addChild(my_image);
my_image.x = (stage.stageWidth - my_image.width)-160;
my_image.y = (stage.stageHeight - my_image.height)-100;
new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);
my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true); 

}

function timerListener(e:TimerEvent):void
{
hidePrev();


my_playback_counter++;
if (my_playback_counter == my_total)
{
    my_playback_counter = 0;
}
nextImage();

}

function hidePrev():void
{

var my_image:Loader = Loader(my_image_slides.getChildAt(0));
my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut);
}

function onFadeOut(e:TweenEvent):void
{
my_image_slides.removeChildAt(0);

} 

I'm building a site in flash using as3. I implemented an xml slideshow on the home page but it wont disappear when changing pages. Anyone could tell me how to remove it on other pages?

slideshow code:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var my_speed:Number;
var my_total:Number;
var my_images:XMLList;

var my_loaders_array:Array = [];
var my_success_counter:Number = 0;
var my_playback_counter:Number = 0;

var my_slideshow:Sprite = new Sprite();
var my_image_slides:Sprite = new Sprite();
var my_timer:Timer;
var my_prev_tween:Tween;
var my_tweens_array:Array = [];

var my_xml_loader:URLLoader = new URLLoader();
my_xml_loader.load(new URLRequest("slideshow_home.xml"));
my_xml_loader.addEventListener(Event.COMPLETE, processXML);


function processXML(e:Event):void
{

var my_xml:XML = new XML(e.target.data);
my_speed = my_xml. @ SPEED;
my_images = my_xml.IMAGE;
my_total = my_images.length();

loadImages();

my_xml_loader.removeEventListener(Event.COMPLETE, processXML);
my_xml_loader = null;

}

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

    var my_url:String = my_images[i]. @ URL;
    var my_loader:Loader = new Loader();
    my_loader.load(new URLRequest(my_url));
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    my_loaders_array.push(my_loader);

}
}

function onComplete(e:Event):void
{

my_success_counter++;
if (my_success_counter == my_total)
{

    startShow();

}

var my_loaderInfo:LoaderInfo = LoaderInfo(e.target); 
my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

}

function startShow():void
{

addChild(my_slideshow);
my_slideshow.addChild(my_image_slides);

nextImage();
my_timer = new Timer(my_speed*5000);
my_timer.addEventListener(TimerEvent.TIMER, timerListener);
my_timer.start();

}

function nextImage():void
{

var my_image:Loader = Loader(my_loaders_array[my_playback_counter]);
my_image_slides.addChild(my_image);
my_image.x = (stage.stageWidth - my_image.width)-160;
my_image.y = (stage.stageHeight - my_image.height)-100;
new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);
my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true); 

}

function timerListener(e:TimerEvent):void
{
hidePrev();


my_playback_counter++;
if (my_playback_counter == my_total)
{
    my_playback_counter = 0;
}
nextImage();

}

function hidePrev():void
{

var my_image:Loader = Loader(my_image_slides.getChildAt(0));
my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut);
}

function onFadeOut(e:TweenEvent):void
{
my_image_slides.removeChildAt(0);

} 

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

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

发布评论

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

评论(2

镜花水月 2024-12-04 05:04:40
my_slideshow.visible = false;

使用这个你可以隐藏你的幻灯片。

但这是愚蠢的方式,因为幻灯片仍在后台运行。

如果您使用类级别程序,您可以使用removechild方法非常轻松地从舞台上删除幻灯片。这种方式很棒。

my_slideshow.visible = false;

using this u can invisible your slideshow.

but this is stupid way because the slideshow still running in the background.

If you use class level program, u can remove the slideshow from your stage very easily using removechild method. this way is great.

蒲公英的约定 2024-12-04 05:04:40

将其作为一个单独的类,然后在主时间轴中实例化。这样就可以轻松删除。

Make this as a separate class and then instantiate in your main timeline. This way you can easily remove.

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