Where do you write your code?

I've just started to learn Flex. One question I have is where
you put the ActionScript code?
I know i can put it in several locations (e.g. inline, within
a script-tag, in actionscript-files, in actionscript classes) but
what's the best way to go?
Up until now I haven't done so much coding, so I have just
written the code inside a <mx:Script>-tag in my MXML-file.
I'm starting to realize though that having both MXML and
ActionScript in the same file is a bit inconvinient when the amount
of code increases.
Since I come from the dark side ;) (Microsoft), I'm used to
having to files for each page/component; one with the "UI code"
(MXML in this case) and one with the logic (AS in this case). I
like that model, so I tried to do something similiar in Flex. My
MXML-file looks like this:
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" applicationComplete="MainCode()">
<mx:Script source="MainCode.as" />
<!-- Other MXML code -->
</mx:Application>
Then I create the MainCode.as and give it a function called
MainCode(). That way, I now have the code in a separate file/class,
and themethod becomes the starting point of the execution. Kind of
like the "document class" in Flash.
First, this seemed like a good solution to me BUT soon I
realized it has a big flaw. Since the class is not hard linked to
the MXML, I will not get any intellisense/codehints about the
components/controls I use in the MXML (at least I don't in
FlashDevelop).
So, how do you do it? Is there a way that is considered "best
practice"?

"haagel" <[email protected]> wrote in
message
news:[email protected]...
> I've just started to learn Flex. One question I have is
where you put the
> ActionScript code?
> I know i can put it in several locations (e.g. inline,
within a
> script-tag, in
> actionscript-files, in actionscript classes) but what's
the best way to
> go?
>
> Up until now I haven't done so much coding, so I have
just written the
> code
> inside a <mx:Script>-tag in my MXML-file. I'm
starting to realize though
> that
> having both MXML and ActionScript in the same file is a
bit inconvinient
> when
> the amount of code increases.
>
> Since I come from the dark side ;) (Microsoft), I'm used
to having to
> files
> for each page/component; one with the "UI code" (MXML in
this case) and
> one
> with the logic (AS in this case). I like that model, so
I tried to do
> something
> similiar in Flex. My MXML-file looks like this:
>
> <mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
> layout="absolute"
> applicationComplete="MainCode()">
> <mx:Script source="MainCode.as" />
> <!-- Other MXML code -->
> </mx:Application>
>
> Then I create the MainCode.as and give it a function
called MainCode().
> That
> way, I now have the code in a separate file/class, and
themethod becomes
> the
> starting point of the execution. Kind of like the
"document class" in
> Flash.
>
> First, this seemed like a good solution to me BUT soon I
realized it has a
> big
> flaw. Since the class is not hard linked to the MXML, I
will not get any
> intellisense/codehints about the components/controls I
use in the MXML (at
> least I don't in FlashDevelop).
>
> So, how do you do it? Is there a way that is considered
"best practice"?
It's better to do one of two things:
1) Get everything pretty much complete and then only pull it
out to an as
file when you're done. That way you get code hinting all the
way up to the
time that you pull out the code. Note that this will _not_ be
a class and
should not have a constructor, etc. or be named the same
thing as any MXML
file in your project.
2) Only pull out things that can truly stand alone, and make
them separate
class. You need to look up these terms on google or your
favorite search
engine "loosely coupled Flex components."
Also note that you can use more than one script tag, and
these will be
visible in outline view. Unfortunately you can't give them
ID's. Also,
using bookmarks can help with managing files with both MXML
and AS.

Similar Messages

  • Where do you receive your vertification code for your apple id?

    Where do you receive your vertification code for your apple id?

    Check your Spam and Junk mail folder.

  • Where do you buy your apps?

    Where do you buy your apps for the iphone? Right on the phone? Can you buy them online if you have an itunes gift card? 

    There are two ways of downloading apps on the iPhone, you can either download them directly from the iPhone using the App Store app, or from iTunes on the computer (Mac or PC), an iTunes gift card can be used on either
    iPhone:  Open the App Store app (should be an app with a blue icon on the first page if apps, unless you moved it elsewhere), tap on "Featured" on the bottom black bar, then scroll all the way down, you should then see two options, Redeem and Apple ID: <your Apple ID>, tap on Redeem, type in your iTunes gift card code, then tap Redeem, once the card is redeemed, you can then start searching for apps within the App Store app
    iTunes (Mac or PC):  Open iTunes and connect the iPhone (let it complete sync), click on iTunes Store on the left pane, then in the Quick Links pane, click Redeem, type in your iTunes gift card code, then click Redeem, once the card is redeemed, in the iTunes STORE pane to the left, click App Store, then you should get similar options to the App Store on the iPhone, download the apps from there and sync them to the iPhone

  • Where i shall write html code in jdeveloper

    Hello,
    please tell me where i can write html code in jdeveloper.
    Thanks

    Hi catalina,
    Html tags should not be used directly inside ADF faces pages which may lead to some undesirable results instead you can use ADF Faces tags itself using which you can do what ever you wanted to do with html tags.
    If you still need to use html tags, you can use ADF Faces html tags.
    Tag doc: http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/html/index.html
    Sireesha

  • Crystal Report XI: Can you write your query in SQL instead of using the GUI

    Hello
      In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
    Thank you
    alpha

    Moved to Database forum.
    No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
    Thank you
    Don

  • Where do you locate your location on the iPad?

    Where can you check your location on the iPad?

    I'm not sure what your asking but, I use a app called magic piano and when it shares my performance it states that my location is in Australia instead of United States ..
    When I updated my iPad my profile pic and location no longer is correct.
    So I'm trying to fix that and unsure how or why but would like to correct it..
    Thnx. ;)

  • Where do you get your images?

    I have accounts with several different stock image online
    companies. But things are getting very expensive.
    I was wondering if there was a website that offers free
    images. I'm also curious, where do you get your images?
    I can grab my digital camera, take a few pictures and edit
    with photoshop but thats not always the case.
    When you design a web page, where do you get your images?
    Thaks for any suggestions.
    Patrick

    "P@tty Ayers ~ACE"
    <[email protected]> wrote in message
    news:g6psi0$raq$[email protected]..
    >
    > "JoeyD1978" <[email protected]> wrote
    in message
    > news:g6pl69$jll$[email protected]..
    >> sxc.hu is a great site, I don't understand the
    confusion here either.
    >> It's
    >> setup exactly like iStock (and has existed for just
    as long). They have
    >> high-end photos at the bottom of their free results
    that you have to pay
    >> for
    >> through their sister site, but those are clearly
    marked.
    >
    > Well, this is weird. Yesterday when I pointed my browser
    to sxc.hu, I got
    > a very different site than I got today. I know that I
    used the same URL
    > yesterday, because it's still in my browser's memory.
    >
    > The site I got yesterday was of the type that
    domain-owners, or maybe web
    > hosts? use to make money off a domain that has no real
    web site. It had no
    > page title or heading other than "SXC.HU", and had
    nothing on the page but
    > searches on various words related to "stock photos".
    >
    > The site I get today looks like what "Tun Tun" and Joey
    are describing.
    >
    > That might explain the confusion!
    Patty, I've used stock.xchg (sxc.hu) before and found some
    good (and bad)
    images there. Another one to try is Morgue File -
    http://www.morguefile.com/
    some others to try:
    http://www.usa.gov/Topics/Graphics.shtml
    http://www.loc.gov/rr/print/
    http://www.imageafter.com/

  • Where do you get your mus

    Well basically the title says it all: Where do you get your music? MSN, Napster? Where? Could you please help me because I am in need of finding a new place to get music.

    I use rhapsody to-go service. I tried napster but did not like the layout. Rhapsody is pretty good ...you can try it for 2 weeks free.

  • Where do you get your PIN number from

    Where do you find your PIN number is there a standard one

    PIN for what? PIN is a "Personal Identification Number", so usually it's whatever you set it to.
    Some devices may have a default 0000 or 1234 PIN until you change it.

  • Where do you check your email at your appleid for instructions to verify your account?

    Where do you check your email at your appleid for instructions to varify on oyur iphone 4?

    Where do you check your email at your appleid for instructions to varify on oyur iphone 4?

  • Question to all: Where do you purchase your images???

    Guys/Gals,
    Where do you purchase your images when needed? Both photos and vector Illustrations.
    I buy from istockphoto.com and bigstockphotos.com, but is there anything better according to your experience?
    I am currently buying a lot of illustrations (vector) - cartoonlike, at about $15 each... which do you buy from and which is the best?Considering the selection and prices.
    I always thought that free image sites didn't have a good selection, am I wrong?
    The question is brough up, everybody that reads this should answer and give their point of view, I am curious to see (and I am sure you are too).
    Jack Newton

    iStock is your best choice for selection and price, but not always quality or even accuracy. iStock is stocked by photographers and artists trying to make extra money. Their offerings are always more diverse than what you'd find on a pro stock photo site. Photographers left to produce imagery on their own will pursue their interests and what they're good at, and that's why you'll find a lot of great stuff on iStock you won't find anywhere else. Sites like photos.com don't compare with this, but may have better visual quality. But, again, the number of "concepts" are limited. If you move above sites like iStock and photos.com then be prepared to dish out big money.
    iStock can be a godsend, but be careful. I often find many photographers will upsize their images at the cost of a loss of quality. I also find photographers who try to make their images better by touching them up with Photoshop, but many of them should just stick with staying behind the camera. I see images where areas were obviously cloned sloppily. Just make sure when selecting an image to zoom in and look at the quality and to check for the sloppy fixes.
    And be very careful when searching for something which you are not knowledgeable on. One time I was searching for Japanese imagery and found a photo labeled "Geisha". This "geisha" was a western girl in the proper make-up and hair... but she was wearing a Chinese dress! You do NOT want to embarrass your clients with something like that.
    Bottom line IMO, iStock is the way to go.

  • Zen Nano Plus Guys: Where Do You Get Your Mus

    I get mine off Limewire and I was basically told that it wouldn't work AFTER I purchased my brand new Nano Plus by the customer support guy. Where do you get your files from?

    I just got my Nano yesterday.. 4/29
    This is what I do:
    .Download the songs on Limewire
    2.Under the Library Tab on Limewire there is a button called "Explore". click on that.
    3. All of the songs that you have downloaded should show up when the folder pops up
    4. Open the Windows Media Player (if you dont have it u should get it) and go to the tab that says "Sync"
    5. Drag the files one-by-one onto "Items to Synchronize" on the Windows Media Player
    6. Once you are done, press "Start Sync" at the top.. it should work
    Now.. the only problem Im having is how to listen to all of my files. Ive downloaded 65 songs on here and its only playing 32 of them.

  • TS3274 where do you see your device on itunes

    where do you see your device on itunes

    You can make the new iTunes look like the old iTunes by clicking view, show side panel. Otherwise, click the link on the top right after you connect your device.

  • What is a PUK code and where do you find yours for your phone

    What is a PUK code and where do you find yours

    Log on to Verizon wireless and under your account after logging in, look at the device in question and it shows there. It stands for Phone Unlock Code
    Good Luck
    Message was edited by: Elector

  • Where do I write the code for customer exit variable?

    Hi Gurus,
    Can anyone tell me where and the procedure that I have to follow to get to the include ZXRSRU01 where I can write customer exit variable code.
    I know its written in ZXRSRU01, but in my system it seems like its not active or does not exist. How do I get to start working in this include for customer exit variables?
    Any help is appreciated. Thank you.
    Regards
    Reddy

    hi Reddy,
    variable exit use enhancement RSR00001 not RSAP0001. EXIT_SAPLRRS0_001.
    try to follow some steps in 'how to' doc related to this, and sample code may useful for you
    https://websmp206.sap-ag.de/~sapdownload/011000358700002762582003E/HowToDeriveVariableValue.pdf
    https://websmp206.sap-ag.de/~sapdownload/011000358700002765042003E/HowToVerifyVariableInput.pdf
      INCLUDE ZXRSRU01                                                   *
      DATA: L_S_RANGE TYPE RSR_S_RANGESID.
      DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
      CASE I_VNAM.
      WHEN 'CUMMONTH'.
        IF I_STEP = 2.                                  "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                  WHERE VNAM = 'MONTH'.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW      = LOC_VAR_RANGE-LOW(4)."low value, e.g.200001
            L_S_RANGE-LOW+4(2) = '01'.
            L_S_RANGE-HIGH     = LOC_VAR_RANGE-LOW.   "high value = input
            L_S_RANGE-SIGN     = 'I'.
            L_S_RANGE-OPT      = 'BT'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
      ENDCASE.
    hope this helps.

Maybe you are looking for