Flash CS4 加载器类:最初加载图像,但加载新图像时返回错误

发布于 2024-10-25 00:26:15 字数 2979 浏览 8 评论 0原文

这在标题中很难解释...首先,这是我在 Actionscript 中的代码:

var digitalGallery:Loader = new Loader();
digitalGallery.x = 730
digitalGallery.y = 210
digitalGallery.load(new URLRequest("images/nair_evanescentautumn.png"));
addChild(digitalGallery);

function dgtlLatest(event:MouseEvent):void {
 if(event.target == new_thumb1) {
    digitalGallery.load(new URLRequest("images/iilu_evanescantautumn.png"));
 }
 else if(event.target == new_thumb2) {
    digitalGallery.load(new URLRequest("images/daem_evanescantautumn.png"));
 }
 else if(event.target == new_thumb3) {
    digitalGallery.load(new URLRequest("images/moon_evanescantautumn.png"));
 }
 else if(event.target == new_thumb4) {
    digitalGallery.load(new URLRequest("images/dael_evanescantautumn.png"));
 }
}

function dgtlGalery(event:MouseEvent):void {
 if(event.target == gal_thumb1) {
    digitalGallery.load(new URLRequest("images/kryo_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb2) {
    digitalGallery.load(new URLRequest("images/nair_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb3) {
    digitalGallery.load(new URLRequest("images/lite_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb4) {
    digitalGallery.load(new URLRequest("images/oasi_evanescantautumn.png"));
 }
}

new_thumb1.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb2.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb3.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb4.addEventListener(MouseEvent.CLICK,dgtlLatest);

gal_thumb1.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb2.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb3.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb4.addEventListener(MouseEvent.CLICK,dgtlGalery);

该脚本用于 Flash 中的加载程序图像库,作为课堂作业的一部分。发生的情况是,在 Flash 中,当我打开 swf 文件时,初始图像 (images/nair_evanescentautumn.png) 将正常加载。但是,单击任何缩略图(包括完全相同的 images/nair_evanescentautumn.png),都会导致错误提示找不到该文件。

我不明白它为什么这样做......我已经测试过了。单击每个缩略图确实会转到两个单独功能中的正确位置。所有所述全尺寸图像链接都位于文件夹 images/ 中,替换初始加载器图像将加载其他图像来代替默认图像。但是,即使一切正常,单击任何缩略图仍然会导致找不到 URL。

这简直让我发疯……创建一个简单的画廊不可能这么困难。

不过,作业要在周三截止……我确信我可以在课堂上问我的老师,但我更愿意在那之前完成它,除了发布这个之外,我想不出还有什么可做的。

非常感谢所有帮助...

编辑:

抱歉没有发布错误...

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

编辑2:

这是整个文件集的链接:

http://www.tsr-online.org/flash/index.swf

我的服务器不允许访问 /flash 文件夹索引,但我可以给目录列表。

/闪存目录: /images(包含所有图像) /cmsn(包含commissions.swf子页面) 索引.swf 主页.swf 博客.swf 传统.swf 数字.swf 摄影.swf Commissions.swf

在有人问我为什么要把这种内容放入 Flash 站点之前,我不是——这只是为了课堂作业。我只是想弄清楚为什么当我只在函数中执行与其他页面上完全相同的操作时,我的图像无法正确加载。

值得注意的是,commissions.swf 具有完全相同的功能,只是加载了 swf 文件,并且它工作得很好。家庭、传统、数字和摄影都有图片库,并且都有相同的问题(我只引用了一页,因为如果我可以修复一页,我应该能够修复所有页面)。

至于艺术品,都是我未婚夫的。网站设计是为她构建的,我在这个项目中使用了网站设计,因为我不想构建一个全新的界面设计。由于该项目还需要一个画廊,所以我觉得这个界面可以很好地工作。

This is extremely difficult to explain in the title... First, here is my code in Actionscript:

var digitalGallery:Loader = new Loader();
digitalGallery.x = 730
digitalGallery.y = 210
digitalGallery.load(new URLRequest("images/nair_evanescentautumn.png"));
addChild(digitalGallery);

function dgtlLatest(event:MouseEvent):void {
 if(event.target == new_thumb1) {
    digitalGallery.load(new URLRequest("images/iilu_evanescantautumn.png"));
 }
 else if(event.target == new_thumb2) {
    digitalGallery.load(new URLRequest("images/daem_evanescantautumn.png"));
 }
 else if(event.target == new_thumb3) {
    digitalGallery.load(new URLRequest("images/moon_evanescantautumn.png"));
 }
 else if(event.target == new_thumb4) {
    digitalGallery.load(new URLRequest("images/dael_evanescantautumn.png"));
 }
}

function dgtlGalery(event:MouseEvent):void {
 if(event.target == gal_thumb1) {
    digitalGallery.load(new URLRequest("images/kryo_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb2) {
    digitalGallery.load(new URLRequest("images/nair_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb3) {
    digitalGallery.load(new URLRequest("images/lite_evanescantautumn.png"));
 }
 else if(event.target == gal_thumb4) {
    digitalGallery.load(new URLRequest("images/oasi_evanescantautumn.png"));
 }
}

new_thumb1.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb2.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb3.addEventListener(MouseEvent.CLICK,dgtlLatest);
new_thumb4.addEventListener(MouseEvent.CLICK,dgtlLatest);

gal_thumb1.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb2.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb3.addEventListener(MouseEvent.CLICK,dgtlGalery);
gal_thumb4.addEventListener(MouseEvent.CLICK,dgtlGalery);

This script is for a loader image gallery in flash, as part of a class assignment. What happens is that in flash, when I open the swf file, the initial image (images/nair_evanescentautumn.png) will load fine. However, clicking on any thumbnail image (including the exact same images/nair_evanescentautumn.png), will result in an error saying the file cannot be found.

I cannot figure out why it is doing this... I've tested it over. Clicking each thumbnail does go to the correct position in the two separate functions. All said full-size image links are in the folder images/, and replacing the initial loader image will load the other images in place of the default one. However, clicking on any thumbnail still results in URL not found, even though everything works correctly.

This is just driving me crazy... it can't be this difficult to create a simple gallery.

The assignment is due Wednesday, though... I'm sure I can ask my instructor in-class, but I'd prefer to have it done before then, and I can't think of anything else to do except post this.

All help is greatly appreciated...

EDIT:

Sorry about not posting the error...

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

EDIT 2:

Here's a link to the entire set of files:

http://www.tsr-online.org/flash/index.swf

My server won't allow access to the /flash folder index, but I can give the directory listing.

/flash directory:
/images (contains all images)
/cmsn (contains commissions.swf subpages)
index.swf
home.swf
blog.swf
traditional.swf
digital.swf
photography.swf
commissions.swf

Before anyone asks why I'm putting this kind of content into a flash site, I'm not--this is only for a class assignment. I'm just trying to figure out why my images aren't loading right when I'm only doing the exact same thing in the functions as I am on the other pages.

Of note, commissions.swf has the exact same feature, just with swf files loaded instead, and it works perfectly fine. home, traditional, digital, and photography all have the image gallery, and all have the same issue (I only referenced one page because if I can fix one page I should be able to fix all of them).

As for the artworks, they are all my fiance's. The website design was built for her, and I used the website design for this project because I didn't want to have to build an entirely new interface design. Since the project also required a gallery, I felt that this interface would work just fine.

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

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

发布评论

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

评论(3

洛阳烟雨空心柳 2024-11-01 00:26:15

您的代码中有拼写错误。这就是问题所在。您自己的代码示例:

 else if(event.target == new_thumb2) {
    digitalGallery.load(new URLRequest("images/daem_evanescantautumn.png"));
 }

实际上拼写为:

http://www. tsr-online.org/flash/images/daem_evanescentautumn.png

请注意,确切的问题是“vanesc a ntautumn.png”,而它应该为“vanesc e ntautumn.png”。

修正上面代码中的拼写,一切都会好起来的。

You have spelling mistakes in your code. That's all the issue is. Example from your own code:

 else if(event.target == new_thumb2) {
    digitalGallery.load(new URLRequest("images/daem_evanescantautumn.png"));
 }

When in fact the spelling is:

http://www.tsr-online.org/flash/images/daem_evanescentautumn.png

Note the exact issue is "vanesc a ntautumn.png" when it should be "vanesc e ntautumn.png."

Fix the spelling in your code above and all should be well.

羞稚 2024-11-01 00:26:15

由于奇怪的限制,我无法对您的帖子发表评论,因此我必须写一个答案(这对您来说是一个问题):为什么您尝试加载同一张图像两次?

Since I cannot make a comment on your post because of the strange restrictions I have to write an answer (which is a question to you): Why do you try to load the same image twice?

柒七 2024-11-01 00:26:15

无论如何,你有点以一种非常迂回的方式来解决它 - 试试这个:

var digitalGallery:Loader;

var thumbs:Array = ['new_thumb1',
                'new_thumb2',
                'new_thumb3',
                'new_thumb4',
                'gal_thumb1',
                'gal_thumb2',
                'gal_thumb3',
                'gal_thumb4']

var images:Array = ['iilu_evanescantautumn',
                'daem_evanescantautumn',
                'moon_evanescantautumn',
                'dael_evanescantautumn',
                'kryo_evanescantautumn',
                'nair_evanescantautumn',
                'lite_evanescantautumn',
                'oasi_evanescantautumn']

setupThumbs()

function setupThumbs(){
    for (var i=0; i<thumbs.length; i++){
        var thumb = this.getChildByName(thumbs[i])
        thumb.id = i
        thumb.addEventListener(MouseEvent.CLICK, loadImage);
    }
}

function loadImage(event:MouseEvent){
    var id = event.currentTarget.id
    digitalGallery = new Loader();
    digitalGallery.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    digitalGallery.load(new URLRequest("images/"+images[id]+".png"));
}

function loadComplete(event:Event):void {
    trace("Complete");
    addChild(digitalGallery)
    digitalGallery.x = 730;
    digitalGallery.y = 210;
}

You're kinda going about it in a really roundabout sort of way anyway - try this out:

var digitalGallery:Loader;

var thumbs:Array = ['new_thumb1',
                'new_thumb2',
                'new_thumb3',
                'new_thumb4',
                'gal_thumb1',
                'gal_thumb2',
                'gal_thumb3',
                'gal_thumb4']

var images:Array = ['iilu_evanescantautumn',
                'daem_evanescantautumn',
                'moon_evanescantautumn',
                'dael_evanescantautumn',
                'kryo_evanescantautumn',
                'nair_evanescantautumn',
                'lite_evanescantautumn',
                'oasi_evanescantautumn']

setupThumbs()

function setupThumbs(){
    for (var i=0; i<thumbs.length; i++){
        var thumb = this.getChildByName(thumbs[i])
        thumb.id = i
        thumb.addEventListener(MouseEvent.CLICK, loadImage);
    }
}

function loadImage(event:MouseEvent){
    var id = event.currentTarget.id
    digitalGallery = new Loader();
    digitalGallery.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    digitalGallery.load(new URLRequest("images/"+images[id]+".png"));
}

function loadComplete(event:Event):void {
    trace("Complete");
    addChild(digitalGallery)
    digitalGallery.x = 730;
    digitalGallery.y = 210;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文