Concept of Subroutine or Method in MXML?

Hi. Does Flex MXML have the concept of a subroutine (like VB) or a method (like ActionScript)?
Reason I ask is that I have some MXML code which will be duplicated (yecch!) unless I can refactor it into a subroutine of some sort.
Ben Ethridge
Senior Java Developer / Flex Newbie

I have this coded and it compiles ok but returns an error in AS at runtime:
TypeError: Error #1034: Type Coercion failed: cannot convert incl::IncludeEmulator@700a479 to mx.effects.Effect.
    at mx.effects::CompositeEffect/getChildrenTargets()[C:\autobuild\3.2.0\frameworks\projects\f ramework\src\mx\effects\CompositeEffect.as:400]
    at mx.effects::CompositeEffect/captureStartValues()[C:\autobuild\3.2.0\frameworks\projects\f ramework\src\mx\effects\CompositeEffect.as:294]
    at mx.core::UIComponent/commitCurrentState()[C:\autobuild\3.2.0\frameworks\projects\framewor k\src\mx\core\UIComponent.as:7163]
    at mx.core::UIComponent/setCurrentState()[C:\autobuild\3.2.0\frameworks\projects\framework\s rc\mx\core\UIComponent.as:7113]
    at mx.core::UIComponent/set currentState()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.a s:4361]
    at EastRidgeSoftware/__btnRestart_click()[C:\Users\Ben\workspace\EastRidgeSoftware\src\EastR idgeSoftware.mxml:267]
Here is the associated code in the parent:
            <mx:Transition fromState="Designing" toState="Initial">
                <mx:Sequence>
                    <!-- fadeout what is shown -->
                    <mx:Fade duration="{fadeDuration}" targets="{[designingImage,designingText,designingText1,designingText2]}" alphaFrom="1.0" alphaTo="0.0"/>
                    <mx:SetPropertyAction name="visible" targets="{[designingImage,designingText,designingText1,designingText2]}"/>
                    <inc:IncludeEmulator initialImage="{initialImage}" initialText="{initialText}" initialText1="{initialText1}" moveDuration="{moveDuration}"/>   
                </mx:Sequence>
            </mx:Transition>
...and the child:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
    <![CDATA[
        import mx.controls.Text;
        import mx.controls.Image;
        [Bindable]
        public var initialImage:Image;
        [Bindable]
        public var initialText:Text;
        [Bindable]
        public var initialText1:Text;
        public var moveDuration:Number;
    ]]>
</mx:Script>
                        <!-- Fadein what should now be shown. -->
                    <mx:Fade duration="1" targets="{[initialImage,initialText,initialText1]}" alphaFrom="0.0" alphaTo="1.0"/>
                    <mx:SetPropertyAction name="visible" targets="{[initialText,initialText1,initialImage]}"/>
                    <!-- Move it across the screen into reading position. -->
                    <mx:Move duration="{moveDuration}" targets="{[initialText,initialText1,initialImage]}"/>
</mx:Module>
So it appears that a generic "Module" is not allowed, i.e. it wants a true "Component" one flavor or another.  Looking at the error above, my top guess is that AS cares about the component type, i.e. since it's running within a Transition, the only components allowed are Effects? Unfortunately, mx.effects.Effect is not in the list, i.e. not in <mx:> namespace.  I tried Canvas just for laughs, but same error, so I'm stuck.  Is there a way to inherit from Effect in MXML maybe?
Ben

Similar Messages

  • Does ExtendScript have a concept of "main" function/method like when script is included as a library

    I was just wondering whether ExtendScript has any concept like a main method, whereby if the current script is included by another script like a library import it will not execute this main function/method and only execute it when the script is run directly.
    Similar to Java's main() method and Python's __main__.
    If not, is there a workaround to mimic such behavior generically?

    I cannot reproduce this.  Can you create a very simple repro of this issue and post to OneDrive?
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • OOPs Concept ! - Why Static Methods can't be redefined in its subclass ?

    Dear Experts ,
    I had searched the SDN , but unable to find out the satisfactorily answers ..
    Can anybody let me know the reason for the following Confusion in Oops Concept
    Question 1: As we know , We can Inherit the Static Methods in the Sub Class , But we can't redefine it in the base class  or       Sub Class  ?
    Question 2 : Why can't Static Method be Abstract ?
    Question 3 : Can a Class be Abstract or Final Both, If yes, then why ?
    Thanks in Advance
    Saurabh Goel

    As per the above discussion two of your doubts have already been clarified  so I am taking only third one.
    A class cannot never be Abstract and final both coz Abstract signifies that the implementation of the class has not been defined completelyi.e. may be some methods have been defined but few methods are still missing implementation. 'Final' is used for those classes/methods which cannot be redefined  means the complete implementation of the method has been defined no one can implement further logic under the same method.
    If you are saying your method is Final then it cannot be overridden and Abstract implies that method implementation is yet to be defined which can only be implemented if that class/method is not 'Final'. So both the terms are contradictory.
    Hope it clarifies!!!
    Thanks,
    Vishesh

  • Calling Java Methods in MXML Application

    Hai ,
    I am new to flex . I want to call a Java Method in my MXML
    Application . Can anyone give a Simple example for this One .
    Thanks
    Madhu

    Thanks. But When i run this Application it throws an Action
    Script Error Like this .
    [RPC Fault faultString="[MessagingError message='Destination
    'myObject' either does not exist or the destination has no channels
    defined (and the application does not define any default
    channels.)']" faultCode="InvokeFailed" faultDetail="Couldn't
    establish a connection to 'myObject'"]
    at mx.rpc::AbstractInvoker/
    http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\AbstractInvoker.as:257
    at mx.rpc.remoting.mxml::Operation/
    http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\remoting\mxml\Operation.as:197
    at
    mx.rpc.remoting::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\remotin g\Operation.as:113]
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at
    mx.rpc.remoting.mxml::Operation/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\re moting\mxml\Operation.as:170]
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at mx.rpc::AbstractService/
    http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[E:\dev\3.0.x\frameworks \projects\rpc\src\mx\rpc\AbstractService.as:285
    at s2/___s2_Button1_click()[C:\Workshop for eclipse\work
    space\Flex\DCSearch\flex_src\s2.mxml:6]
    Can u help me
    Madhu

  • Urgent - ABAP subroutines - Proxy method

    I am coding a proxy method.
    I had to code a BDC call transaction. For this I have defined 2 sub-routines. One BDC_DYNPRO (for screen chnage) and BDC_Insert(for inserting the fields).
    When compile the code, it is giving an error in the line just above the definition of the first sub-routine. <b>The error message is "ENDMETHOD missing".</b>
    But there is an "ENDMETHOD" after the definition of the second sub-routine.
    Are there any reservations for the sub-routines in OO-Context.
    Can anyone help me with this.
    reg

    I did not get your point.
    My code is:
      method ZSMDII_MI_FUSION_PRODUCT_MAINT~EXECUTE_ASYNCHRONOUS.
         code....
         code...
    <b>Error is being shown in this line</b>
          Code of subroutine1.
           code of subroutine2.
    endMethod.
    I can post my code here if this is not clear.
    reg

  • How to call methods from .mxml file from actionscript file

    I have a Example.as and a Test.mxml.
    In this Test.mxml, I have a function which is something like:
    public function doTest():void
         Alert.show("testing!");
    How do I from example.as call this function doTest() from Test.mxml?
    I tried declaring public var test:Test inside my Example.as but I'm still unable to call that function out.
    Any idea how?

    Hi Bryant,
    You need to create an instance of the component and then attach it to the display list then only you can access the Controls with in your component other wise the controls and components are not created or initialized that's why you are thrown the null object reference error.
    So you need to do somethink like below:
    var myTestObj:Test = new Test();
    this.addChild(myTestObj); //Adds the component to DisplayList(You need to add this line of code in order to avoid the error)
    myTestObj.doTest();
    If you add your component in mxml then the component will be automatically added to the display list and you dont need to add explicitly to the display list.
    <comp:Test id="myTestObj" />
    And now if in your actionscript you call myTestObj.doTest(); no error occurs and you can see the Alert message.
    Thanks,
    Bhasker

  • Use RemoteObject method defined in MXML from AS

    I need to use a RemoteObject from a custom component written
    as an ActionScript class. I can easily define the RemoteObject
    service and it's methods in MXML, but I don't know how to acces
    that definition from a class insite an ActionScript package. For
    example imagine
    this
    example on Adobe's site on component creation using a RemoteObject
    to do the calculations. I don't know how to define methods of a
    remote service in AcionScript, only in MXML. Thanks.

    It seems I don't have to defint the methods, just create a
    RemoteObject, set it's dource and destination, and call the methods
    on it. (services-config.xml is already set up.)
    Still, any comments are welcome. Or tutorials on the web.
    Like how to set per-method event handlers. Now I can only set it
    globally on the RemoteObject.

  • Valuation Methods - foreign currency valuation

    Hello
    I am trying to understand the concept of different valuation methods. could you explain using examples please ?
    Say for instance, a goods receipt is raised in USD for 100USD on 2 Jan 2009 and local currency is EUR. Exchange rate is 1EUR : 1,5USD. On 4 Jan 2009 invoice received at rate of 1EUR : 1,6USD.
    What are the implications of the options lowest value principle, strict lowest value principle, always valuate and revalue for such a transaction?
    tks

    Those are different ways of valuating your Foreign Currency Operations depending or the country regulations:
    1- Lowest value principle means that the Valuation will be posted only if it is giving a negative result.
    2- Strict lowest value principle will be post valuation only if two conditions happened:
            A - The valuation is negative
            B - The new valuation has a greater devaluation and/or a greater revaluation for credit entries than the previous valuation
    3 - Always Valuate: No matter if it is possitive or negative, the valuation will be posted.
    4 - Revalue only: The opposite of the first one, valuation is only posted when possitve.
    5 -Reset Valuation Run: In this case open items are valuated at the acquisition price. This way the valuation difference is set to zero. This is useful to reset previous valuations
    Regards,
    Fede

  • Interest splitting method and self withholding tax......

    hi all,
    please let me know the concept for interest splitting method with examples and also self withholding tax.
    thanks in advance

    please update me for this issue.........

  • Invoking methods extracted from a string?!?

    Hi everybody. I hope the subject is not confusing. What I'm really looking for is some Perl-like behaviour in Java. In Perl its possible to execute subroutines (basicly methods) extracted from a string ("&sub()"). Is there anything similar in Java?
    What I would like to do is to process a string and if it has a method (object.getTime()), the method will be called and the return value stored in its place.
    Please let me know if more explanation is needed.
    Thanks in advance for all the help!
    Leo.

    I use a language called MUMPS where you can do that as well - execute strings as commands etc. I don't know much about Reflection but it looks like you can get method (Objects) from strings and execute them as well ...

  • Object finalize method

    As far as my concept goes, the finalize() method for an object can be called only once. If it is called explicitly, the garbage collector will not call it again. But one of my programs is calling finalize() method apprantly more than once. Please see the code below.
    class ObjFinalizeTest{
         public void finalize() {
              System.out.println("Class Terminated");
         static void foo() {
              ObjFinalizeTest aa = new ObjFinalizeTest();
    public class Chap1 {
         static char a ;
         static int b ;
         static ObjFinalizeTest c;
         public static void main(String[] args) {
              c= new ObjFinalizeTest();
              c.finalize(); //explicit call to finalize
              System.out.println(c);
              c=null;
              System.gc();
    }this is the output I am getting
    Class Terminated
    ObjFinalizeTest@923e30
    Class TerminatedCan anybody please explain this phenomenon

    Finalize is just like any other method, it's nothing special, same with main. What you are doing is explicitly calling it and then the JVM is calling it as well. I think the docs only state that the JVM will only call the method once, you however can call it as many times as you like.

  • Static synchronized method

    hi,
    I am unable to understand the concept of static synchronized method.
    A non-static synchronized method gets lock on this object before entering into the method. But how this is valid for static method.
    thanks in advance

    hi,
    I am unable to understand the concept of static
    atic synchronized method.
    A non-static synchronized method gets lock on
    this object before entering into the method.
    But how this is valid for static method.
    thanks in advanceIt locks the YourClassName.class object.

  • Define of subroutine in class

    HI All,
    Please suggest me how can I define a subroutine in class.
    as I have declared subroutine in method.
    Thanks,
    Sandeep.

    Thank Max,
    can u please suggest me how can I create method to the class.
    As I have created one implementation of MB_DOCUMENT_BADI and in that I have already predefined methods.
    Plase suggest as its urgent.
    Thanks .
    sandeep.

  • Refreshing the Output Table in ALV

    Hi All,
    Please let me know how to refresh the output table using refresh button in ALV.
    Thanks & Regards,
    Priya.
    Edited by: SathyaPriya Neelagaru on Jun 26, 2008 7:00 AM

    Hi,
    We can refresh the output table for ALV by below code :
    CLEAR  : g_wa_outtab.
    REFRESH: g_t_outtab.
    When we append something to output table of ALV we need to clear the workarea for that table.
    APPEND g_wa_outtab TO g_t_outtab.
    CLEAR g_wa_outtab.
    If you are using object oreinted concept we have
    CALL METHOD g_alv_grid_9001->refresh_table_display.
    In case you have to use your own PF Status - Always copy the standard GUI status
    (Program : SAPLSLVC_FULLSCREEN,
    Status : STANDARD_FULLSCREEN )
    For REFRESH - Include parameter for "USER_COMMAND" in the Function module interface.
    Inside the User command subroutine - set
    "RS_SELFIELD-REFRESH" = "X".
    It will automatically refresh the ALV and there is no requirement to call ALV again.
    Or else if u have a Refresh button on screen.
    we can have
    WHEN 'REFRESH'.
          CLEAR : g_wa_outtab.         
          REFRESH : g_t_outtab.
    Hope this helps you.
    Plz reward if useful.
    Thanks,
    Dhanashri
    Edited by: Dhanashri Pawar on Jun 26, 2008 7:08 AM
    Edited by: Dhanashri Pawar on Jun 26, 2008 7:14 AM
    Edited by: Dhanashri Pawar on Jun 26, 2008 7:15 AM

  • On ALV report in1 column I want to put Icon on every row of that column.

    On ALV report there is 1 column I want to put Icon on every row of that column.That ALV program uses object oriented concept all class and methods.
      I want to use that icon on that row. That icon name is ‘ICON_OKAY’
    In my program when I assign values to internal table at that time I am assigning that ‘ICON_OKAY’ value to that row as follow.
    Itab-
    Itab-icon = ICON_OKAY.
    Append itab.

    please follow below procedure to display icon in ALV
    1) In corresponding fieldcatelog entry do
    fieldcatalog-icon = 'X'
    2) While filling the internal table fill the corresponding key value of icon , for example ICON_OKAY value is '@0V@' so statement would be
    Itab-icon = '@0V@'
    to get list of corresponding key for icon open include <ICON> in se38

Maybe you are looking for