单击时,adobe flex无法加载图像 [英] adobe flex cant load image when click

查看:116
本文介绍了单击时,adobe flex无法加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的朋友在工作,他不在附近,所以我想尝试一点Adobe Flex4.

代码如下:

I have my friends work and he''s not around so I want to try a little bit of Adobe Flex 4.

Here''s the code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application creationComplete="application1_creationCompleteHandler(event)" xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" preloaderChromeColor="#FFFFFF" backgroundColor="#FFFFFF" width="1165">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.DragEvent;
            import mx.events.FlexEvent;
            import mx.graphics.ImageSnapshot;
            import mx.graphics.codec.JPEGEncoder;
            import mx.graphics.codec.PNGEncoder;
            import org.osmf.layout.AbsoluteLayoutFacet;

            var currimg:Image;
            var db:Array = new Array();
            var first:String;
            private function configureListeners(dispatcher:IEventDispatcher):void {
                dispatcher.addEventListener(Event.COMPLETE, completeHandler);
                dispatcher.addEventListener(Event.OPEN, openHandler);
                dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
                dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            }

            private function completeHandler(event:Event):void {
                var loader:URLLoader = URLLoader(event.target);

                var i : Number = 0;
                //
                var px:int = 90;
                var py:int = 50;
                var larr:Array = loader.data.toString().split(",");
                mx.controls.Alert.show(loader.data.toString());
                for each( var str:String in larr )
                {
                    if(str.indexOf(".db")<=0 && str!="")
                    {
                        var img1:Image = new Image();
                        img1.source = first+"/"+str;
                        img1.width = 50;
                        img1.height = 50;

                        img1.addEventListener(MouseEvent.CLICK,dothis);
                        logobar.addChild(img1);
                        db.push(img1);
                        img1.move(px,py);
                        px += img1.width+20;
                    }
                    i++;
                }

            }
            private function openHandler(event:Event):void {
                trace("openHandler: " + event);
            }
            private function progressHandler(event:ProgressEvent):void {
                trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
            }
            private function securityErrorHandler(event:SecurityErrorEvent):void {
                trace("securityErrorHandler: " + event);
            }
            private function httpStatusHandler(event:HTTPStatusEvent):void {
                trace("httpStatusHandler: " + event);
            }
            private function ioErrorHandler(event:IOErrorEvent):void {
                trace("ioErrorHandler: " + event);
            }

            private var bi:Array = new Array();

            private function saveImageToFileSystem():void
            {
                var jPEGEncoder:PNGEncoder = new PNGEncoder();
                var imageSnapshot:ImageSnapshot = ImageSnapshot.captureImage(imgCanvas, 0, jPEGEncoder);
                var fileReference:FileReference = new FileReference();
                fileReference.save(imageSnapshot.data, "img123.jpg");
            }

            protected function button1_clickHandler(event:MouseEvent):void
            {
                saveImageToFileSystem();
            }

            protected function button2_clickHandler(event:MouseEvent):void
            {
            imgCanvas.removeChild(currimg);
            }

            private function loadurl(url:String):void
            {
                var loader:URLLoader = new URLLoader();
                configureListeners(loader);
                var request:URLRequest = new URLRequest(url);
                try {
                    loader.load(request);
                }
                catch (error:Error) {
                    trace("Unable to load requested document.");
                }

            }
            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                bi.push("blue.jpg,tshirt_blue.png");
                bi.push("black.jpg,tshirt_black.png");
                bi.push("green.jpg,tshirt_green.png");
                bi.push("yellow.jpg,tshirt_yellow.png");
                bi.push("orange.jpg,tshirt_orange.png");
                bi.push("violet.jpg,tshirt_violet.png");
                var py:int = 50;


                for(var i:int=0; i<bi.length; i++)
                {
                    var arr:Array = (bi[i] as String).split(",");
                    var image:customimg = new customimg(arr[0],arr[1]);
                    image.addEventListener(MouseEvent.CLICK,changets);
                    logobar.addChild(image);
                    image.move(0,py);
                    py += image.height+20;
                }
                imgCanvas.addEventListener(MouseEvent.MOUSE_UP,stopdrag);
            }

            private function dothis(event:MouseEvent):void
            {
                var img:Image = new Image();
                img.width = 50;
                img.height = 50;
                img.source = (event.currentTarget as Image).source;
                img.addEventListener(MouseEvent.MOUSE_DOWN,dragme);
                img.addEventListener(MouseEvent.MOUSE_UP,stopdrag);
                imgCanvas.addChild(img);
            }

            private function dragme(event:MouseEvent):void
            {
                currimg = event.currentTarget as Image;
                (event.currentTarget as Image).startDrag(true);
            }

            private function stopdrag(event:MouseEvent):void
            {
                currimg.stopDrag();
            }

            private function changets(event:MouseEvent):void
            {
                theshirt.source = (event.currentTarget as customimg).tsimg;
            }

            protected function button3_clickHandler(event:MouseEvent):void
            {
                for(var i=0; i<db.length; i++)
                {
                    logobar.removeChild(db[i] as Image);
                }
                db =  new Array();
                first="image/logo";
                loadurl("index.php?m=logo");
            }

            protected function button4_clickHandler(event:MouseEvent):void
            {
                for(var i=0; i<db.length; i++)
                {
                    logobar.removeChild(db[i] as Image);
                }
                db =  new Array();
                first="image/text";
                loadurl("index.php?m=text");
            }
        ]]>
    </fx:Script>
    <mx:Canvas id="imgCanvas" width="527" height="407" x="23" y="30">
        <mx:Image id="theshirt" source="image/tshirt/tshirt_white.png" x="61" y="27"/>
    </mx:Canvas>
    <s:Button x="775" y="180" label="Save" click="button1_clickHandler(event)"/>
    <s:Button x="689" y="181" label="Delete" click="button2_clickHandler(event)"/>
    <mx:Canvas id="logobar" x="558" y="30" width="551" height="135" backgroundColor="#FFFFFF">
        <s:Label x="10" y="10" text="T Shirt Color"/>
        <s:Button x="155" y="10" label="Logo" click="button3_clickHandler(event)"/>
        <s:Button x="240" y="10" label="Text" click="button4_clickHandler(event)"/>
    </mx:Canvas>

    <fx:Declarations>

    </fx:Declarations>
</s:Application>






问题是我将所有文件都上传到了我的域(公共html).

它肯定会加载页面,但子图像(徽标)无法加载.

我在代码中看到有一个loadurl(index.php?=text)

我需要创建页面index.php吗?

我不知道该怎么办.

有人可以帮我吗?

这是我的临时域的链接
http://75.126.247.111/~phildogb/ [






The problem is I uploaded all the files to my domain (public html).

It''s certainly load the page but the child images (the logo) can''t load.

I saw in the code that there is a loadurl(index.php?=text)

Am I need to create a page index.php?

I don''t know how to do that.

Can someone help me?

Here''s the link of my temporary domain
http://75.126.247.111/~phildogb/[^]

推荐答案

最多还是没人回答TT我希望有人能帮助我
up still no one answer T T i hope someone who could help me


这篇关于单击时,adobe flex无法加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆