Oral exam - Flash CS4 - Local/global variables?

Hi!
In two days, i have an Oral exam in flash programming, with CS4.
we've been given a problem to solve, and i naturally am having problems solving it!
This is the problem
You are suppost to make a calculator. The calculator should be able to show how much time a person uses
when he/she climbs a mountain when hiking. Time is counted in minutes, and the height is the mountain-height.
a) I should be able to calculate, and show how many heightmeters one walks per minute.
example:
Height: 1440 meters
time: 360 minutes
1440/360 = 4 Heightmeters per minute.
4 * 60 = 240 heightmeters per hour
So, i pretty much figured this out.
iHeight, iTime and iHeightmeters, and iHeightmeters2(for the hour one).
My problem shows itsself when i get to b.
b) animation: Show a person that walks from the bottom, to the top of the mountain, in this application(basically the stage, with the calculator on the right side or something along those lines)
I animated, and i was able to give my "guy" some speed in x and y direction, so that he walks up to the top of the mountain.
c) Let the speed from a, decide the speed the person walking up the mountain has.
So what i'm suppost to do is:
mcWalkingman.x += iHeightmeters;
mcWalkingman.y += iHeightmeters;
Theese values have to recide in a function for themselfs, a function only containing speed variables and such. While the "iHeightmeters" recide in the first function where the calculator is. How do i get whatever value iHeightmeters turns out to be, into the next function or another function at all, when the variables are local?
I hope you understand my problem, and that someone is able to help me.

If i got you right you want to share a variable between differnet functions ?
You need to specify it globally and not within the function. If you are programming it just in the Flash IDE, it would be something like
var iHeightmeters:int = 123456;
testFunction();
function testFunction():void
    trace("iHeightmeters = " + iHeightmeters);
If you do this within a class, it should be
private var iHeightmeters:int = 123456;
testFunction();
private function testFunction():void
     trace("iHeightmeters = " + iHeightmeters);

Similar Messages

  • Can the output of a Generate Occurrence be passed in Local/Global Variable?

    Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly?
    Can more than one party be waiting on the same Occurrence and will all waiting function be released together?

    dbaechtel wrote:
    Answer was not given:
    Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?
    I am not worried about whether it is bad form or not, as yet. That is for me to decide on a case by case basis.
    Yikes! That is not a very good way to learn.
    Anyways, to avoid any more bold emphasis on words, I will answer your question. Locals can only be linked to controls/indicators not individual wires. If you want to get the effect of a local/global variable with a wire value, search the forum for action engines or functional globals. Those will work for passing a wire value between threads.
    That said, what are you trying to use occurences for? There may be (and probably is) a more accepted way to implement what you are trying to do instead of using local variables
    CLA, LabVIEW Versions 2010-2013

  • Labview 8.0 PDA local & global variable cause a crash

    I've attached a pic of the portion of the VI that causes the PDA
    application to crash. What is happening is that I write the initial
    resistance0 to a (global or local) of a chip by using a case
    structure  that sets the value when the while loop first executes,
    afterwards, every other iteration, it sets the resitance to a (local or
    global variable) called resistance then it plots it.. unfortunately,
    accessing the variable
    this way causes it to crash .. Any help would be greatly appreciated.
    Message Edited by GHernandez on 02-09-2006 06:25 PM
    Attachments:
    Problems.jpg ‏162 KB

    I've re-written this application , where i have not included global
    variables for resistance, or resistance0 or the counter. The VI
    executes for maybe a  min or 2 then crashes giving me the
    following error:
    App failed. Error code 560331006. Bad input argument to function.
    unfortunately, this error code does not tell me anything.
    Message Edited by GHernandez on 02-10-2006 04:51 PM
    Message Edited by GHernandez on 02-10-2006 04:52 PM
    Attachments:
    problema.jpg ‏158 KB

  • Flash builder 4, Global Variables... help :)

    hey guys, im new to this form and to flex, so if this post is in the wrong place i appologise.
    I have searched the internet for this issue but i have not found a good solution. The only solution i found ended up in errors that i could not get around.
    Basically waht im trying to do is, build a class containing variables which can be accessed throughout my project ( as in components ).
    the basic structure im workign with is:
    1. starts out with a login page in states
    2. onsuccessful login, i get to the main page.
    3. i use webservice to get all the information from the server to populate in the datagrid fields.
    basically i want this information available throughout my project.
    if anyone can help me with this, i would greately appretiate it!!
    the code i found on the internet goes something like this.
    in a file called global.as i have the following code in the mainScript folder (mainScript/global.as)
    package mainScript{
        public class globalVars{
            public static const var siteUrl:String = "google.com";
    and in my main application i have
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"
            xmlns:PageEditor="modules.PageEditor.*"
            xmlns:PanelEditor="modules.PanelEditor.*"
            xmlns:SiteEditor="modules.SiteEditor.*"
            xmlns="*"
            initialize="init()">
            <fx:Script>
                <![CDATA[
                    import mainScript.globalVars;
                    import mx.controls.Alert;
                    public function init():void{
                        Alert.show("here");
                        Alert.show(mainScript.globalVars.siteUrl);
                ]]>
            </fx:Script>
                    <mx:Panel id="mainForm" width="220" height="100%" backgroundAlpha=".20">
                    <mx:VDividedBox width="200" height="100%" backgroundAlpha=".20">
                        <mx:DataGrid id="siteSelected"    width="100%"
                                                        height="100%"
                                                        backgroundAlpha=".8"
                                                        borderStyle="none"
                                                        backgroundColor="#333333"
                                                        rollOverColor="haloOrange"
                                                         dataProvider="{}" >
                            <mx:columns>
                                <mx:DataGridColumn dataField="name" headerText="Sites" />
                            </mx:columns>
                        </mx:DataGrid>
                        <mx:DataGrid id="pram" width="100%" height="100%"
                                                        visible="false" backgroundAlpha=".40">
                            <mx:columns>
                                <mx:DataGridColumn dataField="name" headerText="Modules" />
                            </mx:columns>
                        </mx:DataGrid>
                    </mx:VDividedBox>
                </mx:Panel>
                <mx:Panel id="dataPanel" width="840" height="100%" backgroundAlpha=".20" visible="false">
                    <mx:ViewStack width="100%" height="100%" id="myViewStack"  >
                        <PageEditor:PageEditor id="PageEditor" />
                        <PanelEditor:PanelEditor id="PanelEditor" />
                        <SiteEditor:SiteEditor id="SiteEditor" />
                    </mx:ViewStack>
                </mx:Panel>
    </s:Application>
    unfortunately i get 1 error in this code. the error states: "1202: Access of undefined property globalVars in package mainscript."
    if someone could help me solve this error, or help me with a different solution i would really appretiate it. I am completely stuck here...
    thanks a lot in advance

    hey mjonkman, what im trying to acomplish here is that i want a function inside of that package getAllSites() to initialize as soon as the application is loaded (getAllSites() is basically a webservice call im doing using the interospection wizard) once the getAllSites goes thru i need the variable sourceData to be globally accessable, this variable is later going to be binded in a datagrid.
    this is all the code i have for right now...
    in the mainList.as i have:
    // ActionScript file
    package mainScript{
        import mx.collections.ArrayCollection;
        import mx.controls.Alert;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import services.main.*;
        [Bindable] public class mainList{
            // variables
            public static var sourceData:ArrayCollection;
            // Web services
            public static var mainInfo:Main = new Main();
            public static function getAllSites():void{
                mainInfo.addEventListener(ResultEvent.RESULT, listener);
                mainInfo.addEventListener(FaultEvent.FAULT, fault);
                mainInfo.GetSiteList();
            public static function listener(event:ResultEvent):void{
                sourceData = new ArrayCollection(event.result as Array);
                //sourceData = event.result as ArrayCollection;
                Alert.show("done");
            public static function fault(event:FaultEvent):void{
                Alert.show(event.fault.faultDetail);
    and in the mainWindow.mxml i have
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"
            xmlns:PageEditor="modules.PageEditor.*"
            xmlns:PanelEditor="modules.PanelEditor.*"
            xmlns:SiteEditor="modules.SiteEditor.*"
             initialize="mainScript.mainList.getAllSites()">
            <fx:Script>
                <![CDATA[
                    import mx.collections.ArrayCollection;
                    import mainScript.mainList;
                    import mainScript.global;
                    import mx.controls.Alert;
                    [Bindable] public var mainListData:ArrayCollection = mainScript.mainList.sourceData;
                ]]>
            </fx:Script>
                    <mx:Panel id="mainForm" width="220" height="100%" backgroundAlpha=".20">
                    <mx:VDividedBox width="200" height="100%" backgroundAlpha=".20">
                        <mx:DataGrid id="siteSelected"    width="100%"
                                                        height="100%"
                                                        backgroundAlpha=".8"
                                                        borderStyle="none"
                                                        backgroundColor="#333333"
                                                        rollOverColor="haloOrange"
                                                        dataProvider="{mainListData}" >
                            <mx:columns>
                                <mx:DataGridColumn dataField="name" headerText="Sites" />
                            </mx:columns>
                        </mx:DataGrid>
                        <mx:DataGrid id="pram" width="100%" height="100%"
                                                        visible="false" backgroundAlpha=".40">
                            <mx:columns>
                                <mx:DataGridColumn dataField="name" headerText="Modules" />
                            </mx:columns>
                        </mx:DataGrid>
                    </mx:VDividedBox>
                </mx:Panel>
                <mx:Panel id="dataPanel" width="840" height="100%" backgroundAlpha=".20" visible="false">
                    <mx:ViewStack width="100%" height="100%" id="myViewStack"  >
                        <PageEditor:PageEditor id="PageEditor" />
                        <PanelEditor:PanelEditor id="PanelEditor" />
                        <SiteEditor:SiteEditor id="SiteEditor" />
                    </mx:ViewStack>
                </mx:Panel>
    </s:Application>
    as you can see in the mainList.as i made a few changes, like i made all the functions static so i can access them in my mainWindow.mxml
    i also made my class bindable so i can stick it in the datagrid.
    the problem im having is that... it calles the getAllSites() just fine but unfortunately the datagrid is not populating.
    I was wondeing if anyone can tell me why.....
    and again thanks for the fast reply guys!!

  • Global Variables in Flash CS4 (AS3) ?

    Hi,
    I  have another problem with my new project and I am looking to get answers for these two question:
    1.) Is there a way to define a global variable which can be accessed inside and movie clip or button? (where do you define it? is it changeable? can you pass it in by reference?)
    2.) If i have my main stage with some actionscript and a movie clip which has also some action script, IN WHICH ORDER does it execute?
    Thank you in advance for any help and tips!

    Thank you this is what i needed I got it to work now!
    But I do still have one last question on this topic.
    This is the Code:
    //this is in a file Actionscript File called glo.as
    package{
         public class glo{
              public static var widthOfSlider:Number = 5;
    // This code is in scene 1 > my_mc
    import glo;
    trace(glo.widthOfSlider);
    //This code is in scene 1 > my_mc > myNext_mc
    import glo;
    var numOfCovers = 6;
    var temp = glo.widthOfSlider;
    trace(glo.widthOfSlider);
    this.addEventListener(Event.ENTER_FRAME, centerB);
    function centerB(event:Event):void{
         for(var i = 0; i < numOfCovers ; i++ ){
              this["cover_btn_"+String(i)].y = 0;
              this["cover_btn_"+String(i)].x = temp;
              temp += this["cover_btn_"+String(i)].width + 5;
         glo.widthOfSlider = temp;
         trace(glo.widthOfSlider);
         this.removeEventListener(Event.ENTER_FRAME, centerB);
    When I run this I get the following output:
    5
    5
    5
    725.45
    725.45
    The first "5" is from the trace(glo.widthOfSlider); in scene 1 > my_mc
    The next two "5"'s are from the trace(glo.widthOfSlider); in scene 1 > my_mc > myNext_mc
    Is there a way so that I can first execute the code in scene 1 > my_mc > myNext_mc before the code in scene 1 > my_mc ?
    I am trying to get 725.45 through the trace(glo.widthOfSlider); in scene 1 > my_mc

  • Calling a variable from inside a movieclip AS3 in Flash CS4

    I am trying to trace a variable string from inside a movieclip which is inside another movieclip on the main timeline using:
    trace(VariableString);
    and also
    trace(stage.VariableString);
    Neither work
    The variable is an input textfield and traces fine when it is on the main timeline but will not work from inside the movieclip. I am using Actionscript 3 in Flash CS4.
    I appreciate this has probably been discussed previously on this forum but I cannot find a difinitve answer that seems to work.
    Thanks

    Thanks for the reply. However this did not seem to work.
    I think I had better explain a little better.
    On Keyfrme1 I have a MovieClip1 containing a text input component. I have created a variable on keyframe 1 using:
    var VariableString1:String = new String();
    When clicking on a seperate button this happens:
    VariableString1 = MovieClip1.text;
    I can trace this correctly on the main timeline using:
    trace(VariableString1);
    However, if I try to trace this from  another keyframe inside a movieclip2 which is inside another movieclip3 using:
    trace(MovieClip1(root).VariableString1);
    I just get the error 1180 call to a possibly undefined method MovieClip1
    Sorry if this is not very clear but I am getting very confused with this.
    Thanks again

  • Can't change string variable values in Flash CS4 Debugger

    I'm using the Flash CS4 debugger, and while I can change numeric variable values in the Variables panel, I can't change string variable values. The only characters the fields accept are the numbers 1-9 and the characters "d" and "j".
    I can  paste strings  into the value fields, but that's a bit of a pain. I've tried this on a couple of different Flash CS4 installations and get the same results.
    Does anyone know if it's possible to change string values in the Variables panel of the Flash CS4 Debugger?

    See:
    http://forum.java.sun.com/thread.jspa?threadID=591012&tstart=15

  • How to assign local variable to global variable dynamically in adobe livecycle designer 7.1

    Hi All,
    i want to assign my textfield value to global variable dynamically.so that where ever i want , i will access my global variable.so it is possible in adobe livecycle designer 7.1. kindly suggest me method.Thanks in advance.
    Thanks & Regards
    Ganesh

    Please remove all adobe livecycle designer versions from your local pc.
    restart your pc to be sure, that all temp data is deleted.
    download the newest ald version from service.sap.com and install it.
    have fun with developing adobe forms with sap transaction sfp.

  • Functional Global Variable in the CLAD sample Exam

    Hello,
    A question in the CLAD sample exam #2 keeps puzzling me. It's question number 32 about FGVs:
    32. Which is not an important part of creating a Functional Global Variable?
    a. Using Shift Registers to store information
    b. Changing the VI’s execution settings to Reentrant
    c. Setting the VI to inline into calling VIs
    d. Setting the While Loop to stop after one iteration
    The answer given is the following
    32.Correct Answer: B
    Topic: Functional Global Variables
    Justification: It is not necessary to inline functional global variables into their calling VIs. In fact, inlining requires that the subVI be reentrant, which is forbidden for functional global variables.
    Clearly, for an FGV to work properly, the VI must NOT be reentrant. So I would have selected answer B, but the justification seems to clearly point to answer C as well, doesn't it? Is it a typo, a subtlety in the wording? I am stuck on this one!
    Solved!
    Go to Solution.

    Well, inlining requires reentrant.  Therefore, the best answer should technically be C.  This looks like one of those rejected/retired questions since it isn't quite right and/or left up to too much interpretation.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Local and global variables in ABAP Debugger

    hi guys.
    we have the following support package:
    SAP_BASIS     640     0025     SAPKB64025     SAP Basiskomponente
    I would like to use in the debugger the local and global variables tab strip, but I can not find it. Is it possible. that our support package is too low for this functionality?
    Thanks a lot.
    rudit
    Edited by: Rudolf Tremmel on Aug 17, 2010 8:35 AM

    Starting with SAP NetWeaver 6.40, SAP released a new version of the Debugger.
    The Debugger available in Release 6.40 was not considered complete (and was
    not the default debugger as a result)
    The Variable Fast Display tool currently has four tabs . The first
    two are provided empty, and you can either type or double click a name in the
    source code to add it to the list. The third tab (Locals) shows all local variables
    for the current program modularization unit, and the fourth (Globals) shows all
    global variables in the current program.

  • Create local or global variables ?!

    hey guys,
    I want to use variables instead of wires , which one you suggest , local or global variables? and why ? 
    thnxxx alot

    blue silver wrote:
    I want to use variables instead of wires , which one you suggest , local or global variables? and why ? 
    In LabVIEW, the wire is the variable.
    Local and global variables have their limited use in certain UI tasks, but lead to inefficient, error prone, and hard to maintain code.
    Local variables create extra data copies in memory, which can be expensive
    They break dataflow and thus lead to race conditions.
    To "fix" the race conditions, you need to clutter your code with sequences.
    ... it's an evil cycle!.
    Why do you think you need local and global variables?
    If you "want" to use them, you are probably misguided. Typically, you should only use them if you "need" to! There are legitimate uses for them.
    LabVIEW Champion . Do more with less code and in less time .

  • Local Variables Versus Global Variables

    DATA A TYPE I VALUE 100.
    PERFORM PRINT_DATA.
    FORM PRINT_DATA.
               DATA A(10) TYPE C 'HELLO'.
               WRITE / A. "Wanted to Print 100 (Global)
               WRITE / A.  "Wanted to Print 'HELLO'(Local)
    ENDFORM.
    Note : Both the times, the Local Variable 'A' is Printed .
    ?Is there any way to   Differentiate the Local and Global Variables When the Names Are Same.*
    *It Might be Possible in Object Oriented But I am Looking for the Same in FORMs.

    Hello Gagan,
    You want to print the Global as well as the local values of the variable named "A". Here are a couple of approaches:
    1.The 'Subroutines' are part of the modularization techniques. There are certain keywords like "using" & "Changing" so that you can work by passing Values.
    2. There is a keyword named "LOCAL". Declare data object with the keyword "LOCAL" and then try the 'write" statement. I suppose this should work for you.
    Let me know if any one of the above works or if you need more help.
    Best Regards,
    Chaitanya

  • How do I pass local final variable value to global variable.

    Hi,
    In my code, I need to pass the local final string varibale value to the global variable for further usage. I know final is constant and inside the braces it can't be modified or assigned to other. Help needed in this regard or how do I re-modify the code according to my requirement i.e assigning the final string variable value to the outside of that block.I need the value of final String variable to be available in the process method outside of the specified block.
    class HostConnection{
    public module process(){
         HostKeyVerification hkv = new HostKeyVerification() {
              public boolean verifyHost(String hostname,SshPublicKey key) {
    final String keyfingerprint = key.getFingerprint();               return true;
    Thanks
    Sri                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    SriRaj wrote:
    It seems to be by-default all varibales in the inner calss method are Final.This is not true. Try this:
    class SomeClass {
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
    }But you obviously can't do this:
    class SomeClass {
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
        System.out.println(i); //compiler error: "i" is undefined
    }Because you are declaring i in an inner class. If you want to access the value of i outside that inner class, you'd have to do this:
    class SomeClass {
      private int i;
      public void method() {
        Runnable runnable = new Runnable() {
           public void run() {
              int i = 0;  // new inner-class variable
              i = i + 1;
              System.out.println(i);  //prints "1"
              SomeClass.this.i = i;
        System.out.println(i); //no compiler error
    }If this doesn't answer your question, please try to post an actual question, along with your real code, and any compiler errors you are getting, word for word.

  • Error while loading a swf created in flash cs4, inside a flex application

    Hi there,
    I have created a rotating logo in flash cs4 using motion presets, named logoRotar.swf. I have used this inside my flex application:
    <mx:SWFLoader width="33.33%" height="100%" source="assets/logoRotar.swf">
    When I execute the flex application, I get this runtime error message:
    VerifyError: Error #1014: Class flash.geom::Matrix3D could not be found.
        at global$init()
        at fl.motion::AnimatorFactory3D/getNewAnimator()
        at fl.motion::AnimatorFactoryBase/addTargetInfo()
        at logoRotar_fla::MainTimeline()
    I also tried adding import flash.geom.*; statement in my flex application, I still get the same message.
    Flash player 10,0,22,87 is running in my browser.
    Please help me out....
    Cheers!
    Deepak

    Get Flex 3.3 and use -target-player=10
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Global variable in XSLT

    Hi,
    I have a requirement in XSLT mapping where i sum up all the data related to amount field and then want to display total that i have added in the another node
    eg.
    <Detail>
    <xsl:variable name="<b>etotal</b>" select="sum(ns0:pay/ns0:checkList/ns0:check/ns0:deductionList/ns0:adjustment/ns0:amount/ns0:amount)"/>
    </Detail>
    <Trailer>
    <TotalDeductionAmount><xsl:value-of select="<b>$etotal</b>"/>
    </TotalDeductionAmount>
    </Trailer>
    how to do ?
    since the above example the scope of the variable is local and cannot be accessed globally. how to declare a global variable and then assign value to the variable
    or is there any other method to do this in XSLT
    Thanks in advance
    With Regards
    Pradeep N

    Hi,
    Please see below sample code is solving your problem. Global variable can not solve the problem, you need to use templates and call then appropriately.
    -Kavita
    Sample Input
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <Test>23</Test>
    <Test>34</Test>
    <Test>90</Test>
    </root>
    Sample Output
    <?xml version="1.0" encoding="UTF-8"?>
    <Mt_test>
         <Header>"create the header data according to req"</Header>
         <Details>
              <DetailsCol>23</DetailsCol>
         </Details>
         <Details>
              <DetailsCol>34</DetailsCol>
         </Details>
         <Details>
              <DetailsCol>90</DetailsCol>
         </Details>
         <Trailer>
              <TotalSum>147</TotalSum>
         </Trailer>
    </Mt_test>
    XLST:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/">
    <xsl:element name="Mt_test">
    <xsl:element name="Header">"create the header data according to req"</xsl:element>
              <xsl:variable name="checkNext" select="//Test[1]"/>
    <xsl:call-template name="GenerateTest">
    <xsl:with-param name="currNode" select="//Test[1]"></xsl:with-param>
    <xsl:with-param name="Sum" select="0"></xsl:with-param>
    </xsl:call-template>
    </xsl:element>
    </xsl:template>
    <xsl:template name="GenerateTest">
    <xsl:param name="currNode"></xsl:param>
    <xsl:param name="Sum"></xsl:param>
    <xsl:element name="Details">
    <xsl:element name="DetailsCol"><xsl:value-of select="$currNode"></xsl:value-of></xsl:element>
    </xsl:element>
    <xsl:variable name="Sum1" select="$Sum + $currNode"></xsl:variable>
    <xsl:variable name="checkNext" select="$currNode/following-sibling::*[1]"/>
    <xsl:choose>
         <xsl:when test="$checkNext">
    <xsl:call-template name="GenerateTest">
    <xsl:with-param name="currNode" select="$checkNext"></xsl:with-param>
    <xsl:with-param name="Sum" select="$Sum1"></xsl:with-param>
    </xsl:call-template>     
         </xsl:when>
         <xsl:otherwise>
         <xsl:call-template name="GenerateTrailer">
    <xsl:with-param name="currNode" select="chkeckNext"></xsl:with-param>
    <xsl:with-param name="Sum" select="$Sum1 "></xsl:with-param>
    </xsl:call-template>
         </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    <xsl:template name="GenerateTrailer">
    <xsl:param name="currNode"></xsl:param>
    <xsl:param name="Sum"></xsl:param>
    <xsl:element name="Trailer">
    <xsl:element name="TotalSum"><xsl:value-of select="$Sum"></xsl:value-of></xsl:element>
    </xsl:element>
    </xsl:template>
    </xsl:stylesheet>

Maybe you are looking for