Getting 0,0 for multiple touches on iPhone?

It’s taken a while for me to discover the simple solution as to why one of my 2 UITouch objects when grabbing the allTouches set from the iPhone SDK touchesMoved event always resulted in 0,0 co-ordinates in my view…

NSSet *allTouches = [event allTouches];

Solution: you need to switch on the multipleTouchEnabled property of the view you want to get multiple touch events from!! ie:

[self.view setMultipleTouchEnabled:YES];

Hope this post helps others…

Unexpected scroll results with HBox/VBox/Containers using percent height/width

The objective:

The screen grab below is taken from a Flex application I’m building. This page of the app comprises of 2 VBoxes inside an HBox. The 2 VBoxes need to size to 100% of the height of the HBox container. The user can edit any of the text fields. When the user edits the body text of the left column, if they use up all the vertical space of that left VBox then I’d like the VBox containing the title and the boy text to create scroll bars, not to resize it’s parent VBox. Simple right?

Not so simple… Here’s a snippet of the code:

<mx:VBox width=”50%” height=”100%” styleName=”whiteContainer”>

<mx:Box direction=”vertical” width=”100%” height=”100%” styleName=”scrollableContentWithText” >
<mx:HBox width=”100%” verticalAlign=”middle”>
<mx:Image source=”assets/images/book74x42.png” width=”74″ height=”42″ />
<controls:AdvancedTextArea id=”title1″ multiline=”false” textModify=”captialize” styleName=”whiteContainerHeader” condenseWhite=”true” width=”100%” prompt=”{resourceManager.getString(‘resources’,’ENTER_TEXT_PROMPT’).toUpperCase()}” />
</mx:HBox>
<controls:AdvancedTextArea id=”body1″ styleName=”blueOnWhiteText” condenseWhite=”true” width=”100%” prompt=”{resourceManager.getString(‘resources’,’ENTER_TEXT_PROMPT’)}” />
</mx:Box>
</mx:VBox>

And here are the results when that body text gets too deep for the VBox:

So the whole parent HBox ended up getting stretched. Not the results I expected.

The solution as it turns out is pretty straight forward. The VBox containing the left column needs it’s minHeight and minWidth properties set to 0! The reason is that with containers using percentage based sizing flex sets the min height and min width properties to the cumulative width and height of the container’s children components. So in my example as the editable text component gets deeper/taller this automatically increases the minHeight property of it’s parent container.

So by explicitly setting the parent container’s minHeight and minWidth to 0:

<mx:VBox width=”50%” height=”100%” styleName=”whiteContainer”>
<mx:Box direction=”vertical” width=”100%” height=”100%” minHeight=”0″ minWidth=”0″ styleName=”scrollableContentWithText” >
<mx:HBox width=”100%” verticalAlign=”middle”>
<mx:Image source=”assets/images/book74x42.png” width=”74″ height=”42″ />
<controls:AdvancedTextArea id=”title1″ multiline=”false” textModify=”captialize” styleName=”whiteContainerHeader” condenseWhite=”true” width=”100%” prompt=”{resourceManager.getString(‘resources’,’ENTER_TEXT_PROMPT’).toUpperCase()}” />
</mx:HBox>
<controls:AdvancedTextArea id=”body1″ styleName=”blueOnWhiteText” condenseWhite=”true” width=”100%” prompt=”{resourceManager.getString(‘resources’,’ENTER_TEXT_PROMPT’)}” />
</mx:Box>
</mx:VBox>

… I ended up with the desired result:

NativeWindow class in AIR does not support Flex components

Just a quick tip for any AIR developer’s searching for why there’s no addChild method in the NativeWindow class – I wasted a fair while on this over the weekend. I was adding Flex components to the stage property of NativeWindow and trying various other work arounds. Although you don’t get errors for doing this the Flex components never appear when you test your app!

If you want to add Flex components to a new NativeWindow in AIR then this is what Window class is for. So don’t waste time creating a new NativeWindow and activating it, just create/subclass the Window class not NativeWindow and you’ll find all the stanard Flex component properties and methods 🙂

Duh!

Corner Radius Doesn’t work on HBox/VBox

I haven’t been responsible for the skinning on most of our Flex projects but today that’s exactly what I’ve been doing all day. I just discovered that setting the cornerRadius style of a HBox or VBox has no effect when used on it’s own in css or MXML. The style ‘borderStyle’ also needs to be set to ‘solid’ for the cornerRadius you’ve set to display! Weird…

Flex Builder 3 Development + Flash Player 10 Beta = Grief

I installed Flash Player 10 Beta the other day which unfortunately led to about 1 hours wasted Flex Development time this morning when I started work this morning. I tried run a Flex application I’ve been working on in debug mode. Last time I ran it on Friday it worked fine but this time I got an Eclipse alert the moment I tried to run the debug with the following message:

/Library/Internet Plug-Ins/Flash Player.plugin

Flex Builder cannot locate the required debugger version of Flash Player. You might need to install the debugger version of Flash Player 9 or reinstall Flex Builder.

Do you want to try to debug with the current version?

Click yes and the app runs but no debug traces back in Flex Builder.

The problem turned out to be that when I installed Flash 10 Beta Player it overwrote my default Flash 9 Debug Player. I found a reference to this bug in the Adobe Bugs DB. Looks like as OS X specific bug.

Anyway, the solution is to uninstall Flash Player and then reinstall Flash 9 Debug version which isn’t ideal as I’d like to keep Flash 10 Beta running.

If anyones knows how to run the 2 simultaneously please let me know 🙂