Archive

Archive for July, 2009

Objective C: Read iPhone Preferences From Application

July 19th, 2009 No comments

You can read preferences from your iPhone Application using the NSUserDefaults class from iPhone SDK.

Here is how you can read the delay value before the phone is starting to dial a number

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
delayBeforeDialing = [userDefaults floatForKey:@"delayBeforeDialing"];

The key, “delayBeforeDialing” in this example, needs to match the Key value in Root.plist.

There are different accessor methods depending on the type of variable you want to retrieve.

* arrayForKey
* boolForKey
* dataForKey
* dictionaryForKey
* floatForKey
* integerForKey
* objectForKey
* stringArrayForKey
* stringForKey

You don’t have to use a UI for your preferences. If you just want to conveniently store values associated with your application, that you can read back later, you can use the setter methods of NSUserDefaults.

Objective C: Show online image on iPhone

July 18th, 2009 No comments

By default the UIImageView control from the iPhone sdk does not allow us to load images from a specific url. In this case we do a little tryck and use a UIWebView.

- (void)loadImage:(NSString*)url frame:(CGRect)frame {
NSString* textHTML = @"
<!--
body {
background-color: transparent;
color: white;
}
-->
<img src="\" alt="" width="%0.0f" height="%0.0f" />
";
 
NSString* html = [NSString stringWithFormat:textHTML, url, frame.size.width, frame.size.height];
 
if(webView == nil) {
webView = [[UIWebView alloc] initWithFrame:frame];
[self.view addSubview:webView];
}
 
[webView loadHTMLString:html baseURL:nil];
}

Flex Array Performance: For vs. ForEach

July 13th, 2009 No comments

We made a little test to see the flex performance on parsing an large array.

Here is the experiment:

var size:Number = 10000000;
var arr:Array = [];
for (var i:int=0; i
var time:Number, o:Object;
 
// for()
time = getTimer();
for (i=0; i=0; i--) { arr[i]; }
trace("for reversed test: "+(getTimer()-time)+"ms");
 
// for..in
time = getTimer();
for each(o in arr) { o; }
trace("for each test: "+(getTimer()-time)+"ms");

And here are the results:

for test: 124ms
for reversed test: 110ms
for each test: 261ms

We wish you to use this results wisely !

————————
The TiMeister Team

Flex: Unable To Open locale en_US or fr_FR

July 13th, 2009 2 comments

If you want to create a localized application you may find yourself in a strange situation when you did all the steps like in the book, but you continue to receive the “Unable to open locale xx_XX” error messages.

To simulate a fix on this issue we will take the example of adding French to your app.

Basic steps:
- The first step is to create a fr_FR folder under the /locale/ one exactly like in the Flex documentation and then add the translated bundle.properties file.
- The second step is to add the compiler options: -locale en_US,fr_FR

Extra steps you need to make in order to get rid of the ugly “unable to open locale” error message:

1. goto the following path :

<flex-install-folder>/sdks/<current-sdk-folder>/bin/

for windows it’s: C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\bin\

2. Execute the following command:

> copylocale.exe en_US fr_FR

That’s all, hope we helped you!
————————-

The TiMeister Team

FLEX: Why is stage == null?

July 13th, 2009 1 comment

Hello,

If you are trying to access the stage of your application right when your app is completed then you’re doing something wrong.

BAD CODE Most of the cases programmers make the following mistake:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.display.StageDisplayState;
            private function init():void
            {
                var s:Stage = this.stage; //<<-- this.stage == null...why??
                s.scaleMode = StageScaleMode.EXACT_FIT;
            }
        ]]>
    </mx:Script>
</mx:WindowedApplication>

GOOD CODE : The correct approach is the following:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
       xmlns:mx="http://www.adobe.com/2006/mxml"
       creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.display.StageDisplayState;
            private function init():void
            {
                this.systemManager.stage.scaleMode = StageScaleMode.EXACT_FIT;
            }
        ]]>
    </mx:Script>
</mx:WindowedApplication>

Hope we helped you with this issue we also had in our beginning as Flex Devlopers

Top Flex Blogs and Resources

July 5th, 2009 No comments

Hello,

We would like to share with the list with our preferred blogs on adobe flex news , and also the top flex resource websites that could came handy anytime

NEWS and Cool Stuff:

* Mihai Corlan’s personal blog
http://corlan.org – Mihai is a flash platform evangelist at Adobe Inc. and one of the most interesting peoples we meet

* Doug McCune
http://dougmccune.com/blog/ – Doug is a pretty big name in the Flex community (he gives presentations all over the country at Flex events), most of the items you are going to find on his site are examples of cool applications built using Flex.

* CFLEX: Community Flex

http://www.cflex.net/

* Dzone
http://www.dzone.com/links/index.html – Dzone is a great community based site for sharing developer links. The site is setup in a similar fashion as popular sites such as Digg or Reddit.

* Flex.org
http://flex.org/ – Flex.org is the main community site for Flex developers, which includes a showcase and resources for everything from PHP to .Net.

Resources & Examples:

* Adobe Flex Developer Center
http://www.adobe.com/devnet/flex/ – The Adobe Developer Center is great resource for complete tutorials and articles on how to get started with Flex or any of the other Adobe products. The other Adobe resource is the Cookbook which is built off of community code snippets that solve small programming tasks.

* Flex Examples
Peter deHaan currently works for Adobe on the Flex SDK QA team. He writes so many small tutorials that it’s hard to even keep up with this man on any level.

* Alex Harui
http://blogs.adobe.com/aharui/ -Alex writes short posts that are usually nice Flex examples solving common and uncommon problems people run across in Flex. He works with the Adobe Flex core team in San Francisco.

* ScaleNine
http://www.scalenine.com/ – Skins and Themes for Flex and AIR

* Flex SDK

http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK

* Flex Showcase

http://flex.org/showcase/

* Flex Developer Center

http://www.adobe.com/devnet/flex/

* Franto.com
http://www.franto.com/ – Flex, AIR, Flash, ActionScript Tutorials, Tips, Tricks.

* The Flex Show

http://www.theflexshow.com/blog/

* Marco Casario

http://casario.blogs.com/mmworld/

Flex and Silverlight: What Will the Next Five Years Look Like

July 5th, 2009 No comments