Archive

Archive for the ‘Design’ Category

Flex: Unable To Open locale en_US or fr_FR

July 13th, 2009 No 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 No comments

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

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

July 5th, 2009 No comments

Call function from Flex to Flash

June 24th, 2009 2 comments

How to call a flash function from flex?

  1. Load the AS3 swf file using an instance of SWFLoader.
  2. Call the function like this:
mySWFLoader.content.functionName();

How to listen for flash events from flex?

  1. // In your Flex app
    /* called when your SWFLoader finishes loading the SWF */
    private function onMySWFLoaded( p_event:Event ) :void
    {
          mySWFLoader.content.addEventListener( “clicked”, onSWFClick );
    }

    /* callback for the clicked event */
    private function onSWFClick( event:Event ) :void
    {
          mx.controls.Alert.show( ‘Click event raised!’ );
    }

  2. // In Flash Movie
    /* called when the button in your flash movie is clicked */
    private function onButtonClick( p_event:Event ) :void
    {
          dispatchEvent( new Event( “clicked” );
    }

How to call a flex function from flash at a specific frame?

Embed(source=“../assets/swf/myFlashComponent.swf”, symbol=“Preloader”)]
private var FlashPreloaderSymbol:Class;
private var clip:MovieClip;

clip = new FlashPreloaderSymbol();
addChild(clip);

private function onFlexInitComplete( event:FlexEvent ):void
{
clip.addFrameScript(47, callMyFunction);
}



Create applications with Adobe Catalyst

June 24th, 2009 No comments


We wanted to share with you a great video tutorial about how to use Adobe Flash Catalyst and create Flex Applications starting just with an image.
The tutorial explains in details how you can create a Flex button and a scrollbar using Catalyst.

Flex Builder 4 Refactored to Flash Builder

June 6th, 2009 2 comments

The next version of our IDE, Flex Builder, will be called Flash Builder 4.

There is already available a public beta for Flash Builder 4 and Flash Catalyst (check Adobe Labs for downloads).

Mihai Corlan (Platform Evangelist for Adobe):
At the same time, we will not change the name of Flex Builder 3. This will stay as it is now. Furthermore, the names of the Flex framework, and the Flex SDK, remain unchanged. The same goes for Flash Professional, which remains unchanged.”
….
“This has happened to me more than once. When I ask people at conferences “Who’s a Flex developer?” many people are unsure how to answer. Why? Because some of you are using the Flex framework, to create Flex or AIR applications, and not our IDE (Flex Builder), some of you are using Flex Builder, but without using the Flex framework (you use ActionScript 3 to create Flash applications). Thus the uncertainty.

Of course, the correct answer is this: anyone who uses the Flex framework, is a Flex developer. It doesn’t matter what tools you use to create these applications. At the same time, any Flex application gets compiled into a SWF file, which is played by the Flash Player. The same happens with the applications written using ActionScript and not the Flex framework.

So looking at it from this perspective, I think it makes a lot of sense. Have the developer tool that is used for creating Flash/AIR applications with or without the Flex framework called Flash Builder 4.

Flex Builder 3 Flash Catalyst Flash Builder 4

Adobe Flex Button with Photoshop (web 2.0 button skin)

June 1st, 2009 1 comment


Here you can see the live result and also download the project source code by right clicking inside the application.

Step 1:
Create Up, Over, Down, Disabled states for the button with Photoshop

1.1 Open Photoshop and choose the desired button size. I will choose 90×28px with transparent background.

1_button_size

1.2 Using the “rounded rectagle tool” create the button to look like in the image

1_button_size

1.3 Duplicate the existing layer, set the “Fill” property to 0 and then apply a gradient effect like in the image below.


1.4 now let’s make the button cloured :D . Apply to the first layer (original) an horizontal gradient overlay like in the image.


1.5 To make the button look even better we add a border and some inner glow to the originl layer like in the images below



1.6 Duplicate the first layer (original) and edit the colors so you can get all 4 states of our button.


1.7 after getting ready all states for the buttons export them 1 by 1 as .png and name them button_up.png button_over.png button_down.png and button_dis.png

Step 2:
Add images to project and create CSS for the button

2.1 Create an Adobe Flex project and name it PhotoshopButton.



2.2 Create a folder inside the /src folder and name it /images

2.3 Copy the 4 png images to /src/images/

2.4 Create a folder inside the /src folder and name it /css, inside this folder Add a new css file and name it main.css

2.5 Inside the main.css file add the following button style:


/* CSS file */
Button
{
     up-skin: Embed(source="/images/button_up.png");
     over-skin: Embed(source="/images/button_over.png");
     down-skin: Embed(source="/images/button_down.png");
     disabled-skin: Embed(source="/images/button_dis.png");
     selected-down-skin: Embed(source="/images/button_down.png");
     selected-up-skin: Embed(source="/images/button_down.png");
    

     color: #ffffff;
     roll-over-color: #000000;
     disabled-color: #efefef;
}


2.6 Your project should look until now like this



2.7 Open the PhotoshopButton.mxml file and add the reference to your css file



<mx:Style source="css/main.css"/>

//Then add some buttons and let's see how does it look :)

<mx:HBox width= "100%" horizontalAlign="center">
    <mx:Button label= "Click Me!"/>
    <mx:Button label= "Disabled" enabled= "false"/>
</mx:HBox>


And again the result…


That’s all, enjoy!