Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsAt 11/27/13 04:06 PM, milchreis wrote:At 11/27/13 04:03 PM, A-Genius wrote: ok you mean I should create a new public class right?No.
You should put that code into the class that creates the monsters, which is you main class.
I already add the code in my main
public class monster1 extends Sprite
{
public var myEnemy:Array = []; // add my objects inside my array
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
At 11/27/13 03:58 PM, graives wrote: Nah, your loop has to go in a completely different class. Put it in the class that is calling your monster1.
ok you mean I should create a new public class right?
At 11/27/13 03:43 PM, graives wrote: This needs to go outside of the monster1 class (along with the myEnemy array). Also, make sure moveMonster is set to public.
still slow
At 11/27/13 03:43 PM, graives wrote: This needs to go outside of the monster1 class (along with the myEnemy array). Also, make sure moveMonster is set to public.
public class monster1 extends Sprite
{
public var myEnemy:Array = []; // add my objects inside my array
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
public function moveMonster(e:Event):void
{
if (this.y != 300)
{
this.mapPattern();
}
}
ok
At 11/27/13 05:16 AM, NoStylin wrote: I made this animation, I'm still new to flash but was wondering... how much detail do most people put within their lip sync animation.
thanks in advance.
http://www.youtube.com/watch?v=Yswj26lS5g0
I also had no idea the song was remixed from a vines clip. kind of silly.
is this some kind of brain washing?! because that what it looks like!
At 11/27/13 09:10 AM, kkots wrote: Re-post your code with changes applied! :D
import flash.display.Sprite;
import flash.events.*;
public class monster1 extends Sprite
{
public var myEnemy:Array = []; // add my objects inside my array
var oneTurn:Number = 0;
var speed:Number = 1;
public function monster1()
{
this.width = 49;
this.height = 45;
addEventListener(Event.ADDED_TO_STAGE,Launch); //when the object is add to stage
trace(myEnemy.length);
}
function Launch(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,Launch); //remove listener to work for one object
myEnemy=[this];
addEventListener(Event.ENTER_FRAME,MyEnterFrame); // create listener to add into frame
}
function MyEnterFrame(e:Event):void
{
for(var i:uint = 0; i<myEnemy.length; i++){
myEnemy[i].moveMonster(e);
}
}
function moveMonster(e:Event):void
{
if (this.y != 300)
{
this.mapPattern();
}
}
it still act slow >.> when I add 20 monster
At 11/27/13 09:10 AM, kkots wrote:At 11/27/13 07:10 AM, A-Genius wrote:Re-post your code with changes applied! :DAt 11/27/13 12:45 AM, milchreis wrote:
ok now I understood so I need to start with Sprite as my main class I will apply the changes then Re-post
At 11/27/13 08:17 AM, larrynachos wrote: I'm impressed you all managed to keep this thing going.
Hats off to you, sirs.
why don't you animate a continue with a short part before I close the collab and start combing everything ?!
At 11/27/13 12:45 AM, milchreis wrote: Do not add an ENTER_FRAME listener to every object.
Iterate over the array that holds all enemies instead. (do this in your Main class)
I didn't understood second line >.>! can you give example?
At 11/27/13 01:39 AM, milchreis wrote:What is Sprites ?A class that you should use instead of MovieClip.
but I don't draw a sprites using codes! I already have ready MovieClip!
At 11/27/13 12:45 AM, milchreis wrote: Do not add an ENTER_FRAME listener to every object.
Iterate over the array that holds all enemies instead. (do this in your Main class)
Use Sprite instead of MovieClip as a super class.
What is "destory()" ?
Do you mean destroy?
Post that function!
What is Sprites ?
At 11/27/13 12:10 AM, HappyWhaleStudios wrote: Can we see the code? Probably the issue is that you're not doing it in the most efficient way or your computer's just slow, but probably the first one, so post your code and I'll see if I have any suggestions on how to make it better
This is the first code that I think contain the problem:
public class monster1 extends MovieClip
{
var oneTurn:Number = 0;
var speed:Number = 1;
public function monster1()
{
this.width = 49;
this.height = 45;
addEventListener(Event.ENTER_FRAME,MoveMonster);
}
function MoveMonster(e:Event):void
{
if (this.y != 300)
{
this.mapPattern();
}
}
public function mapPattern()
{
if (this.x < 168 && oneTurn == 0)
{
this.x += speed;
}
if (this.x == 168 && this.y > -103 && oneTurn == 0)
{
this.y -= speed;
}
if (this.y == -103 && this.x < 435)
{
this.x += speed;
}
if (this.x == 435 && this.y < 125)
{
this.y += speed;
}
if (this.y == 125 && this.x > 150)
{
oneTurn = 1;
this.x -= speed;
}
if (this.x == 150 && this.y < 300)
{
this.y += speed;
}
if (this.x == 150 && this.y == 300)
{
this.destory();
}
}
how can I allow 20 object to move smoothly?
at the beginning my object begin to move, normally just after adding my second object it slowed down any way to speed up my code!
At 11/26/13 07:45 PM, MSGhero wrote: array = [];
timer = new Timer(2000, 8);
timer.addEventListener(TimerEvent.TIMER, timerFunction);
function timerFunction(e:TimerEvent):void {
array.push(new Monster());
}
OK now I understood the function better!
At 11/26/13 06:59 PM, MSGhero wrote:I want my to execute the code inside my class but I think using setInterval(); was a bad ideaYou don't need setInterval, you already wrote out everything you need. Just push() the new thing into the array inside the timer function. The timer function IS your interval-setter.
I have created this code but it works only for 2 objects
var i:Number =0;
var m1:Array = [new monster1(),new monster1()]
var addObj:Number = 21;
var MyTimer:Timer = new Timer(2000,1);
var MyTimer_2:Timer = new Timer(1,2000);
var MyTimer_3:Timer = new Timer (1,2000);
MyTimer.addEventListener(TimerEvent.TIMER,TimerFunction);
function Timer2Function(e:TimerEvent):void{
MyTimer_3.addEventListener(TimerEvent.TIMER,Timer3Function);
m1[i- m1.length + 1].mapPattern();
if(m1[i-m1.length + 1].x == 70){
MyTimer_3.start();
}
}
function Timer3Function(e:TimerEvent):void{
m1[i- m1.length].mapPattern();
}
function TimerFunction(e:TimerEvent):void{
MyTimer_2.addEventListener(TimerEvent.TIMER,Timer2Function);
for(i=0; i<m1.length; i++){
enemy_contain_mc.addChild(m1[i]);
}
MyTimer_2.start();
}
MyTimer.start();
At 11/26/13 11:38 AM, kkots wrote: Post your code, and point out where the problem is, using code comments //
I want my to execute the code inside my class but I think using setInterval(); was a bad idea
var i:Number =0;
var m1:Array = [new monster1()];
var MyTimer:Timer = new Timer(2000,8);
MyTimer.addEventListener(TimerEvent.TIMER,TimerFunction);
//the function increment and decrement the y and x in the path I have created it for it
function td():void{
m1[i].mapPattern();
}
function TimerFunction(e:TimerEvent):void{
for(i=0; i<m1.length; i++){
enemy_contain_mc.addChild(m1[i]);
//doesn't work
setInterval(td,1);
}
// doesn't work
}
MyTimer.start();
looking for 1 last animator who can complete the last animation before I close the collaboration for good any participant?!
Any one know a way to delay multiple array objects from being added into my contsiner at the same time using as3?! I failed to use the timer to it, any idea ?
At 11/20/13 03:54 PM, KhanhCPham wrote: It needs more in-betweens but I thought its not worth adding in-betweens in a rough. It needs more movement in the hair also. Its not much but what the heck =P
gosh! I can really imagine a story just out of this short wip animation!
At 11/19/13 12:27 PM, Sam wrote:At 11/19/13 11:35 AM, milchreis wrote:He mentioned he can't use anything he hasn't been taught yet for this assignment.At 11/19/13 11:32 AM, A-Genius wrote: because our teacher have not tough us yetThat's why I provided the link.
someone who finally understand me! :D
At 11/19/13 09:20 AM, milchreis wrote:At 11/19/13 08:47 AM, A-Genius wrote: and my codes were 100% correct!Nobody denied that at any point in this thread.
You got the advice to use classes properly because it's the better way to do this.
Sadly, you ignore it.
I am not ignoring the advice it's just I don't want to use it because our teacher have not tough us yet and I can't add something we haven't study yet in the assignment it's better to stick with what the teacher want until we take classes!
At 11/19/13 08:42 AM, kkots wrote: I'd recommend to either actually re-write this whole code as a class or start monkeying around.
For example, debug your code using trace statements in the event handler functions.
didn't I just said it already ! I HAVE FIXED IT ALREADY! Oh I Actually done these two things to find the problem which is inside my buttons! Thanks for your help but I don't need any right now! Specially that I have already complete it! if I really had another problem I will try to re-write and debug the codes!
At 11/19/13 07:33 AM, Sam wrote:
:Learning to program is a lot of fun
don't let my friends catch you say that! they really hate programming! it's a specially adobe flash as3!
At 11/18/13 10:49 PM, HappyWhaleStudios wrote: milchreis is right, what you have isn't a class. I'm assuming you're using Flash to write this code, so in your library, right
didn't I just said I have completed this part I don't need to define class even thought it's useful! XD I don't really need to involve in classes right now because it was an assignment that I need to complete it without using anything about class just creating external class and work with it! and my codes were 100% correct! I just needed to change the movieclip that I have add inside my button into a graphic that's all! stop talking about class! I don't want to go that deep! we are in my class need to start simple stuff then get us deeper!playing with actual classes are too advanced for me right now!
At 11/18/13 08:03 PM, milchreis wrote:At 11/18/13 07:48 PM, A-Genius wrote: It's already exported class! for my MovieClip!That does not turn it into a valid class.
As I wrote in my previous post, dumping code into a file does not turn it into a class.
Again, understanding classes is crucial to do this.
I would have appreciated it a lot if you had given my suggestion a try.
my code was correct! the only problem was with the button I have created was using a problem because was inside a MovieClip.
At 11/18/13 07:40 PM, milchreis wrote:At 11/18/13 07:15 PM, A-Genius wrote: that code is the one inside class rooms_infoIt's not a class.
you don't understood the problem is that I have a movieclip called container_mc and I have another movieclip that is called rooms_info which I can call from my library using the exported class how can I call it to do my code inside room_info!
var roomclass:MovieClip = new rooms_info();
contain_mc.addChild(roomclass);
is it a wrong way to call the whole class?
At 11/18/13 07:40 PM, milchreis wrote:At 11/18/13 07:15 PM, A-Genius wrote: that code is the one inside class rooms_infoIt's not a class.
It's already exported class! for my MovieClip!
At 11/18/13 07:13 PM, milchreis wrote: You posted a lot of code, but not the class.
You should obviously put your code into the class that you associate with the mc.
If nothing's in the class, that's what happens.
that code is the one inside class rooms_info
I have MovieClip called rooms_info that contain these codes and export class rooms_info
import flash.display.Loader;
import flash.net.URLLoader;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.geom.ColorTransform;
stop();
var j = 0;
var pj = 1;
var tc = 0.1;
var myInterval:uint;
var XMLLoader:URLLoader= new URLLoader();
var imgLoader:Loader=new Loader();
var location_txt:TextField= new TextField();
var capacity_txt:TextField= new TextField();
var features_txt:TextField= new TextField();
//Declare Default Format for TextFields
var myFormat:TextFormat = new TextFormat ();
myFormat.align = TextFormatAlign.LEFT;
myFormat.size = 30;
myFormat.color = 0x921818;
myFormat.italic = true;
//Load Format Into TextFields
location_txt.defaultTextFormat=myFormat;
capacity_txt.defaultTextFormat=myFormat;
features_txt.defaultTextFormat=myFormat;
//AutoSize TextFields to Left Side
location_txt.autoSize=TextFieldAutoSize.LEFT;
capacity_txt.autoSize=TextFieldAutoSize.LEFT;
features_txt.autoSize=TextFieldAutoSize.LEFT;
XMLLoader.addEventListener(Event.COMPLETE,onLoaded);
//Declare Color Transform that Effect Alpha of Objects
var my_color:ColorTransform = new ColorTransform();
//Delcare Color Transform Function
function colorEffect():void{
tc+=0.1;
if(tc>=1){
clearInterval(myInterval);
}
my_color.alphaMultiplier=tc;
imgLoader.transform.colorTransform = my_color;
location_txt.transform.colorTransform = my_color;
capacity_txt.transform.colorTransform = my_color;
features_txt.transform.colorTransform = my_color;
}
//Change Image Size When Load
imgLoader.contentLoaderInfo.addEventListener(Event.INIT,onInit);
function onInit(evt:Event):void{
evt.target.content.width = 300;
evt.target.content.height = 180;
}
//Load XML and Image Function
function onLoaded(e:Event):void{
var myXML= new XML(e.target.data);
imgLoader.load(new URLRequest("rooms/r" + pj + ".jpg"));
imgLoader.x=110;
imgLoader.y=10;
addChild(imgLoader);
location_txt.text="Location: " + myXML.ROOM[j].@LOC;
capacity_txt.text="Capacity: " +myXML.ROOM[j].@CAP;
features_txt.text="Features:\n \t";
for(var i:uint = 0; i<myXML.ROOM[j].FAC.length(); i++ ){
features_txt.appendText(myXML.ROOM[j].FAC[i]+"\n \t");
}
location_txt.x = 150;
location_txt.y = 200;
capacity_txt.x = 150;
capacity_txt.y = 230;
features_txt.x= 150;
features_txt.y= 260;
this.addChild(location_txt);
this.addChild(capacity_txt);
this.addChild(features_txt);
}
XMLLoader.load(new URLRequest("rooms.xml"));
nb.addEventListener(MouseEvent.CLICK,nexth);
pb.addEventListener(MouseEvent.CLICK,Previoush);
function Previoush(e:Event):void{
var myXML= new XML(XMLLoader.data);
if(j!=0){
pj--;
j--;
my_color.alphaMultiplier=0.1;
tc=0.1;
removeChild(location_txt);
removeChild(capacity_txt);
removeChild(features_txt);
imgLoader.load(new URLRequest("rooms/r" + pj + ".jpg"));
imgLoader.x=110;
imgLoader.y=10;
addChild(imgLoader);
imgLoader.transform.colorTransform=my_color;
location_txt.text="Location: " +myXML.ROOM[j].@LOC;
capacity_txt.text="Capacity: " +myXML.ROOM[j].@CAP;
features_txt.text="Features:\n \t";
for(var i:uint = 0; i<myXML.ROOM[j].FAC.length(); i++ ){
features_txt.appendText(myXML.ROOM[j].FAC[i]+"\n \t");
}
location_txt.x = 150;
location_txt.y = 200;
capacity_txt.x = 150;
capacity_txt.y = 230;
features_txt.x= 150;
features_txt.y= 260;
this.addChild(location_txt);
this.addChild(capacity_txt);
this.addChild(features_txt);
location_txt.transform.colorTransform = my_color;
capacity_txt.transform.colorTransform = my_color;
features_txt.transform.colorTransform = my_color;
myInterval = setInterval(colorEffect,200);
}
else
{
pj=myXML.ROOM.length();
j=(myXML.ROOM.length()-1);
my_color.alphaMultiplier=0.1;
tc=0.1;
removeChild(location_txt);
removeChild(capacity_txt);
removeChild(features_txt);
imgLoader.load(new URLRequest("rooms/r" + pj + ".jpg"));
imgLoader.x=110;
imgLoader.y=10;
addChild(imgLoader);
imgLoader.transform.colorTransform=my_color;
location_txt.text="Location: " +myXML.ROOM[j].@LOC;
capacity_txt.text="Capacity: " +myXML.ROOM[j].@CAP;
features_txt.text="Features:\n \t";
for(i = 0; i<myXML.ROOM[j].FAC.length(); i++ ){
features_txt.appendText(myXML.ROOM[j].FAC[i]+"\n \t");
}
location_txt.x = 150;
location_txt.y = 200;
capacity_txt.x = 150;
capacity_txt.y = 230;
features_txt.x= 150;
features_txt.y= 260;
this.addChild(location_txt);
this.addChild(capacity_txt);
this.addChild(features_txt);
location_txt.transform.colorTransform = my_color;
capacity_txt.transform.colorTransform = my_color;
features_txt.transform.colorTransform = my_color;
myInterval = setInterval(colorEffect,200);
}
}
function nexth(e:Event):void{
var myXML= new XML(XMLLoader.data);
if(j!=(myXML.ROOM.length()-1)){
pj++;
j++;
my_color.alphaMultiplier=0.1;
tc=0.1;
removeChild(location_txt);
removeChild(capacity_txt);
removeChild(features_txt);
imgLoader.load(new URLRequest("rooms/r" + pj + ".jpg"));
imgLoader.x=110;
imgLoader.y=10;
addChild(imgLoader);
imgLoader.transform.colorTransform=my_color;
location_txt.text="Location: " +myXML.ROOM[j].@LOC;
capacity_txt.text="Capacity: " +myXML.ROOM[j].@CAP;
features_txt.text="Features:\n \t";
for(var i:uint = 0; i<myXML.ROOM[j].FAC.length(); i++ ){
features_txt.appendText(myXML.ROOM[j].FAC[i]+"\n \t");
}
location_txt.x = 150;
location_txt.y = 200;
capacity_txt.x = 150;
capacity_txt.y = 230;
features_txt.x= 150;
features_txt.y= 260;
this.addChild(location_txt);
this.addChild(capacity_txt);
this.addChild(features_txt);
location_txt.transform.colorTransform = my_color;
capacity_txt.transform.colorTransform = my_color;
features_txt.transform.colorTransform = my_color;
myInterval = setInterval(colorEffect,200);
}
else
{
pj=1;
j=0;
my_color.alphaMultiplier=0.1;
tc=0.1;
removeChild(location_txt);
removeChild(capacity_txt);
removeChild(features_txt);
imgLoader.load(new URLRequest("rooms/r" + pj + ".jpg"));
imgLoader.x=110;
imgLoader.y=10;
addChild(imgLoader);
imgLoader.transform.colorTransform=my_color;
location_txt.text="Location: " +myXML.ROOM[j].@LOC;
capacity_txt.text="Capacity: " +myXML.ROOM[j].@CAP;
features_txt.text="Features:\n \t";
for( i = 0; i<myXML.ROOM[j].FAC.length(); i++ ){
features_txt.appendText(myXML.ROOM[j].FAC[i]+"\n \t");
}
location_txt.x = 150;
location_txt.y = 200;
capacity_txt.x = 150;
capacity_txt.y = 230;
features_txt.x= 150;
features_txt.y= 260;
this.addChild(location_txt);
this.addChild(capacity_txt);
this.addChild(features_txt);
location_txt.transform.colorTransform = my_color;
capacity_txt.transform.colorTransform = my_color;
features_txt.transform.colorTransform = my_color;
myInterval = setInterval(colorEffect,200);
}
}
I tried to call the class in another movieclip container
but it only shows my buttons the images that are external doesn't show
var roomclass:MovieClip = new rooms_info();
contain_mc.addChild(roomclass);
contain_mc.x=0;
contain_mc.y=0;
At 11/18/13 02:20 AM, Celshaded wrote: I wasn't trying to pound/defame him, I was just giving an honest suggestion. Like I said, not trying to be a dick.
Truth hurt you know! Just give him what he like to hear you know, let him live in his own fantasy world were everyone is looking to take his idea's in open arms while sacrificing their power just to make him happy! and he lived happily ever after!