Hi Yishay, Could you please update version number to 0.9 in the comments. @productversion FlexJS 0.9
Thanks, Piotr 2017-07-03 13:28 GMT+02:00 <yish...@apache.org>: > Repository: flex-asjs > Updated Branches: > refs/heads/tlf fad521450 -> ff4dd1e8a > > > First implementation of FileProxy which takes on some of the functions > of FileReference in Flash. More beads coming soon. > > > Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo > Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ff4dd1e8 > Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ff4dd1e8 > Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ff4dd1e8 > > Branch: refs/heads/tlf > Commit: ff4dd1e8aa2a1f55ab31df2d3b48db73fc02e097 > Parents: fad5214 > Author: DESKTOP-RH4S838\Yishay <yishayj...@hotmail.com> > Authored: Mon Jul 3 14:27:18 2017 +0300 > Committer: DESKTOP-RH4S838\Yishay <yishayj...@hotmail.com> > Committed: Mon Jul 3 14:27:18 2017 +0300 > > ---------------------------------------------------------------------- > .../Network/src/main/flex/NetworkClasses.as | 3 +- > .../main/flex/org/apache/flex/file/FileProxy.as | 57 +++++++ > .../org/apache/flex/file/beads/FileBrowser.as | 159 +++++++++++++++++++ > .../org/apache/flex/file/beads/FileModel.as | 156 ++++++++++++++++++ > .../src/main/resources/basic-manifest.xml | 4 +- > 5 files changed, 376 insertions(+), 3 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > ff4dd1e8/frameworks/projects/Network/src/main/flex/NetworkClasses.as > ---------------------------------------------------------------------- > diff --git a/frameworks/projects/Network/src/main/flex/NetworkClasses.as > b/frameworks/projects/Network/src/main/flex/NetworkClasses.as > index ed88471..51482f3 100644 > --- a/frameworks/projects/Network/src/main/flex/NetworkClasses.as > +++ b/frameworks/projects/Network/src/main/flex/NetworkClasses.as > @@ -18,6 +18,7 @@ > //////////////////////////////////////////////////////////// > //////////////////// > package > { > + > > /** > * @private > @@ -27,7 +28,7 @@ package > */ > internal class NetworkClasses > { > - import org.apache.flex.net.URLBinaryLoader; URLBinaryLoader; > + import org.apache.flex.net.URLBinaryLoader; URLBinaryLoader; > import org.apache.flex.net.HTTPConstants; HTTPConstants; > } > > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > ff4dd1e8/frameworks/projects/Network/src/main/flex/org/ > apache/flex/file/FileProxy.as > ---------------------------------------------------------------------- > diff --git > a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/FileProxy.as > b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/FileProxy.as > new file mode 100644 > index 0000000..7055f1b > --- /dev/null > +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/FileProxy.as > @@ -0,0 +1,57 @@ > +// > +// Licensed to the Apache Software Foundation (ASF) under one or more > +// contributor license agreements. See the NOTICE file distributed with > +// this work for additional information regarding copyright ownership. > +// The ASF licenses this file to You under the Apache License, Version > 2.0 > +// (the "License"); you may not use this file except in compliance with > +// the License. You may obtain a copy of the License at > +// > +// http://www.apache.org/licenses/LICENSE-2.0 > +// > +// Unless required by applicable law or agreed to in writing, software > +// distributed under the License is distributed on an "AS IS" BASIS, > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > +// See the License for the specific language governing permissions and > +// limitations under the License. > +// > +/////////////////////////////////////////////////////////// > ///////////////////// > +package org.apache.flex.file > +{ > + import org.apache.flex.core.IBead; > + import org.apache.flex.core.IDocument; > + import org.apache.flex.core.Strand; > + > + /** > + * The FileProxy class is where beads regarding file operations > are added. > + * Information about operations can be queried in the file model, > or by > + * listenening to events dispatched by beads. > + * > + * @toplevel > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public class FileProxy extends Strand implements IDocument > + { > + private var _document:Object; > + public function FileProxy() > + { > + super(); > + } > + > + > + /** > + * @private > + */ > + public function setDocument(document:Object, id:String = > null):void > + { > + _document = document; > + for each (var bead:IBead in beads) > + { > + addBead(bead); > + } > + } > + > + } > +} > \ No newline at end of file > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > ff4dd1e8/frameworks/projects/Network/src/main/flex/org/ > apache/flex/file/beads/FileBrowser.as > ---------------------------------------------------------------------- > diff --git > a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileBrowser.as > b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/beads/FileBrowser.as > new file mode 100644 > index 0000000..fa24548 > --- /dev/null > +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/beads/FileBrowser.as > @@ -0,0 +1,159 @@ > +// > +// Licensed to the Apache Software Foundation (ASF) under one or more > +// contributor license agreements. See the NOTICE file distributed with > +// this work for additional information regarding copyright ownership. > +// The ASF licenses this file to You under the Apache License, Version > 2.0 > +// (the "License"); you may not use this file except in compliance with > +// the License. You may obtain a copy of the License at > +// > +// http://www.apache.org/licenses/LICENSE-2.0 > +// > +// Unless required by applicable law or agreed to in writing, software > +// distributed under the License is distributed on an "AS IS" BASIS, > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > +// See the License for the specific language governing permissions and > +// limitations under the License. > +// > +/////////////////////////////////////////////////////////// > ///////////////////// > +package org.apache.flex.file.beads > +{ > + import org.apache.flex.core.IBead; > + import org.apache.flex.core.IStrand; > + import org.apache.flex.file.FileProxy; > + > + COMPILE::SWF > + { > + import flash.net.FileReference; > + import flash.events.Event; > + } > + > + COMPILE::JS > + { > + import org.apache.flex.events.Event; > + import org.apache.flex.core.WrappedHTMLElement; > + import goog.events; > + > + } > + > + /** > + * The FileBrowser class is a bead which adds to UploadImageProxy > + * the ability to browse the file system and select a file. > + * > + * > + * @toplevel > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public class FileBrowser implements IBead > + { > + private var _strand:IStrand; > + COMPILE::SWF > + { > + private var _delegate:flash.net.FileReference; > + } > + COMPILE::JS > + { > + private var _delegate:WrappedHTMLElement; > + } > + > + /** > + * Constructor. > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function FileBrowser() > + { > + createDelegate(); > + } > + > + /** > + * @flexjsignorecoercion org.apache.flex.core. > WrappedHTMLElement > + */ > + COMPILE::JS > + public function createDelegate():void > + { > + _delegate = document.createElement('input') as > WrappedHTMLElement; > + _delegate.setAttribute('type', 'file'); > + goog.events.listen(_delegate, 'change', > fileChangeHandler); > + } > + > + /** > + * @private > + */ > + COMPILE::SWF > + public function createDelegate():void > + { > + _delegate = new flash.net.FileReference(); > + _delegate.addEventListener(flash.events.Event.SELECT, > fileSelectHandler); > + } > + > + /** > + * @private > + */ > + COMPILE::SWF > + protected function fileSelectHandler(event:flash. > events.Event):void > + { > + host.model = new FileModel(_delegate); > + // _delegate reference passed to model, so cleanup > this bead to keep encapsulation > + > _delegate.removeEventListener(flash.events.Event.SELECT, > fileSelectHandler); > + createDelegate(); > + } > + > + /** > + * Open up the system file browser. A user selection will > trigger a 'modelChanged' event on the strand. > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function browse():void > + { > + COMPILE::SWF > + { > + _delegate.browse(); > + } > + COMPILE::JS > + { > + _delegate.click(); > + } > + } > + > + /** > + * @copy org.apache.flex.core.IBead#strand > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function set strand(value:IStrand):void > + { > + _strand = value; > + } > + > + /** > + * @private > + */ > + private function get host():FileProxy > + { > + return _strand as FileProxy; > + } > + > + /** > + * @private > + * @flexjsignorecoercion HTMLInputElement > + */ > + COMPILE::JS > + private function fileChangeHandler(e:org. > apache.flex.events.Event):void > + { > + host.model = new FileModel((_delegate as > HTMLInputElement).files[0]); > + } > + > + } > +} > \ No newline at end of file > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > ff4dd1e8/frameworks/projects/Network/src/main/flex/org/ > apache/flex/file/beads/FileModel.as > ---------------------------------------------------------------------- > diff --git > a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileModel.as > b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/beads/FileModel.as > new file mode 100644 > index 0000000..7692e35 > --- /dev/null > +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/ > file/beads/FileModel.as > @@ -0,0 +1,156 @@ > +// > +// Licensed to the Apache Software Foundation (ASF) under one or more > +// contributor license agreements. See the NOTICE file distributed with > +// this work for additional information regarding copyright ownership. > +// The ASF licenses this file to You under the Apache License, Version > 2.0 > +// (the "License"); you may not use this file except in compliance with > +// the License. You may obtain a copy of the License at > +// > +// http://www.apache.org/licenses/LICENSE-2.0 > +// > +// Unless required by applicable law or agreed to in writing, software > +// distributed under the License is distributed on an "AS IS" BASIS, > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > +// See the License for the specific language governing permissions and > +// limitations under the License. > +// > +/////////////////////////////////////////////////////////// > ///////////////////// > +package org.apache.flex.file.beads > +{ > + import org.apache.flex.core.IBeadModel; > + import org.apache.flex.core.IStrand; > + import org.apache.flex.events.EventDispatcher; > + > + COMPILE::SWF > + { > + import flash.net.FileReference; > + } > + > + /** > + * The FileModel class is a bead that contains basic information > + * on the file referenced by FileProxy > + * > + * > + * @toplevel > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public class FileModel extends EventDispatcher implements > IBeadModel > + { > + private var _strand:IStrand; > + COMPILE::SWF > + { > + private var _data:FileReference; > + } > + COMPILE::JS > + { > + private var _data:File; > + } > + > + /** > + * Constructor. > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function FileModel(data:Object) > + { > + COMPILE::SWF > + { > + _data = data as FileReference; > + } > + COMPILE::JS > + { > + _data = data as File; > + } > + } > + > + > + > + /** > + * The size of the file > + * > + * @copy org.apache.flex.core.IAlertModel#title > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function get size():Number > + { > + return _data.size; > + } > + > + /** > + * The name of the file > + * > + * @copy org.apache.flex.core.IAlertModel#title > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function get name():String > + { > + return _data.name; > + } > + > + // TODO this will give different results in flash and in > JS (extension and MIME respectively). Fix this. > + /** > + * The type > + * > + * @copy org.apache.flex.core.IAlertModel#title > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function get type():String > + { > + return _data.type; > + } > + > + /** > + * The last modified time of the file, in millisecond > since the UNIX epoch (January 1st, 1970 at Midnight). > + * > + * @copy org.apache.flex.core.IAlertModel#title > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function get lastModified():uint > + { > + COMPILE::SWF > + { > + return _data.modificationDate. > milliseconds; > + } > + COMPILE::JS > + { > + return _data.lastModified; > + } > + } > + > + /** > + * @copy org.apache.flex.core.IBead#strand > + * > + * @langversion 3.0 > + * @playerversion Flash 10.2 > + * @playerversion AIR 2.6 > + * @productversion FlexJS 0.0 > + */ > + public function set strand(value:IStrand):void > + { > + _strand = value; > + } > + > + } > +} > \ No newline at end of file > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ > ff4dd1e8/frameworks/projects/Network/src/main/resources/basic-manifest.xml > ---------------------------------------------------------------------- > diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml > b/frameworks/projects/Network/src/main/resources/basic-manifest.xml > index 46f2ad9..b69c4a4 100644 > --- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml > +++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml > @@ -20,9 +20,9 @@ > > > <componentPackage> > - > <component id="HTTPService" class="org.apache.flex.net.HTTPService"/> > <component id="BinaryUploader" class="org.apache.flex.net. > BinaryUploader"/> > <component id="CORSCredentialsBead" class="org.apache.flex.net. > beads.CORSCredentialsBead"/> > - > + <component id="FileProxy" class="org.apache.flex.file.FileProxy"/> > + <component id="FileBrowser" class="org.apache.flex.file. > beads.FileBrowser"/> > </componentPackage> > >