ForumsProgramming ForumHelp with as3 coding? please?

7 3475
Theheyjude
offline
Theheyjude
114 posts
Nomad

so first off im using this tutorial and copying its code so heres the link of that site. http://gamedev.michaeljameswilliams.com/2008/09/17/avoider-game-tutorial-1/ so im only on the first part (of 12) and right now im suppose to have a image start at the top the screen (actually completely off) and come down slowly down the screen. (i know its super simple) so heres all my coding so far

Its in two parts: part one:

package
{
import flash.display.MovieClip;
public class Enemy extends MovieClip
{
public function Enemy ()
{
x=100;
y=0;
}

public function moveDownABit():void
{

y=y+8;
}

}

}

part two:

package
{
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;

public function AvoiderGame Extends MovieClip
{
public var enemy:Enemy;
public var gameTimer:Timer;

public function AvoiderGame()

{
enemy=new Enemy();
addChild( enemy );

gameTimer = new Timer( 25 )
gameTimer.addEventListener(TimerEvent.TIMER, moveEnemy );
gameTimer.start();

}
public function moveEnemy(timerEvent:TimerEvent ):void
{
enemy.moveDownABit();
}
}

}

so im pretty sure the problem lies within part two, anywho heres the problem. i started of coding for it to simply be at the top of the screen at the start. then i coded for it to slowly come down. but didn't move... it simply acted like all that coding for it to come down didn't even happen. like theres no error or anything it just doesn't do anything. so i presume i left something out or something. can anyone help me?

  • 7 Replies
Theheyjude
offline
Theheyjude
114 posts
Nomad

ok ive been looking back at this and i noticed this is a bit much and quite confusing. but good news! ive been working on it and i made some progress! i got a error! lol at least i have something to work with now and it will actually change! so what i did is i noticed that my moveclip ive been trying to move, changed its name magical to some giberish. so i changed it back to Enemy, also i made sure that all Enemys were spelled right/captilized and now i have this:
error 1046: Type was not found or was not a compile-time constant: Enemy

and when i try and test it the movieclip just doesn't do anything so any help now?

Theheyjude
offline
Theheyjude
114 posts
Nomad

ok i feel like a idiot talking to myself so i searched on the internet and found this http://www.eddieoneverything.com/flash-9-as3/as3-error-1046-type-was-not-found-or-was-not-a-compile-time-constant.php
this guy says he has the same problem and he found the solution. he duplicated the object in question then used to swap tool to.. well.. swap it. and it worked. so i did that and i try and run it and it whent back to being halfway cut off at the top and not doing anything. then i relized that it didn't have a instance name so then i put in Enemy as the instance name and i get the error talked about in the above post... im starting to get very anoyed. i would start over and delete everything and just do it all again if i think that that would fix it. anyone have any ideas?

Theheyjude
offline
Theheyjude
114 posts
Nomad

ok im reaaaallllly sorry but im just a kid and this is my first game and im a spaz and go ahead and hate me for constantly posting on my own question but i did as i said i did in the above post but anywho i go into properties for my movieclip and i go down see that the class name is Enemycopy and im like hmmm so i try and erase copy to see if it changes anything but it says i can't cause that name is used in the library already so i delete the old usless movieclip and change it to Enemy and then i click on the validate and it says it knows were it is and if i click on the pencil it takes me to the right as3 file and yay so i fixed the error 1046 problem. now the only problem is that it REFUSES to let me change the x and y starting positions anymore (wierd right? like ill change y from 0 to -15 so the other half of my 30 pixel image will hide behind the screen at the start. but it doesn't change anything. and it also refuses to listen to me when i tell it to move down! remember to read all my long and boring posts to find any info you need about my code or were im getting the code from. and what not. i would honestly give my first born child to anyone who could help me with this evil problem i have. kk thanks im going to leave it be and walk away for the rest of the day. otherwise ill go insane

gone3d
offline
gone3d
17 posts
Nomad

i went to the site, downloaded the sample files at the link at the bottom and it all worked fine for me - maybe you should do the same and see if you can get it to work for you.

Then compare your copy vs. his

D

25wes25
offline
25wes25
1,584 posts
Nomad

just stick to youtube and the well known sites

Theheyjude
offline
Theheyjude
114 posts
Nomad

Gone3d:Yea thanks but i sorta gave up on that and ive been working on my own avoider style game but get this... with my own code! lol thanks though

25wes25:yea i think ill do that from now on

25wes25
offline
25wes25
1,584 posts
Nomad

think simple and effective like useing instance names

Showing 1-7 of 7