[flexcoders] Re: I want to use Flex Builder 3 to develop Flash Games
--- In flexcoders@yahoogroups.com, Axonn theax...@... wrote: Hm, I think I didn't ask the right question, because somebody told me that it *is* possible. What I want is this: - Create a FLA file in Flash. - Draw 2 rectangles. - Create an AS file in Flex 3. - Attach it to the Flash. - Export as SWF. - Continue development in Flex 3. When hit debug, my Flash-created SWF starts but the debug code is attached to Flex 3, because I am in Flex 3. But you know Flex 3 creates that default SWF. I don't want that. I want to use the Flash SWF, which *DOES* have my AS class from Flex in it. - DO modifications to the AS but DON'T START FLASH AGAIN until I need to modify graphics and such. I use FlashDevelop for this kind of work. It has code completion and all kinds of handy features (such as autogenerating getters and setters from private variables or event listener functions from an addEventListener statement). Essentially, you write your code in FlashDevelop, and when you debug FlashDevelop will launch Flash to create the swf and you'll see your break points in the Flash IDE. This may not be what you're looking for, but it's a work flow that works for me. HTH; Amy
Re: [flexcoders] Re: I want to use Flex Builder 3 to develop Flash Games
Hi My workflow for working with Flash and Flex has turned into this: Take one of two branches: Flex project or ActionScript project. I mostly start with a Flex project *but* I don't bother to use the Flex framework. I let it generate its usual main.mxml file that extends application. I then create my normal package structure in the src folder: com/[companyname]/[project]/ I create a class there that is the root class for my project - the class *must* extend Sprite or MovieClip. I then go back to the main.mxml and do the following change the mx namespace to: xmlns:[project]=com.[companyname].[project].[MainClass] change the mx:Application tags to be [project]:[MainClass] remove any references like: layout=absolute and so forth so your app tag is just [project]:[MainClass] xmlns=.. Now you have a Flex project that doesn't use the Flex framework but still has a single MXML file so the Flex compiler is happy. The MXML is non-graphical, can't use the design view with it and I don't add anything else to the MXML. Everything else happens in the as [MainClass] file. Once that is setup I create another folder: fla and if I don't already have a libs folder I create that and put in the appropriate references under Properties - Flex Build Path - Library Path. If the libs folder wasn't created by default, create it and use Add SWC Folder and point it to the libs folder. I make sure the libs folder is set to merge into code. Next I create one or more FLAs that will contain assets that I'll use in my final project. I make sure that I add the location of the src folder ../src/ in the class path for the FLA. I then create the appropriate Movie Clips and classes and associate them all together as needed and publish the FLA as both swf and as swc into the lib folder. I ignore the swf (it basically comes along for the ride). Now all the classes you created as MovieClips in Flash are available as classes in your flex project. The nice part is that when you compile in Flex, it will pull in the MovieClip class from the swc but it picks up the base class from your src folder so you never need to republish the swc except if the MovieClip symbol changes. Sometimes I need a library of symbols that I may or may not have actual code references to. Then I'll do one of two things: a) Create a class and list all the symbols as private static properties and then make a reference to that class in the [MainClass]. Keeping all the references neatly outside of my main class keeps things cleaner. b) I create a Flex Library project that I will treat as an RSL. This gets a bit interesting. Because the lack of the use of the Flex Framework means that any RSLs linked to the project will not automatically get loaded. You can solve that by loading them manually, or looking at the Flex SimpleApplication or Application classes and digging down and copying the RSL load scenerio. I do manually using XML config files to tell me what to load. The nice part is that you can still set them to auto-extract to deployment path and Flex will recompile the RSL and then extract the swf from it in debug or release form automatically for you. But again, you can't just point to the classes in the swc to include in the library, you have to create one class that lists all the MovieClips as static variables. So for example in both a) and b) you would do something like: import com.[companyname].[projectname].[SymbolName]; private static var _symbol1:Class = [SymbolName]; Flex will create the appropriate import statement and will show the swc classes in the prompts as you type so you can just do the last line and let Flex create the import statement for ya. Yes I actually create my symbol classes in package structure vs just [SymbolName] as the class in Flash. Sometimes I divide things up like: com.[companyname].[projectname].symbols.[SymbolName] (class associated with symbol in Flash) and com.[companyname].[projectname].[package].[BaseClass] (base class for MovieClip in Flash) Try not to name the two with identical names ie. try not creating a symbol called: CheckBox and a base class called CheckBox take it from me, this will drive you to drinking. I also load my RSLs into ApplicationDomain.currentDomain. After this code only changes and all debugging happens inside of Flex. Only time I open Flash is to publish a new swc *if* the symbols change or new symbols added (then of course need to make reference them in code). One additional cheat method you can use if you like for pulling in symbol assets: Create one master symbol, dump a copy of all the symbols you create into it, then you only have to reference that one symbol and you get all your other symbols for free. For games and such that I would have normally used the main FLA timeline for, I create a symbol that would represent that timeline and use it instead. I hate debugging in Flash itself (the
[flexcoders] Re: I want to use Flex Builder 3 to develop Flash Games
Using swc's for your assets is great because it it also makes compiling a lot quicker. With organisation i would suggest a few more categories. - assets - component (eg. spaceship) logic - component factories. - main - main factories - main logic these separate swcs/swfs make your compiling time even quicker. The factories are basically used to instantiate everything your main game will require. Bjorn --- In flexcoders@yahoogroups.com, Axonn theax...@... wrote: Hi Doobie! You said: You might want to organize things differently. Assuming that Game.as is your main class that you compile for the game, you may not want to compile this with Flash if you're trying to use Flex Builder. The way I organize is to break down my stuff into 2 categories - the main game, and the objects/assets used by the game. Since yesterday, I guess I found a bit of balance! I found a thread on the FlashDevelop forum which goes something like this (I'm just telling you the main idea): You have Game.swc. You then do this: public class Game_New extends Game { public function Game_New() { super(); trace('And here, I can add my component-related code for Game.swc'); } } So as you can see, this way we can modularize code PER-COMPONENT. This is the perfect way for me: I can code stuff for each component without actually going into Flash. I can modularize my component-related code for each SWC and I also can have the main compiled class contain the main logic. You said: There is no way you'll build a game even in the Flash IDE without grouping your art into some form of Movieclip or Sprite. I've been doing computer programming for 11 years now (C#, C++, VB6, PHP), so I know what you're saying and I agree completely. I even did ActionScript quite a lot, but that was 5 years ago and it was AS 1.0, so it's like... another lifetime *laugh*. But no, I wasn't even remotely thinking to work in such a disorganized way! My designer has about 5 years of Flash behind so she knows her shit ::- D. But even so, of course I already am establishing the hierarchical structure of the assets with her. There's no way a good project would live without lots of good and planned order!!! For example if you have planet, space ship, man and helmet, there would be no way in hell I want them lying on the stage for me to stich up together. That would be a huge waste of time indeed ::- D. Axonn. --- The objects and assets I use are usually pretty simple. I like these as SWCs because I can give them a little logic, and maybe a animated timeline if need be. Typically if you keep these simple, you'll rarely have to touch the code, and just have to update with any art changes. The main game class, however (what I'm assuming you're calling Game.as), is something that you'll update constantly throughout the lifecycle of your game. So this is easier to leave as just some code, and don't compile into a SWC, just let Flex compile with each build of the game. You can organize stuff however you like though - you could completely ignore what I said, there's no right way to do it. The above just happens to be what works for me. You also talked about your artist not liking having to dig into movieclips and symbols in the library. Honestly, they should really learn some organization. Movieclips are the basic building blocks for interactivity in the Flash IDE. There is no way you'll build a game even in the Flash IDE without grouping your art into some form of Movieclip or Sprite. If your artist can only draw on the main stage, it'll end up being your job to figure out how to organize things into the movieclips as you need them and just do the production work yourself. The downside of this, is having to do this production work everytime the art gets updated. I've been through this it's not fun. It's easier to do a bit of pre-planning surrounding your game and get a dialog going with your artist on how to best organize the assets. If you both stick to the plan, they can work in Flash independently and just give you an updated SWC every so often while you work in Flex Builder, updating the logic surrounding the game. But like I said - people prefer different stuff - I'm sure once you get a little experience with this workflow, you'll have your own opinions. ben Axonn wrote: Hi Doobie and thanks for your answer! I just managed to get my first SWC into Flex ::- D. *rejoices*. However, I can't do anything with it ::- (... I have this Game.swc. In CS3, I set Game.as to its class. Game.as is in the same folder as Game.swc. After importing it in Flex, I modified Game.as. I added a trace. But nothing shows when I run it with Flex ::- ( ... please don't tell me I need to recompile the SWC if I modify the AS. As far as I understood so far that's the whole thing
[flexcoders] Re: I want to use Flex Builder 3 to develop Flash Games
I think the thing that everyone confuses when they ask these types of questions is Flex vs Flash... IT IS ALL FLASH. Basically when you choose to use The Flex Framework for a project it is because you need to take advantage of the framework features that Flex provides like Data Binding and of course the main feature The Components. The main feature of Flex that you get out of the box is all the components that you can call and use without having to build your own. If you feel that the FrameWork will allow you a huge advantage because of the components say for building menus for your game or something of that nature then I would say Go for it! The Flex framework does have a SWFLoader Component that you could load your actual game into. Then if you need the came to send game data back and forth between the swf and the Flex application you could do this by using custom events or public variables or objects and functions. Does that help at all ? -Matthew Wallace http://flashalisious.com --- In flexcoders@yahoogroups.com, Axonn theax...@... wrote: Hm, I think I didn't ask the right question, because somebody told me that it *is* possible. What I want is this: - Create a FLA file in Flash. - Draw 2 rectangles. - Create an AS file in Flex 3. - Attach it to the Flash. - Export as SWF. - Continue development in Flex 3. When hit debug, my Flash-created SWF starts but the debug code is attached to Flex 3, because I am in Flex 3. But you know Flex 3 creates that default SWF. I don't want that. I want to use the Flash SWF, which *DOES* have my AS class from Flex in it. - DO modifications to the AS but DON'T START FLASH AGAIN until I need to modify graphics and such. Axonn. That is correct. Flex can only debug code in flex itself. I did see a book at barnes and noble last week that dealt with games in Flex (but I forgot the name of it). -- View this message in context: http://www.nabble.com/I-want-to-use-Flex-Builder-3-to-develop-Flash-Games-tp22752546p22766233.html Sent from the FlexCoders mailing list archive at Nabble.com.
[flexcoders] Re: I want to use Flex Builder 3 to develop Flash Games
I think the thing that everyone confuses when they ask these types of questions is Flex vs Flash... IT IS ALL FLASH. Basically when you choose to use The Flex Framework for a project it is because you need to take advantage of the framework features that Flex provides like Data Binding and of course the main feature The Components. The main feature of Flex that you get out of the box is all the components that you can call and use without having to build your own. If you feel that the FrameWork will allow you a huge advantage because of the components say for building menus for your game or something of that nature then I would say Go for it! The Flex framework does have a SWFLoader Component that you could load your actual game into. Then if you need the came to send game data back and forth between the swf and the Flex application you could do this by using custom events or public variables or objects and functions. Does that help at all ? -Matthew Wallace http://flashalisious.com --- In flexcoders@yahoogroups.com, Axonn theax...@... wrote: Hm, I think I didn't ask the right question, because somebody told me that it *is* possible. What I want is this: - Create a FLA file in Flash. - Draw 2 rectangles. - Create an AS file in Flex 3. - Attach it to the Flash. - Export as SWF. - Continue development in Flex 3. When hit debug, my Flash-created SWF starts but the debug code is attached to Flex 3, because I am in Flex 3. But you know Flex 3 creates that default SWF. I don't want that. I want to use the Flash SWF, which *DOES* have my AS class from Flex in it. - DO modifications to the AS but DON'T START FLASH AGAIN until I need to modify graphics and such. Axonn. That is correct. Flex can only debug code in flex itself. I did see a book at barnes and noble last week that dealt with games in Flex (but I forgot the name of it). -- View this message in context: http://www.nabble.com/I-want-to-use-Flex-Builder-3-to-develop-Flash-Games-tp22752546p22766233.html Sent from the FlexCoders mailing list archive at Nabble.com.