Yes, in FlashDevelop you don't have access to the .fla, but you still can port timeline code into FlashDevelop. To do this, put all var X:Y
statements that are outside functions above the line public function Main()
, regardless of where do they appear. Then, put all functions below the finish of init()
function declaration. Any other code should be put into init()
. In your case, the file should look like this:
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* @author Duncan John Bunting
*/
public class Main extends Sprite
{
//setting vars to step in for turns and special blocks
var S:String = 'START';
var F:String = 'FINISH';
var U:String = 'UP';
var R:String = 'RIGHT';
var D:String = 'DOWN';
var L:String = 'LEFT';
var startDir:String;//the direction the enemies go when they enter
var finDir:String;//the direction the enemies go when they exit
var startCoord:int;//the coordinates of the beginning of the road
var lvlArray:Array = new Array();//this array will hold the formatting of the roads
//the names of these variables explain what they do
var currentLvl:int = 1;
var gameOver:Boolean = false;
var roadHolder:Sprite = new Sprite();//create an object that will hold all parts of the road
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
// stop(); MovieClip functions are not supported for Main
lvlArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,R,1,1,D,0,0,R,1,1,D,0,0,R,1,1,D,0,0,
0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,
0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,
S,D,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,R,1,F,
0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,
0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,
0,R,1,1,U,0,0,R,1,1,U,0,0,R,1,1,U,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
];
addChild(roadHolder);//add it to the stage
//run these functions at the start
makeRoad();
startGame();
}
function makeRoad():void{
var row:int = 0;//the current row we're working on
var block;//this will act as the block that we're placing down
for(var i:int=0;i<lvlArray.length;i++){//creating a loop that'll go through the level array
if(lvlArray[i] == 0){//if the current index is set to 0
block = new EmptyBlock();//create a gray empty block
block.graphics.beginFill(0x333333);
block.graphics.drawRect(0,0,25,25);
block.graphics.endFill();
addChild(block);
//and set the coordinates to be relative to the place in the array
block.x= (i-row*22)*25;
block.y = row*25;
} else if(lvlArray[i] == 1){//if there is supposed to be a row
//just add a box that will be a darker color and won't have any actions
block = new Shape();
block.graphics.beginFill(0x111111);
block.graphics.drawRect(0,0,25,25);
block.graphics.endFill();
block.x= (i-row*22)*25;
block.y = row*25;
roadHolder.addChild(block);//add it to the roadHolder
} else if(lvlArray[i] is String){//if it's a string, meaning a special block
//then create a special block
block = new DirectBlock(lvlArray[i],(i-row*22)*25,row*25);
addChild(block);
}
for(var c:int = 1;c<=16;c++){
if(i == c*22-1){
//if 22 columns have gone by, then we move onto the next row
row++;
}
}
}
}
function startGame():void{//we'll run this function every time a new level begins
//right now we don't have any code
}
}
}
The harder part will come when you'll be told to draw something into your .fla and assign names for it. This is still portable into FD, but instead of drawing, you'll have to code all the draw routines into FD using a class that extends Sprite
if layered, or Shape
if not, and use graphics
property to draw simple primitives. Note that you can't directly set anchor point in FD, so your coordinates should be aligned the preset anchor point of (0,0).