This is the first one.
Displaying a Block
- 1. Open a new Flashfile(ActionScript 3.0)
- 2. Create a rectangle and convert it to a movieclip
Using the Rectangle tool create a new rectangle,Use selection tool and group the rectangle together
Right click the rectangle and select Convert to Symbol..
In the Convert to Symbol dialog box Enter Block in the Name: textfield
Select the radio button for Movie Clip
Click the Advanced button
Under Linkage select the Export for ActionScript checkbox
(this will also check the Export in first frame button Leave it checked)
Click Ok
ActionScript Class warning message box will pop up Select OkAfter converting to symbol make sure your stage is clear
- 3. ActionScript Code
Select frame 1 right click and select Actions from drop down menu or press F9 to open Actions window In the Actions window type
import flash.display.*;
import flash.events.Event;This basically lets flash know that we will be working with display objects and events so it can load the code to handle these things.
- Next we want to define a variable to represent our display object in this case the block we created
var myBlock:DisplayObject= new Block()
- At this point we have a variable(myBlock) representing our display object
We can now use ActionScript to alter the display object properties of our variable Let us set the starting point for myBlock before we draw it to the screen
myBlock.x=300
myBlock.y=200
- Now we create myBlock on screen
this.addChild(myBlock)
- Publish preview and you should now have a block sitting on screen at the (X,Y) position that you specified.
This may not seem like much right now, however we now have the ability to change properties of our object with ActionScript code
Go check out his page for the others.