Posted: May 27th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »
Sets up the ground, origin point, and basic camera movement. Meant to be used as a document class.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| package {
import flash.display.*;
import flash.events.*;
import org.papervision3d.view.BasicView;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.events.InteractiveScene3DEvent;
import gs.TweenLite;
import gs.easing.*;
public class PopupMain extends MovieClip {
private var _w:BasicView; // world, sets up BasicView
private var _origin:Plane; // origin
private var _ground:Plane; // ground
private var _destX:Number;
private var _destY:Number;
public function PopupMain():void {
initMaterials();
initPapervision();
}
private function initPapervision():void {
_w = new BasicView(stage.stageWidth, stage.stageHeight, false, true);
_origin = new Plane(null, 30, 30);
_ground = new Plane(null, 1200, 1200, 6, 6);
_ground.rotationX = 90;
// _ground.rotationY = 45;
addChild(_w);
_w.scene.addChild(_origin);
_w.scene.addChild(_ground);
addEventListener(Event.ENTER_FRAME, onRender);
}
private function initMaterials():void {
}
private function onRender(e:Event):void {
_destX = (mouseX - stage.stageWidth / 2) * 2;
_destY = (stage.stageHeight - mouseY) * 2;
if (mouseY < 100) {
_destX = 0;
_destY = 500;
}
_w.camera.x += (_destX - _w.camera.x) / 4;
_w.camera.y += (_destY - _w.camera.y) / 4;
_w.singleRender();
}
}
} |
Posted: May 26th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| // p is planet, instance name "p"
// c is center, instance name "c"
// rotation about the center
var myRadius:Number = 100;
var mySpeed:Number = 7;
var xCenter:Number = c.x;
var yCenter:Number = c.y;
var myDegree:Number = 0;
addEventListener(Event.ENTER_FRAME, orbit);
var myAngle:Number = 45;
var myRadian:Number = myAngle * (Math.PI / 180);
function orbit(e:Event):void {
p.x = (myRadius * Math.cos(myRadian));
p.y = (myRadius * Math.sin(myRadian));
myDegree += mySpeed;
myRadian = (myDegree/180)*Math.PI;
p.x = xCenter + Math.cos(myRadian) * myRadius;
p.y = yCenter - Math.sin(myRadian) * myRadius;
} |
Posted: April 3rd, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »
Here a simple way to get a snapshot on a movie clip in Flash.
+flash
you can get the JPGEncoder here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| import com.adobe.images.JPGEncoder;
var enc:JPGEncoder = new JPGEncoder(90);
var file:FileReference = new FileReference();
stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void{
capture();
}
// video is the instance name of whatever you want to capture
var bit:BitmapData = new BitmapData(video.width, video.height, false, 0x000000);
addChild(new Bitmap(bit));
var counter:int = 0;
function capture():void {
bit.draw(video);
counter++;
// save out each screen capture
// file.save(enc.encode(bit), "myImage_" +counter+".jpg");
} |
Posted: March 25th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »

Right now this has an XMLLoader class and class for navigation. Am working to make a better one that extends different ways images can be displayed. The content is some collages that I’ve been working on.
( +flash )
Posted: February 26th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »

some navbar/gallery i’ve been working on: XMLLoader (class), Navigation (class), document class (constructor).
( +flash )
Posted: February 17th, 2009 | Author: Janice | Filed under: Uncategorized | Tags: as3, flash | No Comments »
1
2
3
| private var container:MovieClip = new Container();
private var content:MovieCLip = new Content();
// where container is your stage, and content is the material you want to center |
Initialize your stage listeners/event listeners.
1
2
3
4
5
6
7
8
9
10
11
12
| function init() {
stage.align=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, updateSize);
stage.dispatchEvent(new Event(Event.RESIZE));
container.x = 0;
container.y = 0;
} |
updateSize gets called every time the stage gets resized.
1
2
3
4
5
6
7
8
9
10
11
| function updateSize(e:Event) {
// make container width/height equal to stage.width/height
container.width = stage.stageWidth;
container.height = stage.stageHeight;
//center content
content.x = stage.stageWidth/2 - content.width/2;
content.y = stage.stageHeight/2 - content.height/2;
} |
Posted: February 13th, 2009 | Author: Janice | Filed under: Uncategorized | Tags: as3, flash, tweenlite | No Comments »
You can choose to overwrite tweens:
1
2
| TweenLite.to(mc, 1, {x:100, y:200});
TweenLite.to(mc, 1, {x:300, overwrite:2}); //only overwrites the "x" property in the previous tween |
you can pass 0, 1, 2, or 3 to overwrite.
According to GreenSock’s site:
0 (NONE): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any tweens with overlapping properties, otherwise they’ll conflict with each other.
1 (ALL): (this is the default unless OverwriteManager.init() has been called) All tweens of the same object are completely overwritten immediately when the tween is created.
2 (AUTO): (used by default if OverwriteManager.init() has been called) Searches for and overwrites only individual overlapping properties in tweens that are active when the tween begins.
3 (CONCURRENT): Overwrites all tweens of the same object that are active when the tween begins.
Posted: February 13th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »
Basic line drawer: (preview link)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| // add stage listeners
stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
function onDown(e:Event):void {
graphics.moveTo(mouseX, mouseY);
addEventListener(Event.ENTER_FRAME, onLoop);
}
function onUp(e:Event):void {
removeEventListener(Event.ENTER_FRAME, onLoop);
}
// bit shifting colours
function onLoop(e:Event):void {
graphics.lineStyle((Math.random()*45), Math.random()*0xFFFFFF >> 23, Math.random(), true, "normal"); // blue=black
graphics.lineTo(mouseX, mouseY);
} |
Posted: February 13th, 2009 | Author: Janice | Filed under: Uncategorized | No Comments »
A button component in MXML:
1
| <mx:Button x="10" y="10" label="myButton" id="newButton" click="checkForm()"> |
MXML is converted to AS3 when you compile it. MXML is used to define the structure of your Flex application, and Actionscript is used to define behavior.
Posted: February 13th, 2009 | Author: Janice | Filed under: Uncategorized | Tags: as3, flash, tweenlite | No Comments »
TweenLite is a small and fast tweening engine for Flash Player 9 (AS3). TweenLite only adds about 3KB to published .swfs.
Somewhere above your constructor:
1
2
| import gs.TweenLite;
import gs.easing.*; |
Basic TweenLite function:
TweenLite.to tweens from an initial point to that point that you define. Position the clip on the stage where/how you want the tween to start.
1
2
| TweenLite.to(circle, 1, {x:300, ease:Sine.easeIn});
// TweenLite.to(moviecliptotween, timeinsec, { .. properties... }); |
TweenLite.from does the opposite. Position the clip on the stage where you want the tween to end, and define where/how you want the tween to begin:
1
| TweenLite.from(circle, 1, {y:300, ease:Sine.easeIn}); |
Useful notes:
TweenLite has an onComplete function that you can map behaviour to upon finishing a tween.
1
2
3
4
5
| TweenLite.to(circle, 1, {onComplete:doneTween};
...
function doneTween():void {
// finished tween, now do this
} |