Friday 23 September 2011

Lets Bring It Down! (Flash More ActionScript 3 coding)

Hello again to another Blogger update on the Interactive Media Course at Weymouth College!

Today's update is about learning more AS3 codes in Adobe Flash. We have been learning how to create basic shapes and be able to move them around with the mouse. Unfortunately for me, I was only able draw a shape but not able to do the Drag and Drop feature. Here is the code for drawing a simple shape:

var mc:MovieClip= new MovieClip();
mc.graphics.beginFill (0xff0000);
mc.graphics.drawCircle(50,50,50);
mc.x=80;
mc.y=60;
addChild(mc);


Result:




















This was what I able to draw with this coding. After that, we had to import an image onto the canvas, again using only ActionScript but first we had to save the image into our folder, then import the image into the lybrary, rather than straight onto the canvas, then write in the code. This is how it turned out:  

var mc:MovieClip= new MovieClip();
mc.graphics.beginFill (0xff0000);
mc.graphics.drawCircle(50,50,50);
mc.x=80;
mc.y=60;
addChild(mc);


var MC:Marneus_Calgar = new Marneus_Calgar(100,100);
var myImage:Bitmap = new Bitmap(MC);
addChild(myImage);
setChildIndex(myImage,0)



Yeah, as you can see, I'm a big Warhammer 40000 fan! Anyway, this is what resulted in the code. Straight after that, we had to resize the image we imported. Here's what I did:



var mc:MovieClip= new MovieClip();
mc.graphics.beginFill (0xff0000);
mc.graphics.drawCircle(50,50,50);
mc.x=80;
mc.y=60;
addChild(mc);


var MC:Marneus_Calgar = new Marneus_Calgar(100,100);
var myImage:Bitmap = new Bitmap(MC);
addChild(myImage);
setChildIndex(myImage,0)
myImage.scaleX=0.5
myImage.scaleY=0.5





















Result! So far so good. I'm sort of getting the hang of using AS3 but there is still a lot more I need to learn, especially for when I need to start making my game... Okay fianlly, we then had to create a movie clip without converting objects into symbols, then draw a shape within that movie clip. Here's the coding:

var mc:MovieClip= new MovieClip();
mc.graphics.beginFill (0xff0000);
mc.graphics.drawCircle(50,50,50);
mc.x=80;
mc.y=60;
addChild(mc);


var MC:Marneus_Calgar = new Marneus_Calgar(100,100);
var myImage:Bitmap = new Bitmap(MC);
addChild(myImage);
setChildIndex(myImage,0)

myImage.scaleX=0.5
myImage.scaleY=0.5


var cc:circle = new circle();
addChild(cc);


I would insert a picture at this point but there's no point because it's made no difference to the image. There's basically a red circle in the movie clip but it didn't show up when I played the file.

Anyway, That's it for me today. 

No comments:

Post a Comment