Friday, June 13, 2008

Adding mc speed using Numeric Stepper component

In previous example, our hero has constant speed set to 2. Speed is defined inside doTween function, as 6th parameter for xT and yT tweens. Off course, this speed doesn’t have to be constant at all. We will use Numeric Stepper component just to show how to change speed parameter. Instance of Numeric Stepper is "step". We change mentioned parameter from "2" to "step.value".

download hero_v2 source file.

 


When making a game, we will not use Numeric Stepper, but we can change hero speed in this way in relation to health or game level or whatever.

Posted by flanture at 14:51:07 | Permanent Link | Comments (0) |

Wednesday, June 11, 2008

Character elastic movement


Flash game characters doesn’t have to move only in standard way, press left arrow key to move left, right arrow key to move right, space to jump etc. In this new flash game, main character (hero) will move differently. Hero will be dragable and on click, he will perform elastic move. Start position and destination position will be symmetrical in relation to Stage center. Enemy can be destroyed only if mouse is not pressed, otherwise, hero health will decrease.

Now, code. First we import related classes:

import mx.transitions.Tween;
import mx.transitions.easing.*;

We need to define simple onPress, onReleaseOutside and onRelease methods for movie clip of our hero, mcHero. Method onRelease has two functions, findSimPoint() and doTween(). It is obvious that findSimPoint() calculates symmetrical point of hero x and y in relation to Stage center. DoTween(), well, performs the tween! Code comes with comments.


Download hero.fla




Posted by flanture at 15:48:03 | Permanent Link | Comments (0) |

Sunday, July 22, 2007

Without Good Title


I have read a little bit more my Flash Mobile book and I made my first application which is actually doing something.

Simple application that shows how screen reacts on keys. This is what I did. Make a movie clip with text field. Name movie clip "mctxt", name text field var "myinput". On root place next code:

fscommand2("FullScreen", true);
_root.mctxt.myinput="keys test";

Make button, put next code for button's actions:

on(keyPress "4")
{
_root.mctxt.myinput="4";
}
on(keyPress "6")
{
_root.mctxt.myinput="6";
}
on(keyPress "5")
{
_root.mctxt.myinput="by flanture";
}


That's it. I tested it and it works great. Don't forget to publish movie with flash lite 1.1 and don't forget (I did) to make text color different from background color. Text field must be dynamic. Also, movie size must correspond with your screen size.

This application is very simple, but it has some usefull elements like reaction on keys and displaying response. These element are basic for any game or serious application. Right.


AddThis Social Bookmark Button

Posted by flanture at 03:08:00 | Permanent Link | Comments (0) |

Saturday, June 23, 2007

Small update


Small update to Sparta Defender, now v0.13. First, I added points won movie clip that let's you know if you killed Persian shield or you missed it. Second, I introduced time limit. Now you have 3 minutes to kill 300 points or 60 Persians or Sparta fill fall.

Download Sparta Defender v0.13
Posted by flanture at 19:39:32 | Permanent Link | Comments (0) |

Wednesday, June 20, 2007

Sparta Defender v0.11




My simple "space shooter" v0.8 surprized me few days ago by becoming "Sparta defender" v0.11 ! I have changed main character and enemies, added background and solved timeline issue.

You have to move mouse left and right and destroy all those Persians as soon as possible. At start they come to you slowly, but their speed is changing fast. You goal is to get 300 points.

Game has 56 lines of code. I have been using code I wrote earlier for main character and you can read that post here .

Download game swf and source code Sparta .

If you have any question about code, please feel free to ask.
Enjoy !
Posted by flanture at 23:50:34 | Permanent Link | Comments (0) |

Thursday, June 14, 2007

Emanuele Feronato rocks !

 

Emanuele Feronato and his website really rocks. For every Flash Game Developer wannabe this is never ending source of useful informations about making games in Flash. More suitable for beginers, but well explained, code everywhere , samples and stuff.

 

I wish I could have more free time to explore it more. Nice work Emanuele !

Posted by flanture at 16:48:54 | Permanent Link | Comments (0) |

Saturday, March 24, 2007

comics album flash application

Flanture is proud to present next flashMX project, Comics Album.

Album is simple but useful. It uses flash power to include dinamic content loaded from any xml file and combine it with already done comic image pages. Comic is usually separated in pages, and every page has different text clouds. This Album shows pages one by one. It has two navigation buttons. Main characteristic is that text can be changed from xml file, but also and text font, color, size. Xml file contain text clouds for every page.

Comic Album is great way to separate graphics from text in your comic creations. Text can be modified dinamicaly, font, it's size and color. Let's see how to use it. This is how looks like part of xml file that describes one comic page:

< page purl="page1.jpg" tboxn="1">

< tbox posx="420" posy="220" bw="300" bh="100" txt="Third text box!" fnt="Verdana" fnts="26" fc="0x000000" />

So, what we have here? Parametars for one comic page are:
purl - page url
tboxn - number of text boxes (clouds)

Parametars for one text box are:
posx - x position of text box
posy - y position of text box
bw - box width
bh - box height
txt - text
fnt - font face
fnts - font size
fc - font color (hexadecimal numbers)

That's it ! Simple, but nice. If you are interested in using Comics Album, please leave comment.

DOWNLOAD ALBUM FILES

Posted by flanture at 21:25:26 | Permanent Link | Comments (0) |

Thursday, March 15, 2007

hidden news ticker

My news thicker is little different. It can be hidden amongst other page flash elements, but on button press, it becomes wider, and news are displayed. News string comes from xml file. You can download zip (4kb) with swf and xml.

edit: link broken, download at HERE
download zip

I may convert it into component, later. This is created on first hand. I could spend more time on some nice skin, or on code which implements two rows of data with different colors, etc, but I didn't. Not yet. Like it?

Posted by flanture at 22:17:07 | Permanent Link | Comments (2) |

Sunday, February 25, 2007

contolling objects in FlashMX


tool : Flash MX

Moving object as movie clips in Flash can be achieved in various ways. One of them is controlling objects with text input box.
First, create new file. You will need two things, movieclip that represents object, and button with input text box. My creations are on picture below.



For button, for every state put keyframe. Set show border around text. Set input text with var : "distance".
Set movieclip instance name as "wheel". Finaly enter action for button:

on(keyPress "< Enter>"){
  _root.onEnterFrame=function(){
    if (_root.wheel._x < distance){
      _root.wheel._x += 5;
      _root.wheel._rotation +=5;
    }
    if (_root.wheel._x > distance){
      _root.wheel._x -= 5;
      _root.wheel._rotation -=5;
    }
  }
}

Another way of moving movieclip is with mouse. In this case we don't have button. MovieClip is same, and only code is in first frame of main timeline.
_root.onEnterFrame=function(){
  if (_root.wheel._x < _xmouse){
    _root.wheel._x += 10;
    _root.wheel._rotation +=10;
  }
  if (_root.wheel._x > _xmouse){
    _root.wheel._x -= 10;
    _root.wheel._rotation -=10;
  }
}
Posted by flanture at 23:13:12 | Permanent Link | Comments (0) |

Thursday, February 08, 2007

integration

I was wondering what if somebody is deeply in as1 and as2 and have doubts  about learning as3. How to use many lines of code written earlier, with new avm2. Well, solution is already here, as I said before.  FlashInterface is about actionscript virtual machines communication. It provides direct communications between flash8 and flash9 avms. 
Posted by flanture at 12:59:07 | Permanent Link | Comments (0) |
1 2