Archives of June 2009

Trick to adjust 100% height of a Repeater container without forcing vertical scroll.

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="onCreationComplete()">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.collections.ListCollectionView;

            [Bindable]
            private var items:ArrayCollection = new ArrayCollection ([
                0,1,2,3,4,5,6,7,8,9
            ]);

            private function onCreationComplete():void {
            }
        ]]>
    </mx:Script>

    <mx:VBox width="100%" height="100%">
        <mx:HBox height="50">
            <mx:Label text="Automatic percent adjust!"/>
        </mx:HBox>
        <mx:VBox height="100%" backgroundColor="red" id="myContainer">
            <mx:VBox height="{myContainer.height}" id="myList" backgroundColor="green"
                includeInLayout="false">
                <mx:Repeater id="rp" dataProvider="{items}">
                    <mx:Button label="{rp.currentItem}"/>
                </mx:Repeater>
            </mx:VBox>
        </mx:VBox>
    </mx:VBox>
</mx:Application>
  • Share/Bookmark

Examples of CSS buttons with center alignment in the page:

  • Share/Bookmark

3. Include management logic in the pop-up: Container only must manage return value of the pop-up:

Origin (myDlgShow.mxml):

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	creationComplete="onCreationComplete()">
	<mx:Script>
		<![CDATA[
			import mx.utils.ObjectProxy;
			import mx.controls.Alert;
			import mx.collections.ArrayCollection;
			import mx.collections.ListCollectionView;

			[Bindable]
			public var item:ObjectProxy;

			private function onCreationComplete():void {
				item=new ObjectProxy();
				item.label="Item container";
				MyDlg.showDialog(item, onAddItem, this);
			}

			private function onAddItem(event:Event):void {
				Alert.show(item.label);
			}
		]]>
	</mx:Script>
</mx:Application>

Pop-up (myDlg.mxml):

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="absolute" width="350" height="180"
				showCloseButton="true"
				title="Confirmar"
				close="onClose()">

	<mx:Metadata>
		[Event("returnEvent")]
	</mx:Metadata>

	<mx:Script>
		<![CDATA[
			import mx.utils.ObjectProxy;
			import mx.core.Container;
			import mx.binding.utils.BindingUtils;
			import mx.controls.Button;
			import mx.events.CloseEvent;
			import mx.core.Application;
			import mx.core.UIComponent;
			import mx.managers.PopUpManager;

			[Bindable]
            public var itemDlg:ObjectProxy;

			public static function showDialog(item:ObjectProxy, returnFunction:Function=null, container:Container=null, modal:Boolean=true): void
			{
		        var dlg:MyDlg = MyDlg (
		        	PopUpManager.createPopUp(
		        		Application.application as DisplayObject, MyDlg, modal
		        	)
		        );
		        PopUpManager.centerPopUp(dlg);
				BindingUtils.bindProperty(container, "item", dlg, "itemDlg");
		        dlg.addEventListener("returnEvent", returnFunction);
		        dlg.itemDlg=item;
			}

			private function onClose():void {
				PopUpManager.removePopUp(this);
			}

			private function onSelect():void {
				var item:ObjectProxy=new ObjectProxy();
				item.label="Item dialog";
				itemDlg = item;
				dispatchEvent(new Event("returnEvent"));
			}

		]]>
	</mx:Script>

	<mx:VBox>
		
		<mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" horizontalGap="5">
			<mx:Label text="{itemDlg.label}"/>
		</mx:HBox>

		
		<mx:HBox width="100%" height="36" horizontalGap="5" horizontalAlign="center" verticalAlign="middle">
			<mx:Button label="Seleccionar" click="onSelect()"/>
		</mx:HBox>
	</mx:VBox>
</mx:TitleWindow>

Ver entrada relacionada.

  • Share/Bookmark

Management methods of ListCollectionView cause access error in a collection in Flex SDK 3.3.

The following code:

var items:ListCollectionView = new ListCollectionView();
				var item:Object = new Object();
				item.label="item 1";
				items.addItem(item);

cause next exception:

RangeError: Index '0' specified is out of bounds.
	at mx.collections::ListCollectionView/addItemAt()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:482]
	at mx.collections::ListCollectionView/addItem()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:470]
	at Pruebas/onCreationComplete()[/Users/acarballares/Proyectos/Flex/Pruebas/src/Pruebas.mxml:14]
	at Pruebas/___Pruebas_Application1_creationComplete()[/Users/acarballares/Proyectos/Flex/Pruebas/src/Pruebas.mxml:3]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9308]
	at mx.core::UIComponent/set initialized()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169]
	at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
	at Function/http://adobe.com/AS3/2006/builtin::apply()
	at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8633]
	at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8573]

A solution can be initialize the object as a subclass ArrayCollection:

var items:ListCollectionView = new ArrayCollection();
  • Share/Bookmark

Flex Filereference have a file upload error in Firefox when you try upload through HTTPS.

Register error in adobe only happen with this browser and because of using non valid or recognized certificates.

  • Share/Bookmark
Creative Commons License
This blog is under Creative Commons licence, unless indicated otherwise.
Special thanks to Mark James for the icon set used in this blog.