flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Added Image component for ActionScript.
Date Wed, 11 Sep 2013 15:43:45 GMT
Updated Branches:
  refs/heads/develop a39ab2298 -> a1f8929b3


Added Image component for ActionScript.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/a1f8929b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/a1f8929b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/a1f8929b

Branch: refs/heads/develop
Commit: a1f8929b3cdc4296c3a8c396a4f722fe3858279e
Parents: a39ab22
Author: Peter Ent <pent@apache.org>
Authored: Wed Sep 11 11:43:33 2013 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Wed Sep 11 11:43:33 2013 -0400

----------------------------------------------------------------------
 frameworks/as/basic-manifest.xml                |  1 +
 frameworks/as/defaults.css                      |  8 ++
 frameworks/as/src/FlexJSUIClasses.as            |  2 +
 .../as/src/org/apache/flex/core/IImageModel.as  | 28 +++++++
 .../apache/flex/html/staticControls/Image.as    | 41 ++++++++++
 .../flex/html/staticControls/beads/ImageView.as | 86 ++++++++++++++++++++
 .../staticControls/beads/models/ImageModel.as   | 53 ++++++++++++
 7 files changed, 219 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 337ba4f..843c537 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -30,6 +30,7 @@
     <component id="Button" class="org.apache.flex.html.staticControls.Button"/>
     <component id="DropDownList" class="org.apache.flex.html.staticControls.DropDownList"/>
     <component id="DropDownListList" class="org.apache.flex.html.staticControls.supportClasses.DropDownListList"/>
+    <component id="Image" class="org.apache.flex.html.staticControls.Image"/>
     <component id="Label" class="org.apache.flex.html.staticControls.Label"/>
     <component id="TextButton" class="org.apache.flex.html.staticControls.TextButton"/>
     <component id="TextInput" class="org.apache.flex.html.staticControls.TextInput"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index 3458881..7e5e549 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -118,6 +118,14 @@ DropDownListList
     IBeadModel: ClassReference("org.apache.flex.html.staticControls.beads.models.ArraySelectionModel");
 }
 
+Image
+{
+    width: 64;
+    height: 64;
+    IBeadModel: ClassReference("org.apache.flex.html.staticControls.beads.models.ImageModel");
+    IBeadView:  ClassReference("org.apache.flex.html.staticControls.beads.ImageView");
+}
+
 Label
 {
 	width: 95;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as b/frameworks/as/src/FlexJSUIClasses.as
index e32c2ce..76d26c3 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -37,6 +37,7 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.staticControls.beads.ControlBarMeasurementBead; ControlBarMeasurementBead;
 	import org.apache.flex.html.staticControls.beads.CSSTextButtonView; CSSTextButtonView;
     import org.apache.flex.html.staticControls.beads.DropDownListView; DropDownListView;
+	import org.apache.flex.html.staticControls.beads.ImageView; ImageView;
     import org.apache.flex.html.staticControls.beads.ListView; ListView;
     import org.apache.flex.html.staticControls.beads.NumericStepperView; NumericStepperView;
     import org.apache.flex.html.staticControls.beads.PanelView; PanelView;
@@ -58,6 +59,7 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.staticControls.beads.models.AlertModel; AlertModel;
     import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
     import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
+	import org.apache.flex.html.staticControls.beads.models.ImageModel; ImageModel;
 	import org.apache.flex.html.staticControls.beads.models.PanelModel; PanelModel;
 	import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
     import org.apache.flex.html.staticControls.beads.models.TitleBarModel; TitleBarModel;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/src/org/apache/flex/core/IImageModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IImageModel.as b/frameworks/as/src/org/apache/flex/core/IImageModel.as
new file mode 100644
index 0000000..07dfd56
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IImageModel.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core
+{
+	import org.apache.flex.events.IEventDispatcher;
+
+	public interface IImageModel extends IEventDispatcher, IBeadModel
+	{
+		function get url():String;
+		function set url(value:String):void;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/src/org/apache/flex/html/staticControls/Image.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Image.as b/frameworks/as/src/org/apache/flex/html/staticControls/Image.as
new file mode 100644
index 0000000..297e847
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Image.as
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.staticControls
+{
+	import org.apache.flex.core.IImageModel;
+	import org.apache.flex.core.UIBase;
+	
+	public class Image extends UIBase
+	{
+		public function Image()
+		{
+			super();
+		}
+		
+		public function get url():String
+		{
+			return IImageModel(model).url;
+		}
+		
+		public function set url(value:String):void
+		{
+			IImageModel(model).url = value;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ImageView.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ImageView.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ImageView.as
new file mode 100644
index 0000000..2fed3e6
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ImageView.as
@@ -0,0 +1,86 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.staticControls.beads
+{
+	import flash.display.Bitmap;
+	import flash.display.Loader;
+	import flash.display.LoaderInfo;
+	import flash.net.URLRequest;
+	
+	import org.apache.flex.core.IBeadView;
+	import org.apache.flex.core.IImageModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	
+	public class ImageView implements IBeadView
+	{
+		public function ImageView()
+		{
+		}
+		
+		private var bitmap:Bitmap;
+		private var loader:Loader;
+		
+		private var _strand:IStrand;
+		private var _model:IImageModel;
+		
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			
+			IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange);
+			IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange);
+			
+			_model = value.getBeadByType(IImageModel) as IImageModel;
+			_model.addEventListener("urlChanged",handleUrlChange);
+			
+			handleUrlChange(null);
+		}
+		
+		private function handleUrlChange(event:Event):void
+		{
+			loader = new Loader();
+			loader.contentLoaderInfo.addEventListener("complete",onComplete);
+			loader.load(new URLRequest(_model.url));
+		}
+		
+		private function onComplete(event:Object):void
+		{
+			if (bitmap) {
+				UIBase(_strand).removeChild(bitmap);
+			}
+			
+			bitmap = Bitmap(LoaderInfo(event.target).content);
+			
+			UIBase(_strand).addChild(bitmap);
+			
+			handleSizeChange(null);
+		}
+		
+		private function handleSizeChange(event:Object):void
+		{
+			if (bitmap) {
+				bitmap.width = UIBase(_strand).width;
+				bitmap.height = UIBase(_strand).height;
+			}
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a1f8929b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ImageModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ImageModel.as
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ImageModel.as
new file mode 100644
index 0000000..e5821f8
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/ImageModel.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.staticControls.beads.models
+{
+	import org.apache.flex.core.IImageModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+	
+	public class ImageModel extends EventDispatcher implements IImageModel
+	{
+		public function ImageModel()
+		{
+			super();
+		}
+		
+		private var _strand:IStrand;
+		
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+		}
+		
+		private var _url:String;
+		public function get url():String
+		{
+			return _url;
+		}
+		public function set url(value:String):void
+		{
+			if (value != _url) {
+				_url = value;
+				dispatchEvent( new Event("urlChanged") );
+			}
+		}
+	}
+}
\ No newline at end of file


Mime
View raw message