Archive for August, 2008

Bug in Astro(Flash 10) or My mistake

Friday, August 29th, 2008

Trying to rotate a cube in flash 10 with its new 3D features
I placed a movie clip at z index 1 having alpha 0.5
I placed a movieclip at z index 50 having alpha 1 and again i placed movie clip at z index 100 with alpha 1

I can view the last movie clip as because the alpha is 0.5 for the the two upper movie clip but when i rotate the movie clip and when the last movie clip comes to front then still i can view the two movie clip which is not quite natural in case of 3d objects the code goes as follows

=============================================

package
{
import flash.display.*;
import flash.events.*;
import flash.media.*;

public class Regauqablo extends MovieClip
{

private  var container:MovieClip=new MovieClip();
private var glassBox:MovieClip=new MovieClip();
private var pane1:GlassPane=new GlassPane(0xffffff);
private var pane2:GlassPane=new GlassPane(0xffffff);
private var pane3:GlassPane=new GlassPane(0xffffff);
private var pane4:GlassPane=new GlassPane(0xffffff);
private var pane5:GlassPane=new GlassPane(0xffffff);
private var pane6:GlassPane=new GlassPane(0xffffff);

private var back:GlassPane=new GlassPane(0xff0000);

[Embed(source=”LILY.jpg”)]
private var Lily:Class;

//  private var back:Bitmap= new Lily();

public function Regauqablo()
{
pane1.alpha=1;
pane2.alpha=0.5;
pane3.alpha=0.5;
pane4.alpha=0.5;
pane5.alpha=0.5;
pane6.alpha=0.5;
back.alpha=0.5;

glassBox.addChild(pane1);

glassBox.addChild(pane2);
pane2.rotationX=270;

glassBox.addChild(pane3);
pane3.rotationY=90;

pane4.x+=pane4.width;
glassBox.addChild(pane4);
pane4.rotationY=90;

pane5.y+=pane5.height;
glassBox.addChild(pane5);
pane5.rotationX=270;

glassBox.addChild(pane6);
glassBox.addChild(back);

pane1.z=200;
pane2.z=200;
pane3.z=200;
pane4.z=200;
pane5.z=200;
back.z=100;

glassBox.x=100;
glassBox.y=100;

this.addChild(glassBox);
this.addEventListener(Event.ENTER_FRAME,doFrame);

}

function doFrame(e:Event):void
{
this.glassBox.rotationY+=.5;
}

}
}

import flash.display.*;
class GlassPane extends MovieClip
{

public function GlassPane(color:uint)
{
this.graphics.moveTo(0,0);
this.graphics.beginFill(color,1);
this.graphics.moveTo(200,0);
this.graphics.lineTo(200,200);
this.graphics.lineTo(0,200);
this.graphics.lineTo(0,0);
this.graphics.endFill();
}

}

=====================================

please check the file below for the output (FLASH 10 player needed)

regauqablo.swf

Astsro And Me

Tuesday, August 26th, 2008

Last week I downloaded Flash 10 SDK(Astro)
The 3d Thing (post card in space) is cool i am able to make a cube and rotate the cube in x ,y,z roatation . Till now flash does not have camera, Models and textures but shaders are great

I got Adobe pixel blender tool and tried with flash i was not able to run it smoothly as my graphics card (ATI) was not among the supported list of GPU for pixel blender

Flash 3 has

SoundMixer.getSprectrum for getting the spectrum of the sound .
few years back that was a hard thing for me to do in Java Sound api but now it is not even 3 single line of code here is my code in flash 10 AStro for rotatating a cube with the music

package
{
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.media.*;
import flash.net.*;
import flash.filters.*;

[SWF( backgroundColor=”#000000″, frameRate=”31″)]
public class Test extends MovieClip
{

[Embed(source=”yourpicture file.jpg”)]
private var Mypic:Class ;
private var mySound:Sound;

private var cont:MovieClip=new MovieClip();

private function soundLoaded(e:Event):void
{

mySound.play();

}
var n:Bitmap=new Mypic();
public function Test()
{

mySound=new Sound();
var soundFile:URLRequest =new URLRequest(”your soung file.mp3″);
mySound.load(soundFile);
mySound.addEventListener(flash.events.Event.COMPLETE,soundLoaded);

cont.addChild(n);
var n2:Bitmap=new Mypic();
cont.addChild(n2);
n2.rotationX=270;
addChild(cont);
var n3:Bitmap=new Mypic();
cont.addChild(n3);
n3.rotationY=90;
var n4:Bitmap=new Mypic();
n4.x+=n4.width;
cont.addChild(n4);
n4.rotationY=90;
var n5:Bitmap=new Mypic();
n5.y+=n5.height;
cont.addChild(n5);
n5.rotationX=270;
var n6:Bitmap=new Mypic();
cont.addChild(n6);
n.z=197;
n2.z=197;
n3.z=197;
n4.z=197;
n5.z=197;
cont.x=100;
cont.y=100;

var tTimer:Timer = new Timer(5, 0);
tTimer.addEventListener(TimerEvent.TIMER, doit);
tTimer.start( );

cont.alpha=0.5;

}

function doit(g:Event):void
{

var spectrum:ByteArray = new ByteArray( );
SoundMixer.computeSpectrum(spectrum);
var nos:Number=0;
cont.rotationX+=1;

cont.rotationY-=1;
for (var i:int = 0; i < 256; i++) {
nos = (spectrum.readFloat() );
cont.rotationZ-=(nos*10);

}

}

}

}

and here is the rotation of cube with out the music The rotating cube in flash 10