Flex Pasta » Flex 3
Tinkering around with the new scrolling method s:Scroller in Flex 4. I like it much more than Flex 3. Less overhead and more control of scroll bars. Still the overall frustrations with scroll bars and where they should appear still remains. Thought and trial/error are required to get it just right.
I was recently trying to do a full application scroll bar rather than those “in component” ones. I was using a viewstack and having all sorts of issues with getting the scroll bars to actually activate. I have a simple example of my problem. Can you easily figure out the solution?!?!
Code Before
<?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” pageTitle=”Booyah”
xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″ height=”100%” xmlns:local=”*”>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Declarations>
<!– Place non-visual elements (e.g., services, value objects) here –>
</fx:Declarations>
<s:Scroller width=”100%” height=”100%” verticalScrollPolicy=”on”>
<s:VGroup width=”100%” height=”100%”>
<mx:LinkBar dataProvider=”{vs}”/>
<mx:ViewStack id=”vs” width=”100%” height=”100%”>
<s:NavigatorContent label=”Link 1″ width=”100%” height=”100%”>
<s:VGroup/>
</s:NavigatorContent>
<s:NavigatorContent label=”Link 2″ width=”100%” height=”100%”>
<s:VGroup height=”100%” width=”100%”>
<s:HGroup width=”100%” height=”500″>
<mx:Image source=”http://www.wallpaperbase.com/wallpapers/photography/greece/greece_6.jpg” height=”100%”/>
<s:Label text=”Some Text 2!” width=”50%”/>
</s:HGroup>
<s:HGroup width=”100%” height=”500″>
<mx:Image source=”http://www.photoatlas.com/photo/italy_venice_03.jpg” height=”100%”/>
<s:Label text=”Some Text 3!” width=”50%”/>
</s:HGroup>
<s:HGroup width=”100%” height=”500″>
<mx:Image source=”http://www1.pictures.zimbio.com/gi/St+Louis+Cardinals+v+Cincinnati+Reds+5GwTSG7xvgfl.jpg” height=”50%”/>
<s:Label text=”Some Text 4″ width=”50%”/>
</s:HGroup>
</s:VGroup>
</s:NavigatorContent>
</mx:ViewStack>
</s:VGroup>
</s:Scroller>
</s:Application>
When I run this, I am expecting a scroll bar on the application. Here is a screen shot of the output:
Checking out the right side, I see my scroll bar, but is disabled, despite content hanging off the bottom of the screen. The only reason the scroll bar is showing up at all is because I have verticalScrollPolicy=”on” for demo purposes. Looking the source can be a bit challenging to figure out a solution, even in a simple example. Figured out where the problem is?
2 1/2 years ago I published annotations for BlazeDS that allowed for placing tags on Java getters/setters to determine if a value is serialized to the Flex client. Soon I will publish a 3 part BlazeDS extension that does the following(with annotations of course).
- Serialization Profiles with BlazeDS - This was mentioned in a previous post and I will be releasing this soon along with the rest of the annotations code.
- Mate Code Generator - More details to come, but if you are familiar with the Mate Framework, this code generator will create complete EventMaps/DataManagers/Events from Java services(and it runs for the life of the project).
- Model Code Generator - This isn’t the kind where a button is pressed once to create Flex remote object bean classes. I don’t like code generators that only generate the file initially. I also don’t like when a code generator creates generated code that then the developer must extend(ex: Customer extends _Customer). I have created a code generator that does neither but still can be run endless times for the life of the project. Here is an example output file. The developer can add any code to the area marked as such in comments. Every time the generator is run it will clear out the rest of the file and regenerate the properties from the matching Java class.
/* File Generated by FlexPastaDomainGenerator v. 1.0
* Only edit the file in the designated area.
* All other changes will be lost
*/
package com.company.model
{[Bindable]
[RemoteClass(alias=”com.company.model.Address”)]
public class Address
{
public var country:String;
public var lot:String;
public var parcel:String;
public var state:String;
public var streetName:String;
public var streetNumber:String;
public var subdivision:String;
public var uuid:String;
public var zipCode:String;//**********EDIT AREA**********
//**********END EDIT**********
}
}
Looks for more details in the coming weeks!
Progress Bars via the mx:ProgressBar tag are easy to use in Flex. Unlike some kind of progress bars that can drive anyone insane….
Flex progress bars are easy to implement and great for usability. When there is a long database query or chance for network latency, a progress bar is always a good idea to keep the user informed that something is happening. Those with an artistic ability can create a custom progress image to use on a progress bar, but if not, the built in one is still a viable option. There are two main types of progress bars included in the Flex SDK. Ones that use percentages to show completeness and ones that use an indeterminate/unknown to give the user indication of activity. Both are implemented in the mx:ProgressBar tag/class.
The percentage progress bar is used directly with the mode property, which has three options, event, polled, and manual. This is used in conjunction with the source property which the progress bar can use to automatically update the progress bar.
Up until the other day, when using modal and/or pop up windows in Flex, I have always instantiated them in Actionscript. Since I use relative layout, I couldn’t really add an mxml component that would be a modal without it being drawn on the screen. The advantages of declaring a modal in mxml would be:
- Taking advantage of mx:Metadata tags that allow me to invoke methods when events occur without manually adding listeners
- Automatic binding the same way my other components work
- Less code; by declaring the pop up window in mxml, I don’t have to invoke a method that creates an instance of the pop-up
Here is how you can declare a modal/popup window in mxml:
<mx:ArrayCollection id=”modals”>
<MyPopupWindowComponent id=”modal1″ someBindings=”{bindingAVariable}” anEventThisComponentDispatchesInMetaData=”doSomething(event)”/>
</mx:ArrayCollection>
Now when you want to open the modal, just do PopupManager.addPopup(modal1,true,DisplayObject(Application.application));
This allows you to use the ease and power of bindings/metadata in modal windows.
A while back I did a post on the choppiness of mx:List scrolling and a mx:Repeater work around FTW(For the Win). Well in Flex 4, the List component will be FTW out of the box!!! Meaning, smooth scrolling item renderers!! It looks like the Flex SDK team has spent some time improving the quality, scrolling, and layout of item renderers. Here side by side are the examples from a Flex 3 List compared to the same code in a Flex 4 List. Check out the difference!
Flex 3 List with Image Scrolling
Flex 4 List with Image Scrolling



