Flash

C++, C#, Java, PHP, ect...
Post Reply
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

i have flash mx 2004. No, I cant open it. "Unexpected File Format" Can you place where what piece of code goes where, so when I place it, I know where it goes...I would appreciate it
Image

Image
User avatar
Agent
Posts: 164
Joined: Tue Jul 14, 2009 5:22 am

Re: Flash

Post by Agent »

Yup nice stuff, yeah Spirit their are LOADS of tutorials out there - you can google most and find everything you need (also try http://www.flashkit.com)
- Except of course how to build Flash/php mmo's hehe :P - Most likely something me and halls are going to work on in the not too distant future.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

Agent wrote:Yup nice stuff, yeah Spirit their are LOADS of tutorials out there - you can google most and find everything you need (also try http://www.flashkit.com)
- Except of course how to build Flash/php mmo's hehe :P - Most likely something me and halls are going to work on in the not too distant future.
Yeah I been searching, thats how I found tutorialized, before I was told about it. I cant wait too see your tutorials.
Image

Image
User avatar
neronix17
Posts: 317
Joined: Sat Aug 01, 2009 5:01 am

Re: Flash

Post by neronix17 »

as i mentioned before http://www.tutorialized.com seems to be the best one to me, there are alot more for flash than anything else ive tried anyway. Anywhoo, heres the code for the navigation, just have a layer at the very top, only need one frame for each layer, after the code is what objects you will need to make...

Code: Select all

/*Navigaiton Engine*/
/*Setup*/
var maxspeed:Number = 4;
var startAngle:Number = 0;
var steeringFriction:Number = .50;
var groundFriction:Number = .98;
var speed:Number = 0;
var steering:Number = 0;
var moveX:Number = 0;
var moveY:Number = 0;
var radiance:Number = ((startAngle-90)/180)*Math.PI;
//
/* Create Map */
var map_mc:MovieClip = this.attachMovie("map_mc","map_mc",this.getNextHighestDepth());
map_mc._x = 0
map_mc._y = 0
//
/* Create Player */
var player_ship_mc:MovieClip = this.attachMovie("player_ship_mc","player_ship_mc",this.getNextHighestDepth());
player_ship_mc._x = Stage.width/2;
player_ship_mc._y = Stage.height/2;
//
/* Main Game Loop */
player_ship_mc.onEnterFrame = function() {
	run();
};
function run():Void {
	if (speed<0) {
		speed = 0;
	}
	// left    
	if (Key.isDown(Key.LEFT)) {
		steering -= 0.2;
	}
	// right    
	if (Key.isDown(Key.RIGHT)) {
		steering += 0.2;
	}

	// maxsteering
	if (steering > 1.5){
	steering =  1.5;
	}
	if (steering < -1.5){
	steering = -1.5;
	}

	// accelerate
	if (Key.isDown(Key.UP) && speed<maxspeed) {
		speed += 0.5;
	}
	// brake    
	if (Key.isDown(Key.DOWN)) {
		speed *= 0.75;
	}
	// friction    
	speed *= groundFriction;
	// ideal changes
	var idealXMovement = speed*Math.cos(radiance);
	var idealYMovement = speed*Math.sin(radiance);
	// real change
	moveX += ((idealXMovement-moveX)*steeringFriction);
	moveY += ((idealYMovement-moveY)*steeringFriction);
	// update
	//trace("moveX "+moveX);
	//trace("moveY "+moveY);
	map_mc._x += moveX;
	map_mc._y += moveY;

	// rotate
	radiance += (steering*speed)*.025;
	player_ship_mc._rotation = radiance*180/Math.PI;
	steering -= (steering*0.1);
}
for the background area you need to make a movie clip named "map_mc"

for the ship you will need to call it "player_ship_mc" you should not place either of these on the stage, just have them in the library.

For the HUD, just have it sitting where you need it on the layer below the actionscript (to place AS on a frame right click then choose action)

The code may not work in MX 2004 as it only has AS2 and I dont know if this code is AS2 or AS3, from what i remember it is AS2 so you should be fine, either way Id suggest downloading the trial for CS4 anyway, it lasts 30 days and that should be enough to do something like this.

EDIT: everything in the first area of code can be played with to make the ship move differently, so have a go at doing that so you have what you need.
This isnt just a gimp mask...This is an S&M gimp mask...
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

I maybe confused. On the top layer, I named it "actions" and placed that code there. I placed the sprite(ship) down, made it a movie clip, and then deleted it from the stage, did the same with the background. When I run it, I get a black screen, nothing else.


EDIT: The background and ship are in the library
Image

Image
User avatar
neronix17
Posts: 317
Joined: Sat Aug 01, 2009 5:01 am

Re: Flash

Post by neronix17 »

forgot a bit you need to do

right click the ship in the library, choose properties, click advanced if its not already expanded, then tick the box which says "export for actionscript"
then do the same for the map and make sure that when you converted to a symbol that you chose the center box on the little grid of 9 boxes. if you cant change it then do this:

1. drag them onto the stage
2. right click and break apart
3. delete them from the library
4. convert them to symbols again making sure to change the properties as needed

sorry if this is confusing, im confusing myself just reading it over but if i change it il make it worse, hope this helps
This isnt just a gimp mask...This is an S&M gimp mask...
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

lol...its cool.

I got it all to show, but now my map is all over the place...it places the map down on the far left, not centered...

what size should the map be? The map is centered to the ship, on its right border.


EDIT: When I press the down key and left or right, it quits moving...only up seems to work. I aim down, the map scrolls right. Aim right, map goes up, aim up, map goes left, aim left map goes down.
Image

Image
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

Agent wrote:
SpiritWebb wrote:Is there a way when importing into flash, to make the background transparent? I have it as a .png file. I imported a ship to use as a sprite, and can't figure out how to get rid of the background, leaving just the ship.
Easy way to do it -

Select the image on the stage: Go to Modify > Bitmap > Trace Bitmap - fiddle with the parameters to get the level of detail you want left in it ... then simply select the unwanted parts of the image such as white BG with your mouse and hit delete to get rid of them :D easy.

Agent: I went and tried it your way, and when I click modify > bitmap I cannot select trace bitmap. Its there, just not selectable.
Image

Image
User avatar
Agent
Posts: 164
Joined: Tue Jul 14, 2009 5:22 am

Re: Flash

Post by Agent »

SpiritWebb wrote:
Agent wrote:
SpiritWebb wrote:Is there a way when importing into flash, to make the background transparent? I have it as a .png file. I imported a ship to use as a sprite, and can't figure out how to get rid of the background, leaving just the ship.
Easy way to do it -

Select the image on the stage: Go to Modify > Bitmap > Trace Bitmap - fiddle with the parameters to get the level of detail you want left in it ... then simply select the unwanted parts of the image such as white BG with your mouse and hit delete to get rid of them :D easy.

Agent: I went and tried it your way, and when I click modify > bitmap I cannot select trace bitmap. Its there, just not selectable.
Make sure you have not "broken" (with the break apart method) it apart - you need the original image straight from your library on stage - selected and then it should normally work.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Flash

Post by SpiritWebb »

Thanks Agent, worked that time, so much cleaner
Image

Image
Post Reply

Return to “Coding”