Dustwing
7 posts
|
So, I keep getting this after double and triple checking that my lines match…it’s been a long day and I might just be blind but I’md like to figure out what’s up XP
“Classes may only be defined in external ActionScript 2.0 class scripts” souce- “class Ship extends MovieClip”
also “The name of the class ‘Ship’ conflicts with the name of another class that was loaded, ‘Ship’” from the same line.
Also in lines 2 and 28 it’s got issues with the brackets…gah XP Can anyone help me out?
here’s the full script as it is written in the Actions menu.
class Ship extends MovieClip
{
var velocity;
function onLoad()
{
velocity = 10;
}
function onEnterFrame()
{
if( Key.isDown(Key.RIGHT) )
{
_x = _x + velocity;
}
if( Key.isDown(Key.LEFT) )
{
_x = _x – velocity;
}
if( Key.isDown(Key.UP) )
{
_y= _y – velocity;
}
if( Key.isDown(Key.DOWN) )
{
_y = _y + Velocity
}
}
}
I actually did get the ship to scroll off of the screen after much mucking about and eventually copying that portion of the script to the actions menu as accessed through the movie clip and not the way Kon has you get to the window in the shootorials. This is my first time in flash, I know photoshop inside and out though so at least some of the menus make sense XP
Also, I’m not using any of the art that came with the shootorial, and for the main ship you controll I’d like to use an animated sprite. It doesnt need to be super fancy and change animations based on what arrow key you’re holding down, more like a short animated gif loop.
|
|
|
Jotamota
254 posts
|
Hav you saved this script as Ship.as and saved in the same folder that is your graphics and stuff of the game?
|
|
|
Dustwing
7 posts
|
yep :) Everything’s in the same folder
|
|
|
Jotamota
254 posts
|
Ooh. Man dont put this in action, create a new AS file and put that code! Save as Ship.as
|
|
|
Dustwing
7 posts
|
mmm :/
Still no dice. Just in case I had some wierd thing happening in that file I restarted a new file and copied over the script. Nothing XP So..I figured I’d try to see if maybe my install was weird and tried the next part to make the background scrolling, which worked just fine! So…I now have a stationary ship and a scrolling background XP
Here’s a rapidshare link to the file and files associated with it, http://rapidshare.com/files/181524733/Dustwings_Shooter.zip.html I know the ship is a dragon and I coulda named it dragon but for ease of using the tutorials I’m keeping the names the same :) The art isnt final, just quick placeholders to get stuff working- just a 10 min painting and a matte painting I had on my HD from an earlier matte painting experiment.
|
|
|
Jotamota
254 posts
|
I will download the file and take a look. Try to relook the shootorial 1 in the mean while.
|
|
|
Jotamota
254 posts
|
I’ve done it!
First, replace your entire ship script for this:
class Ship extends MovieClip
{
var velocity;
function onLoad()
{
velocity = 10;
}
function onEnterFrame()
{
if( Key.isDown(Key.RIGHT) )
{
// The line below means that the coordnate x is equal to x plus velocity (_x += velocity). -= means that _x is equal to _x minus speed. Got it?
_x += velocity;
}
if( Key.isDown(Key.LEFT) )
{
_x -= velocity;
}
if( Key.isDown(Key.UP) )
{
_y -= velocity;
}
if( Key.isDown(Key.DOWN) )
{
_y += velocity;
}
}
}
Then go in your fla file and delete the ship symbol from the library. Put the image file in the stage again where ever you want and then select the image and go on “Modify > Convert to Symbol”. Then put in the name box “Ship”, in “Registration” select the center box (of 9), click in “Export to ActionScript” and automatic it will select “Export in Frame 1”. A box named Class will be clear. Put it “Ship” too. Then click OK. Now, select the ship picture again in stage and go in “Properties” on your right. Put the instance name to “Ship”. It should work!
|
|
|
Dustwing
7 posts
|
Hm, did as you said, still no cigar. XP Thanks for your help, I’m starting to think the flash gods disapprove of this venture.
So, in the library veiw, should I have separate entries for the .png and the movie clip ship(With a gear icon)? I’m wondering if the point that the movie clip is making is mobile but not attached to the graphic for whatever reason. I’ve created the movie clip by right clicking the image and converting it to a symbol every time, is that correct or should I be doing it in a menu and manually connecting the two?
|
|
|
Jotamota
254 posts
|
The symbols are correct. Over check shootorial 1 and see your code and theirs.
|
|
|
Jotamota
254 posts
|
For me it worked the game.
|
|
|
Dustwing
7 posts
|
I believe you, I’m positive your code works..but I’m starting to question my copy of flash XP I’m gonna re re re re look over the shootorial and see if I can run something to check the install of flash. :) Thanks a ton! I’ll figure it out.
|
|
|
Jotamota
254 posts
|
Ok, disintall and install your flash. Save your game files in other folder. What Flash do you use?
|
|
|
Draco18s
5885 posts
|
Have you checked to make sure that Flash is set to use ActionScript 2 and not ActionScript 3? File → Publish Settings → “swf” tab → “ActionScript” version dropdown.
|
|
|
khixan
70 posts
|
Dustwing – I had the EXACT same problems. After almost 3 hours of messing with it, I finally figured it out. It’s not the code. It’s the order in which the tutorial has you creating things (and you also should export them). Here’s how I got it to work.
Make your ship graphic. If you do it in CS4, make sure you export it as a png.
Make your background graphic. I used a jpg for background. Again, if you did it in CS4, export it.
Create the two action script code files. Make sure the file name and class names match up.
Now go in CS4 and start a new Flash File (Action Script 2.0). That code will not work in 3.0 for a number of reasons. I don’t have 3.0 code equivalent figured out yet. (I’m a newbie to this language myself. Ask me a VB.NET or TSQL question = no problem.)
Follow the shootorial instructions for importing background to stage and convert to movie clip. Be sure to check the actionscript box and key in your class name. Export the movieclip. Save and publish. If it all worked, in properties you should now see “instance of:yourclassname”. You can set <instancename> to whatever. If I understand this, that’s just the variable name for this instance of that class.
Add the ship layer, rinse and repeat for the ship. Now it should work. If it doesn’t, shoot me a message. – Khixan
|
|
|
stratoff
2 posts
|
had same prob, was reading forums, found answer bout Windows clock. so i corrected time in my Windows clock from wrong to present time, and recompiled Shootorial.fla. all work now :>
|
|
|
cguwilliams
2 posts
|
I tried everything here and while it all made my code better, imho, what finally worked was placing a keyframe into frame 1 on the timeline.
|
|
|
aldrin
2081 posts
|
Can I BUMP this?
EDIT:
STILL DIDNT WORKED
|
|
|
sierraleone
1 post
|
Ok, i realize that this is a way old topic, but in the case that someone has this problem again, the solution is simple: SAVE before testing movie.
|
|
|
LarryElwell
1 post
|
Thanks. but in what folder?
|
|
|
UnknownGuardian
6221 posts
|
The same folder as the rest of your game.
|