Entries Tagged as 'Flex'

How to bring an existing Flex / AIR project into your FlexBuilder workspace.

Learning Flex can be a challenge and I've found looking at sample code that demonstrates a technique very helpful. You've found a good example, but how to move it into your work space.

 

Here are the steps.

 

  1. Download the flex project (i.e. samplecode.zip).
  2. Open FlexBuilder.
  3. Select File > Import > Flex Project.
  4. Next to "archive file" click the browse button and locate the zipped flex project on your hard drive.
  5. You may want to change the Project Location. For example to your web root if you are running server code. Of course this may be unnecessary for sample code you are learning from.
  6. Click the Finish button.

 

Now you can open and run the sample code, pick it apart and take that next step as a Flex developer.

 

ViewStack objects cause TypeError: Error #1009

Cannot access a property or method of a null object reference.

 

Viewstacks are great for hiding and showing groups of objects. For example you can display a datagrid with all your "Contacts" from an address book. Click on a person's name and display an "edit form" in the second viewstack position with all the contact details ready to edit.

 

The problem is when you try to set the details into the form input fields you get the TypeError #1009.

 

The reason is your viewstack does not create your form when the component is initialized. You have to tell the viewstack to create ALL the objects on initialization.

 

<mx:ViewStack
    width="100%"
    height="100%"
    creationPolicy="all">
        <view:ContactList />
        <view:ContactForm />
    </mx:ViewStack>

 

 

SQLError: Error #3129: The database schema changed with Flex and AIR SQL Lite Database

This error occures when you create new tables and then try to insert, select, etc during the same database connection.

 

Adobe has it listed on their runtime errors page.

 

3129 The database schema changed. Indicates that the operation could not be completed because of a schema error. This occurs when the schema of the database changes after a statement is prepared but before it finishes executing, such as if two SQLConnection instances are connected to the same database, and one instance changes the schema while another one is reading it.

 

The solution is to use the .close() method. For example. SomeSQLLiteDB.close() should be the last statement after creating your new tables. Then use SomeSQLLiteDB.open() before your insert, select, etc statement is executed.

 

The solution is to call the .close() method when you complete creating your tables. Then you can call the .connect() method and select, insert, etc from the newly created tables.

SomeSQLLiteDB.close()

SomeSQLLiteDB.connect()

 

 

Custom Event Handler named add will fire when the compenent is added to stage.

In the example below, I've created a component named two.mxml and it's based on the Panel component. Inside the two.mxml component meta data defines an event called "add". Here is the problem, the Panel componenet already has a method called "add". It's fired when the component is added to the stage.

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
        title="Two"
        paddingBottom="10"
        paddingLeft="10"
        paddingRight="10"
        paddingTop="10">
        <mx:Script>
            <![CDATA[
            import com.TwoEvent;
            import flash.events.Event;
            public function addHandler(event:MouseEvent):void
            {
                var submitEvent:TwoEvent = new TwoEvent(TwoEvent.ADD);
                dispatchEvent(submitEvent);
            }
            ]]>
        </mx:Script>

        <mx:Metadata>
                [Event(name="add", type="flash.events.Event")]
        </mx:Metadata>

        <mx:Button label="Dispatch and Say Hello" click="addHandler(event)"/>
</mx:Panel>

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  layout="absolute" xmlns:local="*"
  viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            public function changeState():void
            {
                currentState='two';
             }

             public function SayHello():void
            {
                Alert.show("Hello Panel Two");
             }


        ]]>
</mx:Script>

<mx:states>
        <mx:State name="two">
                <mx:AddChild position="lastChild">
                    <local:two add="SayHello()" x="254.5" y="20" width="222" height="155" horizontalAlign="center" verticalAlign="middle"/>
                </mx:AddChild>
            </mx:State>
</mx:states>

      <mx:Panel title="One" width="195" height="155" x="28" y="20" id="panel1" horizontalAlign="center" verticalAlign="middle">
            <mx:Button label="Show Panel 2" click="changeState();" />
      </mx:Panel>
</mx:Application>

 

 

The easy solution is to rename the custom event in your two.mxml componenet from "add" to something like "addNew". This was something I stumbled over and hope this helps anyone who's made this same mistake.

 

 

5 ways to learn Flex, if you've got some cash in your budget

Flash Camp
Adobe has re branded their popular Flex Camp as Flash Camp. These are modeled after BarCamp, where experienced developers in the community talk for roughly 50 min on some aspect of the Flash Platform (Flex, AIR, Flash) or how other technologies integrate with the Flash Platform. Each Flash Camp is unique and the agenda is determined by the organizer. They average 5 to 7 hours in length. These are NOT hands on workshops, but demonstrations of what is possible with the technology.

COST: $25

 

Lynda.com
Lynda.com is a well known software education company. I've used both their DVDs and online courses. The instructors are excellent and the self-paced nature works well for those with full time jobs and can't take 3 days off for in person training. They offer the following Flex related courses.

 

  • Flex 3 Essential Training (8.5 hours)
  • Flex 3 Beyond the Basics (8 hours)
  • ActionScript 3.0 in Flex Builder Essential Training (13 hours)
  • AIR Essential Training (4.25 hours)

 

Ask your Local Adobe User Group if they can secure a discount from Lynda.com.

COST
Monthly: $25 per month for access to all courses.
Annual Subscription: $250 per year for access to all courses.
Premium: $375 per year for access to all courses, plus exercise files.

 

Training from the Source - Flex 3
Jeff Tapper now a senior consultant at Digital Primates is the main author for this book and it's predecessor for Flex 2. I've seen Jeff present at Adobe MAX and he is definitely one of the leaders in the Flex Community.

COST: $38 at Amazon.com

 

360 Flex Conference
This is the premier Flex conference. It's created by developers for developers. Over the past two years 360 Flex has hosted conferences in San Jose, Atlanta, Seattle, Milan and on May 18-20 in Indianapolis, IN. Sessions from San Jose are available on AdobeTV using the following feed. http://sessions.onflex.org/1733261879.xml

COST VARIES: $480 for San Jose 2008 and $360 for Indianapolis 2009

 

Flex Authority
From the creators of ColdFusion Authority, Michael and Judith Dinowitz, the Flex Authority is a quarterly Journal with amazing how to articles from top Flex developers. Jeffery Houser of The Flex Show is the Editor for the magazine.

COST: Four Issues for 49.95

 

 

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds