RSS
email
4

Attach MovieClip in AS3:



In Actionscript 3.0 attachMovie(); function does not exist, but there
are some ways new ways to do that...

Create a movieClip in the IDE.. (name: Star)

Open library (ctrl+L)..and click linkage..

Select Export for ActionScript..(Note: We can give Any name in the identifier that is the linkage name)



Open Actions panel

Code follows:

var mc:Star=new Star();
mc.x=100;
mc.y=100;
addChild(mc);

Where Star is the linkage name..and its important to add it in the displaylist
Read more
13

Embedding Font in Flash CS3(using AS3)



Here is the way to embed fonts in AS3.0, and the code explanation follows

import flash.text.*;
var font:Font1=new Font1();
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false
addChild(txt);


Code Explanation:

Importing all the necessary classes..
import flash.text.*;

Creating new instance of the font from library..
var font:Font1=new Font1();
Here Font1 is the Linkage name given in the library



Creating TextFormat
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24

Note:
font is the instance name of Linkage name

Creating text field and applying the TextFormat created above
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false

Adding the TextField to the DisplayList
addChild(txt);
Read more
0

Flash supported Firefox plugins



FlashTracer 2.0.0 :

While running any .swf Flash file in your browser you can see all the output generated by the "trace" flash functions in this sidebar component...

While running any .swf Flash file in your browser you can see all the output generated by the "trace" flash functions in this sidebar component.
You *NEED* the flash player debug version to run this extension correctly:
http://download.macromedia.com/pub/flashplayer/updaters/9/flashplayer_9_plugin_debug.exe

Works with:
Firefox: 2.0a1 – 2.0.0.*

Download

Flash Switcher (win)

Switch between various flash plugins or remove current plugin. It is installed in the statusbar of your browser. when you click on it a popup menu appears showing different options: which flash player version to install (2,3,4,5,6,7,8,9) or if you...

Switch between various flash plugins or remove current plugin. It is installed in the statusbar of your browser. when you click on it a popup menu appears showing different options: which flash player version to install (2,3,4,5,6,7,8,9) or if you want to remove the currently installed one.

Download
Read more
4

Handling Mouse Events for Planes(Papervision 3d)



Here contains the code for handling mouse events in papervision 3d using flash cs3..

Code contains explanations ..

// import the necessary files..
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
//dictionary objects holds objects as key
var planebycontainer:Dictionary=new Dictionary();
var container:MovieClip=new MovieClip();
container.x=stage.stageWidth*0.5;
container.y=stage.stageHeight*0.5;
addChild(container);
this.frameRate=40;
//creating scene basic for papervision; among multiple scenes Scene3D is basic one
var scene:Scene3D=new MovieScene3D(container);
//camera to see objects
var camera:Camera3D=new Camera3D();
//initial camera zoom is (0,0,0);
//to zoom object into scene..
camera.zoom=10;
//star making planes...
//create material-by attaching bitmap using BitmapAssetMaterial
var bam:BitmapAssetMaterial=new BitmapAssetMaterial("FlashIcon");
//by default material applied to one side of object(here plane);
bam.oneSide=false;
bam.smooth=true;
for (var i:int=0; i<5; i++) {
//new Plane(material,height, width,triangle num,triangle num)---triangle num to control quality
var p:Plane=new Plane(bam,150,75,2,2);

p.x=50*i;//gives value from -500 to 500
p.y=40;
p.z=40*i;
//p.y=Math.random()*1000-500;
//p.z=Math.random()*1000-500;
//p.x=500
p.rotationY=45;//rotate individual
//p.addEventListener(MouseEvent.CLICK,clicker);
scene.addChild(p);
var container2:Sprite = p.container;
//here we have container as key and plane as value later we retrive plane by using container
planebycontainer[container2]=p
container2.buttonMode = true;
//adding event listeners for mouse events
container2.addEventListener( MouseEvent.ROLL_OVER, doRollOver );
container2.addEventListener( MouseEvent.CLICK, clicker );
container2.addEventListener( MouseEvent.ROLL_OUT, doRollOut );
}
scene.renderCamera(camera);


this.addEventListener(Event.ENTER_FRAME,render);
function render(e:Event) {
//render places object in scene
scene.renderCamera(camera);
}
function doRollOver(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 0.5;
}
function doRollOut(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 1;
}
function clicker(evt:MouseEvent) {
//here we retrieve the plane which is clicked
var sprit:Sprite=evt.target as Sprite;
var p:Plane=planebycontainer[sprit]
trace(p)
}


Basic papervision example
Read more
2

Loading Library Assets from Loaded swf:



To load Movieclip from library in AS3:
var Content_mc:MovieClip= new MovieClip()

where Content_mc is the linkage name similarly to load content from loaded swf

var Content_mc:Class = event.target.applicationDomain.getDefinition(”Content_mc”) as Class
var new_content_mc:MovieClip = new Content_mc() as MovieClip;
addChild(new_content_mc);

Note : place this code in Complete Event ie., after preloading
Read more
 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.