1 Reply Latest reply on Jun 13, 2007 5:06 AM by PimpOfPixels

    help with first flash game?

      Hi. My name's Rory.

      I am an artist.

      I am learning action script and Flash so that I can make games.
      I am not a complete novice in programming. I am proficient in Java and in MaxScript (3DSMAX embedded language).

      I have been making some progress in action script and I have a functional (although incomplete) game in the works. You can view it here:
      The idea is it's a color game
      red beats green, green beats, blue beats red. Think paper scissor rock.
      The idea is to change the entire circle into one color.
      The graphics are place holders BTW.

      I am using FlexBuilder 2.0 and Flash CS3, and I have come across a problem not covered in either of my books.

      I'd really appreciate any help that you guys can offer.

      I have gotten this far on my own.

      My #1 question (and I have many more) is:

      How do you through Flash specify animation segments for a MovieClip Symbol?

      Notice how the red creatures occasionally open their mouths. I want to have a walk, an attack, an absorb, and a bounce animation on the same timeline and trigger the appropriate one depending on which color the creature collides with. I do not know how to go about this problem. I’ve just been trying to get the walk animation to loop without playing the attack animation so far.

      I've tried frame-labeling in flash, with scripts on the key frames of a second layer that specify when to stop or repeat the animation... No dice.

      I have a symbol named RedShot in the library of a flash project named "graphics"

      In my timeline I have 2 animation segments, and I have a second layer denoting two corresponding frames named "walk" and "attack" from the properties menu.

      On the final frames of the animations I have scripts.


      Im my library I have linkage options specified as such:
      export of actionscript#CHECKED
      export on 1st frame#CHECKED

      on the main stage of my flash project I have actionscript for 2 functions:

      function walk(){
      function attack(){

      I export the project and the opened window has the "walk" animation looping properly.

      In my FlexBuilder project I embed the symbol

      //Inside class global variables:
      [Embed(source="../graphics.swf", symbol="RedShot")]
      public var RedShot:Class;
      private var _shot:MovieClip;
      //and in my buildShot function:
      _shot = new RedShot();

      When I build the project the characters appear, and they animate. The only trouble is that there are no breaks in the animation. The animation loops right through the frames where I have specified that the animation should "gotoAndPlay" from a different part.

      What's weirder is that I can call
      without an error and it will go to and play from that point. The only trouble is that it will begin to loop the entire animation again without stopping at the gotoAndPlay events stored in the frames of the timeline.

      It seems like all embedded actions are ignored, add I can't think of another way to controll the animation.

      Any thoughts?
        • 1. Re: help with first flash game?
          PimpOfPixels Level 1

          After hours of searching the internet I finally got this blasted question figured out.

          How to you export a symbol from Flash for use in a Flex Builder project without destroying actionscript stored within the frames of the Symbol's timeline?

          That's a long winded way of saying: "In FlexBuilder, how do you control MovieClips from Flash". I'm trying to make games, and this was a particularly important question for me :).

          Here's how:

          1) You need a hotfix from Adobe.

          This allows Flash CS3 to export a SWC file.

          2)You have to set the linkage properties for your various symbols in the flash library panel.
          a)right click on symbol in library panel
          b)choose "linkage"
          c)"Class:" = (pick a name)
          d)"Base class:" = flash.display.MovieClip;
          e)"Export for ActionScript" = CHECKED
          f)"Export in first frame"=CEHCKED

          3)If you want to have multiple segmented animations as I certainly did you'll want to create frames and actionscripts within the symbols timeline to define where these animations are.
          a) in the symbol's timeline make a second layer. We'll name that layer "labels" for the sake of not having this get too confusing.
          b) on that layer create a new frame for each of the animation segments that you'd like to define and stretch them to the length of the corresponding animations.(I'm assuming that you have a keyframe animation on the 1st layer... otherwise what's the point of all this :P?)
          c)in the properties panel name the frames in the "labels" layer accordingly ie. "walk" "run" shoot" etc.
          d)Define whether the various animations play once or loop by adding a script to the last frame of the animation. If you want the animation to loop add
          if you want the animation to play once and stop add
          if you want the animation to play once and then return to a different animation add

          4) now you can export the symbols to an SWC file. Note: you do not get this option unless you have installed the hotfix. [HTML]http://kb.adobe.com/selfservice/viewContent.do?externalId=kb401493&sliceId=2[/HTML] .
          a)rightclick on a symbol in the library panel
          b)choose "exportSWCfile..."
          c)export the file to a logical place such as the root of your FlexBuilder project.

          5) Now you have to tell flexbuilder about the new SWC file. Note: Once this file is added to the FlexBuilder library you can instantiate classes from it as though they were included using the "include" function.
          a)Right clicking on the root of the project in the Navigator view.
          b)going to properties.
          c)Going to library path. (2nd tab)
          d)and pressing the "Add SWC" button

          Now you're done and you can instantiate any of the symbols from your library while preserving any actions from your symbols timeline just as though you had imported it as a class from a typical library.

          Sweet huh?

          Thanks to the countless people and internet resources I found on the subject. Hopefully it will be easier for anyone who finds this post.

          Here's an adobe video which covers the basic process.