Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AdobeFlex到纯动作脚本。怎么用?_Actionscript 3_Apache Flex_Flex4_Flex3_Flex4.5 - Fatal编程技术网

Actionscript 3 AdobeFlex到纯动作脚本。怎么用?

Actionscript 3 AdobeFlex到纯动作脚本。怎么用?,actionscript-3,apache-flex,flex4,flex3,flex4.5,Actionscript 3,Apache Flex,Flex4,Flex3,Flex4.5,我有下面的脚本,它允许通过PHP脚本将文件上传到我的web服务器,但我希望将伪代码变成纯动作脚本。此外,由于某些原因,我的进度栏不会显示文件上载的实际进度 以下是PHP代码: <?php $tempFile = $_FILES['Filedata']['tmp_name']; $fileName = $_FILES['Filedata']['name']; $fileSize = $_FILES['Filedata']['size']; move_uploaded_file($temp

我有下面的脚本,它允许通过PHP脚本将文件上传到我的web服务器,但我希望将伪代码变成纯动作脚本。此外,由于某些原因,我的进度栏不会显示文件上载的实际进度

以下是PHP代码:

<?php

$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];

move_uploaded_file($tempFile, "./" . $fileName);

?>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               width="225" height="178" minWidth="955" minHeight="600">
    <fx:Declarations>

    </fx:Declarations>

<fx:Script>
    <![CDATA[

        import flash.net.FileReference;
        public var fileRef:FileReference = new FileReference();
        public function uploadDialog(e:MouseEvent):void{
            errLabel.text="";
            var imgType:FileFilter = new FileFilter("Images (*.GIF,*.JPG,*.PNG)","*.gif;*.jpg;*.png");
            var filterArray:Array=new Array(imgType);
            fileRef.browse(filterArray);
            fileRef.addEventListener(Event.SELECT,fileSelect);
            fileRef.addEventListener(ProgressEvent.PROGRESS,fileProgress);
            fileRef.addEventListener(Event.COMPLETE,fileComplete);
        }

        public function fileSelect(e:Event):void{
            var fileURL:URLRequest = new URLRequest("upload.php");
            try
            {
                //filepath.text=fileRef.name;
                fileRef.upload(fileURL);
            }
            catch (err:Error)
            { 
                errLabel.text="Unable to Upload File.....";
            }
        }

        public function fileProgress(e:ProgressEvent):void
        {
            progBar.visible=true;
        }

        public function fileComplete(e:Event):void{

            errLabel.text="File Uploaded Sucessfully....."
            progBar.visible=false;

        }

    ]]>
</fx:Script>


    <s:Label x="10" y="10" click="uploadDialog(event)" text="Upload ..."/>
    <mx:ProgressBar id="progBar" x="10" y="26"/>
    <s:Label id="errLabel" x="10" y="108" width="200" text="..."/>

</s:Application>

以下是Adobe Flex代码:

<?php

$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];

move_uploaded_file($tempFile, "./" . $fileName);

?>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               width="225" height="178" minWidth="955" minHeight="600">
    <fx:Declarations>

    </fx:Declarations>

<fx:Script>
    <![CDATA[

        import flash.net.FileReference;
        public var fileRef:FileReference = new FileReference();
        public function uploadDialog(e:MouseEvent):void{
            errLabel.text="";
            var imgType:FileFilter = new FileFilter("Images (*.GIF,*.JPG,*.PNG)","*.gif;*.jpg;*.png");
            var filterArray:Array=new Array(imgType);
            fileRef.browse(filterArray);
            fileRef.addEventListener(Event.SELECT,fileSelect);
            fileRef.addEventListener(ProgressEvent.PROGRESS,fileProgress);
            fileRef.addEventListener(Event.COMPLETE,fileComplete);
        }

        public function fileSelect(e:Event):void{
            var fileURL:URLRequest = new URLRequest("upload.php");
            try
            {
                //filepath.text=fileRef.name;
                fileRef.upload(fileURL);
            }
            catch (err:Error)
            { 
                errLabel.text="Unable to Upload File.....";
            }
        }

        public function fileProgress(e:ProgressEvent):void
        {
            progBar.visible=true;
        }

        public function fileComplete(e:Event):void{

            errLabel.text="File Uploaded Sucessfully....."
            progBar.visible=false;

        }

    ]]>
</fx:Script>


    <s:Label x="10" y="10" click="uploadDialog(event)" text="Upload ..."/>
    <mx:ProgressBar id="progBar" x="10" y="26"/>
    <s:Label id="errLabel" x="10" y="108" width="200" text="..."/>

</s:Application>

检查此项:您必须设置和属性,并调用您的
fileProgress
函数

有两种方法可以将flex代码转换为纯as3:
*在flex config.xml中设置
true


*在不使用mxml作为纯as3项目的情况下重写代码

这就是我所寻找的关于进度条更新的内容

private function progressHandler(event:ProgressEvent):void 
{ 
    pb.setProgress(event.bytesLoaded, event.bytesTotal); 
}
解决方案的链接


既然你什么也不做,为什么你希望进度条会改变?代码是有效的,似乎ProgressEvent有一个事件监听器,但我猜PHP不会报告文件上载进度,因此操作脚本只看到开始和结束。我想我会扔一个旋转器来代替。在上传过程中,似乎没有任何东西在向进度条输入。