Pure Actionscript vs. MXML

I understand that the answer to this question may be mostly
subjective to some, but I'm trying to zero in on the objective
part. In developing my apps, I am finding a regular tension between
having my Flex components developed in MXML vs. Actionscript. I
wanted to ask a general question, and again, trying to be objective
as possible, is it better to develop Flex components in MXML or in
pure Actionscript?
While MXML of course let's you perform WYSIWYG development in
Flex Builder's GUI editor, I have run into things that can't be
done very gracefully in MXML, reuse of MXML components can become
cumbersome, and there's a lack of control of loading and unloading
of components in MXML, which you can accomplish in Actionscript
much better.
I have noticed that what I have seen of the Flex API is pure
Actionscript, which would indicate a lean toward Actionscript, but
then I've seen code snippets for components in various places on
the web posted in MXML.
So to try to get down to the crux of the matter -- is it
inherently better to develop Flex components in pure Actionscript
or in MXML, and why?
Thanks -- I'm curious as to community responses....
B

Tankman,
I'll take one last stab here.
quote:
Wait, you've completely lost me- you're saying that MXML
isn't declarative because it can include Actionscript?
You said previously that "the Flex documentation explicitly
states that MXML is declarative, and therefore limited". I replied
with "MXML isn't completely declarative, it allows embedded
Actionscript." In other words, while MXML components are
declarative, they aren't 100% declarative. An MXML component is
both declarative and includes embedded Actionscript. The intent of
the original question was to compare writing components in MXML
(which includes embedded Actionscript), versus writing components
exclusively in Actionscript. Never at any time was there any
intention to be discussing writing components in MXML while
prohibiting any use of embedded Actionscript, like virtually all
tutorials and samples from Adobe do. The thrust is to determine if
going in either direction (MXML, which again includes embedded
Actionscript, vs. pure Actionscript) either provides or removes any
features / functionality that the other has access to.
quote:
By that logic, no, there are no limitations to MXML. Since it
has actionscript in it.
Now you've answered the question. In your opinion, writing a
component using MXML (once again, which includes embedded
Actionscript) has no limitations.
quote:
By your classification system, I could just make my entire
application one MXML file, with 9000 lines of actionscript in it,
doing all the work, and that would count as "MXML".
Yes, this is true. But the question wasn't an architectural
design one of how the app should be broken into subcomponents, the
question was about the merits of building your components in MXML
vs. pure Actionscript. Your scenario has nothing to do with using
MXML vs. pure Actionscript -- that is merely a design choice with
whichever one you choose. One could just as easily write 9000 lines
of Actionscript in a single monolithic Actionscript class.
Based on your answer above, about there being no limitations
of MXML when you include Actionscript, if that is true, then I
believe one has to conclude that writing MXML components is
superior to Actionscript, based on the fact that Actionscript
components cannot be rendered and modified in the designer. Now,
whether MXML has limitations was the question posed in this mail
thread, and that answer still remains to be seen. But if your
answer is true, then MXML is clearly superior, based on avaiable
tooling, to Actionscript.

Similar Messages

  • Use mx and spark components in pure ActionScript project?

    I'm working on an AIR project in Flash Builder 4, but I'm not using MXML at all (pure ActionScript). Is there a way for me to instantiate and use mx and spark components without MXML? If not, what is the minimal amount of MXML I have to use? FYI, I've already tried all of the following hacks with absolutely no luck:
    http://www.actionscript.org/forums/showthread.php3?t=143062
    http://ersatz.tv/2009/off-topic-flex-components-without-mxml
    http://stackoverflow.com/questions/141288/possible-to-use-flex-framework-components-withou t-using-mxml
    I much prefer ActionScript over MXML. Why does Adobe have such a hard-on for this MXML ****?! It's like all that code and all those great components are going to waste.

    Me too.. . I'm a pure as3 guy and all these components go to waste. You would think they would allow people to generate components via mxml or as3...

  • Pure ActionScript project for Adobe AIR

    I've probably missed an obvious button or checkbox somewhere?
    I've seen that when you create a new MXML project, you have
    the option to target it at AIR. How do you do this for a pure
    ActionScript project? (Or import an existing pure ActionScript
    project that was written for AIR?)

    Hi Mister Lafrance,
    But, but it is same problem with creating project after build configure mxml to as. It can to show error - i have tried anything. It can not work while java runtime kills or show a lot of errors. Like this
    Error: ...
    at ...
    at...
    Please make sure my post!!! Sorry we must to configure manuel with RUN/Debug and adding as files....
    Thanks!
    Great nice tutorial! I hope because air developer are happy with Adobe Air Applications.
    Suggestions:
    new functions for executing applications like this flash.system.os.exec or flash.system.exec - If you want to build distributable Air Multi Applications.
    Application Air should to make default directory for important distributing air installers. If you want to work 1 or more application in currect directory.
    Like this:
    /mycompany <- that is root directory was created by frist air installer.
    ./airapps - that new distributing air installer while you after start of air application
    .//airapps/utilities/ <- example Air SDK should to copy into.. or nice air application like this Languagechooser or StyleChooser etc..
    ./airapps/softwares <- your built application like Widget Builder, Splashup or IconGenerater etc..
    ./airapps/config/ <- your currect saved config files. Important: all applications of distributing air applications will to load your currect config like Styles and Languages...
    ./myapp Binary <- create by air installer.
    ./shared/ <- assets,. libraries, templates and more files were created by Air installer.
    Can you make sure for my idea of distributing air applications? We would to talk with new file for Air distributuing packages = *.airdp.
    Thanks and best regards, SnakeMedia

  • How do i make a pure actionscript as simple native window?

    Hello @all anythings,
    I ask about a sample pure framework by Flex for Adobe Air.
    An Example: Window with customizable buttons - If i use boolen  for visible or invisible buttons like this:
    http://livedocs.adobe.com/flex/3/html/help.html?content=Part6_ProgAS_1.html
    For Example:
    NativeWindowPanel:
    <sm:NativeAirWindow icon="true" closable="true" minimizable="true" resizable="false">
    </sm:NativeAirWindow>
    How do i know that code with AS3. I want to build custom window for native window - Non-FlexChrome?
    Sorry my Language is same problematy...
    But I want to learn about pure actionscript for creating sample frameworks & components.... That is new native Language for German?
    Thanks and best regards...
    Snake Media Inc

    <code>
    [http://example.com text]
    </code>

  • Unwanted Android selection behaviour... different in Flex versus pure ActionScript... Why?

    Hi,
    I'm trying to get to the bottom of the text selection behaviour on my Android Xoom under different circumstances:
    1. In a pure ActionScript mobile app, selection and copy / paste is controlled through a floating control that appears on screen without resizing or otherwise moving anything
    2. In a Flex mobile app, selection and copy / paste is controlled through a UI bar that appears at the top of the screen, pushing the entire app downwards, losing focus on my textfield, ballsing up every bit of control I have in addition to confusing the hell out of my user whose finger is no longer pointing at the piece of text they wanted to select but rather at something else that is about a half-inch above that point...
    So...
    Obviously, I want to get to 1. for Flex - eg: I want to allow selection and copy / paste without loss of focus, without repositioning and without confusing the hell out of my user.
    Does anybody have any clues how I can achieve this?
    Thanks,
    G

    Got it. The two selection behaviours depend on the underlying skin.
    This one works with Flex:
    skinClass
    : ClassReference("spark.skins.mobile.TextInputSkin"
    Where this one shifts the app down, places a bar above, and generally screws with any interactivity you may have wanted to do using your selected text...
    skinClass: ClassReference("spark.skins.mobile.StageTextAreaSkin"
    G

  • ActionScript and MXML highlightubg

    I'm a low vision guy, I can't use flex builder because I need
    to change default editor colors (actionscript and mxml editors).
    In others IDEs normally i change background and foreground
    colors to "white over black".
    Help, please

    found a solution for you
    in your eclipse instlation
    go to \plugins\com.adobe.flexbuilder.editors.common_xxxxx\
    directory
    P.S xxxx means some numbers it might be different on your
    machin .
    unzip common.jar file
    then go into
    common\com\adobe\flexbuilder\editors\common\color directory
    edit Colors.xml to your prefferences (it has hex values for
    colors , its pretty self descriptive) and after you finish editing
    put that back into the jar or re-jar that whole directory .

  • Pure Actionscript for Adobe Air 1.5.x - I want to know without mxml...

    Hello guys,
    I want to learn about advancad programming because i want to know for intelligent like you good workers...
    Question 1:
    How does my application create new config file and write config file?
    - Save currect language! like you life in US. I life in Germany
    - Save currect setting by my application - example Style for your favorite color or currect setting: function for splash or without splash...
    - Save cuurect file type like your file was created by Adobe Fireworks CS3 = *.png or any application OpenOffice: file was created by OpenOffice - Wrie...
    - Save for backup files: If you want to restore your applications - same that application happens...
    Question 2:
    How do i know problems of events?
    - If i see currect event but compiler says error. Why does compiler show same error from Flex SDK/ Fledx Builder 3.0x?
    Question 3:
    Can i build my application with new trial version or bussnis version? Or without bussnis mode?
    Question 4:
    Can i work only complete as files into new application for Adobe Air?
    It is too heavy? I do not have panic of action scripts. I know about AS3 okay. But i have forgotten same latast times. :(  I want to save example or important codes of AS3 into my head / brain.
    Now can you same example for non-mxml programming?
    Thank you best regards, SnakeMedia

    Dear Star Traveler,  Thanks for your reply. I checked out the support document link you provided but all it really did for me was reinforce the idea that I'm not thinking in a helpful manner about how iCloud operates in connection with my Mac as well as devices like my iPad. The mechanism I had used to get photos into iCloud from my iPad was that I had already had them in an album which the system labeled "My Photo Stream". I used the "iCloud" section of the iPad to turn off the iCloud and it asked if I wanted to store the photos in iCloud I think. When I answered yes, that's when the troublesome deed occurred.  Luckily it did not delete any photos which I had in any other album nor did it delete any photos which I have in the main "Photos" directory nor in "Camera Roll". All it did was allegedly transfer photos which were in "My Photo Stream" to the iCloud, deleting the photo stream in the process. Naively I then thought that those photos which had been in the photo stream would then appear when I logged into iCloud and searched around. I now believe however that I never did "create" a PHOTO directory in iCloud and maybe that is why they aren't there. However,  when I try to do that, I am unable to unless I have iOS 8 and/or Yosemite. Agree or disagree?? But getting back to the way I think about the iCloud, I always thought of it as an external storage back up drive which was independent of any device or computer/Mac. Now, it seems that's not the case AND even worse, files can get deleted without you knowing about it or approving the specific deletion first!!  Why is iCloud not compatible with former versions of iOS and OS X??? That does not make sense to me. What would you recommend if I want greater specific control over which files get stored in iCloud and which do not?????

  • How to use TestRunnerBase in pure AS3 / no MXML

    Hi,
    is there a way to use the testRunnerBase GUI for a pure AS3 project, without a mxml?
    Thank you

    Hi, the testRunnerBase is a Flex application, so you can't use it in a pure AS3 environment without including all of the Flex dependencies.

  • How to separate embedded ActionScript from MXML

    Hi all,
    I need to separate the embedded ActionScript codes located in
    between <mx:Application> tags (inside MXML). I need to
    do this, becuse it will help me to simplify my job.
    The embedded ActionScript code looks like this:
    <mx:Script>
    <![CDATA[
    private var services:RemoteObject;
    public function initApplication():void
    services = new RemoteObject("GenericDestination");
    services.source="com.mydomain.Services";
    services.authorizeAccessTicket.addEventListener(ResultEvent.RESULT,
    loginResultHandler);
    ]]>
    </mx:Script>
    Once I taked the whole codes, and placed inside a class
    called Main.as and refere this class inside <mx:Application>
    as following:
    <mx:Script source="Main.as" />
    I got the following error: 1037: Packages cannot be nested.
    Main class looks like this:
    package
    import mx.rpc.remoting.RemoteObject;
    public class Main
    private var currentUser:User;
    private var currentAccessTicket:AccessTicket;
    private var services:RemoteObject;
    public function Test()
    services = new RemoteObject("GenericDestination");
    services.source="com.mydomain.Services";
    services.addEventListener(FaultEvent.FAULT, faultHandler);
    services.authorizeAccessTicket.addEventListener(ResultEvent.RESULT,
    loginResultHandler);
    What I have to do in this case?

    You made your included file a class. Instead, you want to put
    into your included AS files EXACTLY what appears in the
    <mx:Script> block (without the CDATA). From your example, the
    external AS file would start with private var services:RemoteObject
    and not with package and class information.

  • Create remoteObject with ActionScript, not MXML

    I want to use remoteObject with ActionScript only, no MXML:
    private function initializeRemoteObject():void {
                _remote = new RemoteObject();
                _remote.source = "AMFProxyObject";
                _remote.endpoint = "http://localhost/linktoMyAMFServer";
                _remote.destination = "zend";
                _remote.showBusyCursor = true;
    public function getIAllData():void {
                initializeRemoteObject();
                var token:AsyncToken = _remote.getAllDataFromStoryTable();
                //token.result = getDataHandler;
    I am stuck here because I don't know the proper syntax to handle the result
    private function getDataHandler ()void
    ///////////////    I just want to convert the MXML code below to ActionScript   \\\\\\\\\\\\\\\\\\\\\\
    <mx:RemoteObject id="zendRemoteObject" destination="zend" source="AMFProxyObject"
            endpoint="http://localhost/linktoMyAMFServer"         
            result="resultHandler(event)">
            <mx:method name="getAllDataFromStoryTable" result="getDataHandler(event)"/>
            </mx:RemoteObject>
    Thanks very much. This is driving me nuts, particularly since I couldn't find any help online by googling.

    Try using a Responder, specifically an AsyncResponder.
       var token:AsyncToken = _remote.getAllDataFromStoryTable();
       var responder:AsyncResponder = new AsyncResponder( resultHandler, faultHandler );
       token.addResponder( responder );
       public function resultHandler( event:ResultEvent, token:Object=null ):void
          Alert.show( "RESULT: "+ event.result as String );
       public function faultHandler( event:FaultEvent, token:Object=null ):void
          Alert.show( "FAULT: " + event.fault.message );
    The following documentation may be helpful:
    http://www.flexafterdark.com/docs/ActionScript-Responder
    I hope that helps...
    Ben Edwards

  • Add states with ActionScript, because MXML states occupying space

    I have my States setup with MXML fine, but I noticed that even though the State is not currently set, it is occupying space and leaving a huge empty gap in my layout.
    I want the State to not occupy the space when it is not the active State.
    I think using ActionScript to dynamically add the State when it is needed will solve the problem. What is the ActionScript code to add States (to replace all the State MXML code below)?
    <mx:Labe text="No State should be visible and don't occupy any space" />
    <mx:states>
    <mx:State name="{displayThisState}">
    <mx:AddChild>
    </mx:AddChild>
    </mx:State>
    </mx:states>
    Thanks.

    I'll recommend you to use a ViewStack instead of States, States in Fx 3 are kinda diffucult to declare and manage as your app grows. Fortunately in the Flex SDK 4 there will be a much simpler syntax to declare states.

  • Embed OTF Font as CFF in Pure Actionscript Project using Flex SDK 4.0

    I want to apply the method explained here: http://www.insideria.com/2009/03/flash-text-engine.html using only the Flex SDK 4 (not using FlashBuilder)
    Specifically:
    Embedding fonts can be tricky. In Flex, embed the font and store it
    using DefineFont4 and font subsetting currently only supported by Gumbo.
    A future version of Flash will support it but in the meantime, a Gumbo
    SWC with the embedded font must be created then adding to your Flash CS4
    project.
    The following is the method I am using to embed the fonts.
    public class Main extends Sprite {
         [Embed(source="../assets/GE Thameen DemiBold.otf",
                                  fontFamily = "GE Thameen",
                                  fontWeight = "bold",
                                  mimeType = "application/x-font",
                                  embedAsCFF = "true"
         private const GEThameen:Class;
    The following command line was assimilated after solving the output error messages using google and a little looking into how FlashDevelop works..
    mxmlc Main.as -load-config config.xml -managers flash.fonts.AFEFontManager
    The output SWF is not working as supposed, and the file size (20KB) does not seem to account for the embedded font. PS: When the font embedding is bypassed, and a device font is used for the text engine classes, the file works perfectly.
    The contents of config.xml are as the following:
    <?xml version="1.0" encoding="utf-8"?>
    <!--This Adobe Flex compiler configuration file was generated by a tool.-->
    <!--Any modifications you make may be lost.-->
    <flex-config>
      <target-player>10.0.0</target-player>
      <compiler>
        <source-path append="true">
          <path-element>E:\actionscript</path-element>
        </source-path>
        <external-library-path>
            <path-element>C:\bin\flex_sdk_4\frameworks\libs\player\10.0\playerglobal.swc</path-element>
            <path-element>C:\bin\flex_sdk_4\frameworks\libs\flex.swc</path-element>
        </external-library-path>
      </compiler>
      <file-specs>
      </file-specs>
      <default-background-color>#FFFFFF</default-background-color>
      <default-frame-rate>30</default-frame-rate>
      <default-size>
        <width>800</width>
        <height>600</height>
      </default-size>
    </flex-config>

    After losing about 2-3 days to trying to figure this stuff out, I rolled back to build 4.5.0.19786 and the problem doesn't occur anymore.  I'll revisit this issue once we ship the product next week.
    Thanks Alex.
    Cheers,
    Nate Beck

  • Seperating Actionscript and MXML

    I have a MXML file called PopUp.mxml which contains tabs. I
    need to pop this up after a menu is being pressed. I try to keep my
    as3 separate from MXML code..and I tried this.
    var popUp = new PopUp(); // the object of an MXML file
    var settingsWindow:TitleWindow =
    TitleWindow(PopUpManager.createPopUp(this, popTab, flase));
    I get the error.. 1034 when the settingsWindow is created..
    can someone help me in this. or can someone tell me how to
    create a pop up tabnavigator ?. I want the tabnavigator in a
    seperate MXML and the pop up action in a AS3..
    thanks in advance
    domnic

    found a solution for you
    in your eclipse instlation
    go to \plugins\com.adobe.flexbuilder.editors.common_xxxxx\
    directory
    P.S xxxx means some numbers it might be different on your
    machin .
    unzip common.jar file
    then go into
    common\com\adobe\flexbuilder\editors\common\color directory
    edit Colors.xml to your prefferences (it has hex values for
    colors , its pretty self descriptive) and after you finish editing
    put that back into the jar or re-jar that whole directory .

  • Assigning property value using ActionScript in MXML

    I have a component extending VBox, say MyContainer. I have an array property, say myArray.
    I am trying to set myArray using a function.
    If I do something like :
    <MyContainer >
        <myArray>
            <mx:Array>
                <obj/>
            </mx:Array>
        </myArray>
    <MyContainer>
    then it works fine. The setter for 'myArray' is called.
    But, if I do something like this:
    <MyContainer myArray="{buildArray()"}>
        <mx:Script>
            <![CDATA[
                public function buildArray():Array {
                    return [obj];
            ]]>
        </mx:Script>
    <MyContainer>
    In this case, the setter for 'myArray' never gets called.
    I want to check the value of 'myArray' before the container is added is initialized.
    Any suggestions?

    It would be easier to validate the data in "myArray" before passing it to the component. Then you can decide whether to create the component or not. Let the parent make this decision, not the child. The custom component cannot do anything until it is initialized, and you've indicated that is too late.

  • How to get response header using ActionScript and MXML?

    So... I have a URL like www.example.com/stream/
    I need to make any request to this url and get Http Rewspons header (like this one:
        HTTP/1.0 200 OK
        Content-type: video/x-flv
        Cache-Control: no-cache
    I do not need reponse body at all. After I get header need to emmidiatly close connection to that url (so stop to obtain data from it)
    How to do such thing (I use Flash builder)?

    Hai Mahesh
    Check the following Code
    Data : i_entamiot     LIKE   ehswas_entamiot.
    DATA: gv_batchattributes LIKE bapibatchatt.
    DATA: batchstatus    LIKE bapibatchstatus.
    DATA: lt_bapi_ret        LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
          CALL FUNCTION 'BAPI_BATCH_GET_DETAIL'
            EXPORTING
              material        = i_entamiot-matnr
              batch           = i_entamiot-charg
              plant           = i_entamiot-werkss
            IMPORTING
              batchattributes = gv_batchattributes
              batchstatus     = batchstatus
            TABLES
              return          = lt_bapi_ret.
    Thanks & regards
    Sreenivasulu P

Maybe you are looking for