01 May 2009 ~ 8 Comments

Flex 101 – Back to the basics

Back a few months ago I had the opportunity to present an introduction to Flex talk for the PDX RIA group. I promised to post the files we built during the live demo. Then this week I was honored to present and Adobe Tech Wedndesday to my peer Adobe UGM and Community experts. I gave a very similar talk and the demo was almost identical.

A couple people have asked for the files we created during the demo, and since I dont think I ever posted them after the user group meeting, I wanted to make sure I actually made them available.

Flex 101 – Back to basics – Demo Files

And as an added bonus, the presentation I gave was recorded so if you are feeling like enjoying a Flex 101 talk please view it here. My actual presentation starts at about minute 15, but Leif has a very important PSA in the beginning.

8 Responses to “Flex 101 – Back to the basics”

  1. Andrew Maurer 2 May 2009 at 8:48 am Permalink

    Great Flex 101 Simeon! You really opened my eyes in how to pass data around between components with events and VOs. Thanks again!

  2. Alan Rother 4 May 2009 at 4:02 pm Permalink

    Hey Simeon,

    How would you go about loading the component from AS? Rather than

    I managed to load it in a popupmanager window, but I can’t get it to add the event listener. It throws an error…

    private function openWindow():void {
    win = view.UserForm(PopUpManager.createPopUp(this, UserForm, false));
    PopUpManager.centerPopUp(win);
    win.addEventListener(UserEvents.USER_SUBMIT, onSubmit);
    }

    =]

  3. Simeon 4 May 2009 at 4:07 pm Permalink

    In Actionscript you can create it just like you would any other class.

    var uf:UserForm = new UserForm();
    addChild(uf);

    Let me know if you need a more specific example.

    Thanks,
    sim

  4. Alan Rother 4 May 2009 at 5:17 pm Permalink

    I guess specifically the issue I am having is around the event listener. I haven’t been able to successfully add the event listener to the component using AS. When I do this

    win.addEventListener(UserEvents.USER_SUBMIT, onSubmit);

    It throws an error:

    1119: Access of possibly undefined property USER_SUBMIT through a reference with static type Class.

  5. Simeon 4 May 2009 at 5:19 pm Permalink

    That error is actually saying that there is no property named USER_SUBMIT on the UserEvents class. So either its not defined as public or not static.

    Thats my guess anyway. Your syntax for addEventListener is perfect.

  6. Alan Rother 4 May 2009 at 5:35 pm Permalink

    AHHH.. I got it now…

    Yeah that wasn’t in the demo. I added this to the UserEvents class file…

    // Define static constant.
    public static const USER_SUBMIT:String = “userSubmit”;

    …and it worked.

    Why doesn’t it work without it in the class using AS but it does work using the MXML way?

  7. Simeon 4 May 2009 at 8:51 pm Permalink

    Hey Alan,

    So the trick is that in the mxml it uses the metadata to define the event as available. And when we created the event,before we dispatch it in the component, we used a string. We could have replaced that string with the static const like you did in the AS version.

    HTH,
    sim

  8. Mike 23 May 2009 at 1:48 pm Permalink

    Hi, nice posts there :-) thank’s for the interesting information


Leave a Reply

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIEhpISBNeSBuYW1lIGlzIFNpbWVvbiBCYXRlbWFuIGFuZCBJIGFtIGEgd2ViIGFwcGxpY2F0aW9uIGRldmVsb3BlciBzcGVjaWFsaXppbmcgaW4gdGhlIEFkb2JlIEZsYXNoIFBsYXRmb3JtLiAgSSBhbSBhbiBBZG9iZSBDb21tdW5pdHkgUHJvZmVzc2lvbmFsIGFuZCBhbiBBZG9iZSBDZXJ0aWZpZWQgVHJhaW5lciBmb3IgRmxleCBhbmQgQUlSLiAgSSBhbSBhbHNvIHRoZSBQcmluY2lwbGUgSW5zdGlnYXRvciBmb3IgUE5XIFJhaW4gTExDIGEgUklBIGNvbnN1bHRpbmcgYW5kIG1lbnRvcmluZyBjb21wYW55LjwvbGk+PGxpPjxzdHJvbmc+d29vX2Fkc19yb3RhdGU8L3N0cm9uZz4gLSB0cnVlPC9saT48bGk+PHN0cm9uZz53b29fYWRfaW1hZ2VfMTwvc3Ryb25nPiAtIGh0dHA6Ly93d3cud29vdGhlbWVzLmNvbS9hZHMvd29vdGhlbWVzLTEyNXgxMjUtMS5naWY8L2xpPjxsaT48c3Ryb25nPndvb19hZF9pbWFnZV8yPC9zdHJvbmc+IC0gaHR0cDovL3d3dy53b290aGVtZXMuY29tL2Fkcy93b290aGVtZXMtMTI1eDEyNS0yLmdpZjwvbGk+PGxpPjxzdHJvbmc+d29vX2FkX2ltYWdlXzM8L3N0cm9uZz4gLSBodHRwOi8vd3d3L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