4 Replies Latest reply on Feb 17, 2011 6:37 AM by HorseSense.knome

    Game in Flex, help working around Deprecated Code

    HorseSense.knome

      I've been leanring Flex by trying to create a simple Mobile game engine in Flex Burrito w/ Hero following the tutorials here.

      http://www.dreamincode.net/forums/topic/92293-making-flash-games-for-the-non-flash-develop er-part-ii/

      http://www.brighthub.com/internet/web-development/articles/11010.aspx

       

      The problem is that both of these tutorials use Deprecated Code and it's been difficult to move forward. One of the main Problems I've been having is with the

      <mx:Canvas> tag which has been deprecated http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/containers/Canvas.ht ml, I'm not sure which one of the alternatives to pick, or know if there's any extra things needed when working around them.

       

      The other problem is with the way that children are added in the code for example,

      <mx:states>
                <!--Main Menu scene state-->
                <mx:State name="Menu">
                     <mx:AddChild relativeTo="{gameCanvas}" position="absolute">
                          <mx:Button label="Start Game" mouseOver="mouseOver(event)" click="btnStartGame()" x="{Application.application.width / 2}" y="{Application.application.height / 4}" />
                     </mx:AddChild>
                     <mx:AddChild relativeTo="{gameCanvas}" position="absolute">     
                          <mx:Button label="How 2 Play" mouseOver="mouseOver(event)" click="btnHow2Play()" x="{Application.application.width / 2}" y="{Application.application.height / 4 + 25}" />
                     </mx:AddChild>
                     <mx:AddChild relativeTo="{gameCanvas}" position="absolute">     
                          <mx:Button label="Settings" mouseOver="mouseOver(event)" click="btnSettings()" x="{Application.application.width / 2}" y="{Application.application.height / 4 + 50}" />
                     </mx:AddChild>
                     <mx:AddChild relativeTo="{gameCanvas}" position="absolute">     
                          <mx:Button label="Credits" mouseOver="mouseOver(event)" click="btnCredits()" x="{Application.application.width / 2}" y="{Application.application.height / 4 + 75}" />
                     </mx:AddChild>
                     <mx:AddChild relativeTo="{gameCanvas}" position="absolute">     
                          <mx:Button label="High Scores" mouseOver="mouseOver(event)" click="btnHighScores()" x="{Application.application.width / 2}" y="{Application.application.height / 4 + 100}"/>
                     </mx:AddChild>
                </mx:State>
      

      The new Flex (working in mobile mode), doesn't like this way of working with add child, now I'm basically I have no idea how the work around would look like.

       

      If anyone knows of any good up to date game development tutorials, or can help work around the Decrecated Stuff that'd be greatttt. xD

        • 1. Re: Game in Flex, help working around Deprecated Code
          miguel8312 Level 3

          may i sugguest just using the 3.5 sdk as supposed to the 4.0 sdk. This might solve your problem. Thats one way to get around the hurdle. Post up if you dont know how to do this.

          Miguel

          • 2. Re: Game in Flex, help working around Deprecated Code
            HorseSense.knome Level 1

            Well I would if I could, currently I'm trying to make a game work for the new up coming BlackBerry Play Book, the code supported is only Air 2.5, SDK 4.0 + soo I can't switch even if I wanted to

             

            I could try to re-write everything from pure scratch AS, but that's something I'd want to avoid if I can.

            • 3. Re: Game in Flex, help working around Deprecated Code
              David_F57 Level 5

              hi,

               

              There are a few things you can do,

               

              Replace canvas with a container (group or borderContainer or Skinnable Container).

               

              With States its a lot easier, you just add all your components to the group then declare what state they belong to

               

              <s:states>

              <s:State name="default"/>

              <s:State name="scores"/>

              </s:states>

              <s:Group id="main" width="100%" height="100%">
                   <s:Button id="score" top="{main.height*0.75}" left="{main.width/2}" bottom="0" right="0" includeIn="scores"/>     
                   <s:Button id="top score" top="{main.height*0.75}" left="0" bottom="0" right="{main.width/2}" includeIn="scores"/>     
                   <s:Button id="play" top="{main.height*0.75}" width="100%" includeIn="default"/>     
              </s:Group>
              So when currentState = "scores" there will be 2 buttons filling the bottom quarter of the group
              when current State = "default" ther is one button filling the bottom quarter of the screen.
              also you can still add mx components to a spark container you don't use addChild but addElement and typecast the mx component
              main.addElement(myCanvas as IVisualElement).
              Hope this helps a bit.
              David.

              1 person found this helpful
              • 4. Re: Game in Flex, help working around Deprecated Code
                HorseSense.knome Level 1

                I will give this a work around a try tonite, I'll post up any findings when I get it working.