Hi I am in the early stages of building a word game where a word will be displayed on the screen and then letters would fall down the screen. The player would be required to click on the correct letters to build the word that appears at the bottom of the screen.
I have made the letters in Illustrator. Each letter on a different layer. My question is - how do I BEST import them into Flash to appear in the game?
As a test I imported one png, I made it a movie clip, I made its own class as file to have an alpha and a path to move on.
I've set it to start moving when the timer starts in the constructor as file. I also added an event listener to say letter "a" was clicked on. I still have to remove it from the stage when it passes certain x or Y co-ordinates and loop the behaviour untill the timer has run out.
I want many letters to glide over the screen and start at random times while the timer is running.
Do I keep going in the same way with the other letters - each having their own class as file and the manipulating them in the constructor as file.
I have never worked with an array of anything, but I think I might have to learn how to do arrays with the letter tiles?
this is but a small part of my game, but I think its best to ask/learn about specific sections one at a time.
Message was edited by: buggoop
I don't know that you need to create a class file yourself. If you want to assign alpha and a path I think those elements could be defined dynamically. YOu may just have to assgn a class id to each moviclip in the library and then use that to dynamically create an instance.... Flash will automatically create the class for you in that case.
I'm basically following a tutorial (on no objects on stage only one frame game) and adobe tv and implementing everything applicable religiously. So I import a graphic, then convert to movieclip and enable action script linkage in the properties. I think this is called OOP coding? Everything works fine as is. I would just like to know - if I go on doing the rest of the letters the same way, if it will work ok or is there a more efficient way?
Should I do it for all the letters?
The I get the following code:
//class A refers to my letter A graphic
public class A extends MovieClip
//set basic location and appearance
public function A()
x = 300;
y = 30;
alpha = 0.1;
//change alpha as mc appears
public function fadeIn():void
alpha = alpha + 0.06;
//move mc accross screen
public function moveA():void
x = x + 3;
y = y + 4;
And then I have this constructors code to pull everything together:
public class BugGoopFSGame extends MovieClip
public var mybackground:BackGround;
public var lettera:A;
public var cinders:Cinders;
public var gameTimer:Timer;
public var spidy:Spidy;
public var myplaybtn:Play;
public var timerback:TimerBack;
public var timermiddle:TimerMiddle;
public var timerfront:TimerFront;
public var settings_btn:Settings_btn;
public function BugGoopFSGame()
mybackground = new BackGround ();
lettera = new A ();
cinders = new Cinders();
spidy = new Spidy();
myplaybtn = new Play();
timerback = new TimerBack();
timermiddle = new TimerMiddle();
timerfront = new TimerFront();
settings_btn = new Settings_btn();
gameTimer = new Timer(31,5120);
//Add event listener for start button
//Add event listener for timer;
//Add event listener for when lettera is clicked
//Start timer function
public function startTimer(timerEvent:MouseEvent):void
myplaybtn.visible = false;
public function tickTock(timerEvent:TimerEvent):void
public function timerFinished(timerEvent:TimerEvent):void
trace("Timer is finished");
public function scaleLifeBar(timerEvent:TimerEvent):void
public function fadeIn(timerEvent:TimerEvent):void
public function moveA(timerEvent:TimerEvent):void
public function onClick(event:MouseEvent):void
trace("The letter a was clicked");
If you need to have specific locations and property assignments for the different letters, then creating each class yourself manually is probably your only course of action. But if they could be assigned dynamically, then you would only have to go as far as creating the movieclips and assignoing them a class linkage. Flash will create the class code/file and your document or constructor class cvould deal with assigning the properties.
THe short version of that is, you are probably okay the way you are going. I realize I'm a day or better late in getting back to your posting, so hopefully I am not recommending against some change in your approach that might have arisen.
I worked on other things while I waited for your answer. I'm going to try your advice now and am sure I'll have more questions...
I already change all the individual letters to movie clips now and I created a class file for each in my classes folder. I will assign porperties for them.
My next question is:
In my constructor class - how to I add children(letters) randomly and at spaced intervals? I suspect this will have to be done with arrays (never delt with arrays).
In my game a letter will have to be clicked on and checked to see if it corresponds to the next letter in a string that I display at the bottom.
Thanks for your help