forked from: Musica e Partículas
import adobe.utils.CustomActions;
import flash.display.Shader;
import flash.ui.Mouse;
...
@author Thi
/**
* Copyright Aksor.Al ( http://wonderfl.net/user/Aksor.Al )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fBZM
*/
// forked from Thy's Musica e Partículas
package
{
//import adobe.utils.CustomActions;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.GraphicsSolidFill;
import flash.display.Loader;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.media.SoundMixer;
import flash.utils.ByteArray;
//import flash.display.Shader;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.BlendMode
import flash.display.GradientType
import flash.errors.IOError;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.media.ID3Info;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
import flash.net.navigateToURL
import flash.system.Security
import flash.system.LoaderContext
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.ui.Mouse;
//import flash.ui.Mouse;
/**
* ...
* @author Thi
*/
public class Main extends Sprite
{
//aqui você põe seu nome
private const Name:String = "Thi"
//aqui os dois menús
private const Menus:Array = [
["An Menu", ["An item", "http://wonderfl.net/"], ["Another one", "http://wonderfl.net/"], ["More itens", "http://wonderfl.net/"], ["Just some more", "http://wonderfl.net/"], ["Blah0","http://wonderfl.net/"], ["Blah1","http://wonderfl.net/"], ["Blah2","http://wonderfl.net/"], ["Blah3","http://wonderfl.net/"], ["Blah4","http://wonderfl.net/"]],
["Menu", ["Only 1 iten", "http://wonderfl.net/"],["The second", "http://wonderfl.net/"], ["The last", "http://wonderfl.net/"]]
]
//
private var Musicas:Array = [
["http://scfire-dtc-aa03.stream.aol.com:80/stream/1035"],
["http://thethi.webs.com/m/Im%20Not%20Alone_.mp3"],
["http://thethi.webs.com/m/3%20Words_.mp3"]
]
//coisas sobre o nome da pessoa
private var bmp_Nome:Bitmap;
//informações sobre os menús
private var data_menus:Array = new Array(Menus.length)
private var bmp_menus:Array = new Array(Menus.length)
private var ativ_menus:int = 0 //0 nenhum, 1 o [0], 2 o [1]
private var ativ_menus_antes:int = 0
private var ativ_over:Boolean
//menu que rola
private var spr_rollMenu:Sprite; //guarda Bitmap e 'rollTxt'
private var spr_rollTextos:Sprite = new Sprite(); //guarda todos os textos
private var shpMask:Shape = new Shape()
private var fundinho:Boolean = false
private var WFundinho:Number, HFundinho:Number
private var destinoY:Number
private var data_fundinho:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x959595)
private var bmp_fundinho:Bitmap = new Bitmap(data_fundinho, "auto", true)
//lista dentro do slide menu
private var list_top:Array = []
private var slide_over:Boolean = false
private var vai_fazer_deslizar_de_volta:int
//barra de rolagem
private var spr_rollBar:Sprite
private var slidingBar:Boolean = false
private var destinoY_scrool:Number
private var point_scrool:Number
//
private var data_player:Array = new Array(4)
private var bmp_player:Array = new Array(5)// O Pause/Play compartilham da msm musica
private var spr_loading:Sprite
private var spr_playing:Sprite
//
private var som:Sound = new Sound()
private var id3:ID3Info;
private var id3Pego:Boolean = false
private var somC:SoundChannel;
private var musica:String = ""
private var pauseP:Number = 0.00
private var length_som:Number = 0.00
private var porc_som:Number = 0
private var somP:Boolean = true
private var rand:int
private var proxima:Boolean = true
private var Tinf:TextField
//
private var carregou:Boolean
private var Entrosa:Loader
private var carregadorCarregado:Boolean = false
private var objEntrosa:Object
private var primeiroID3:Boolean = false
//
private var frame:Shape = new Shape()
//parar o frame rate
private var countFrameRate:int = 30, bool_frameRate:Boolean
//sound Spec
private const rads:Number = .0174532
private var rX:Number, rY:Number = 0, cX:Number, cY:Number, width_nome:Number = 0, height_nome:Number = 0;
private var velo:Number = 0, ang:Number = 0
private var circ_back:Shape = new Shape(), circ_front:Shape = new Shape();
private var data_spec:BitmapData, bmp_spec:Bitmap;
private var ba:ByteArray = new ByteArray()
private var amp:Number = 0
//
private var data_sound:BitmapData, data_force:BitmapData, data_perlin:BitmapData, data_perlin2:BitmapData
private var bmp_sound:Bitmap
private var blur:BlurFilter = new BlurFilter(2, 2, 1)
private var col:ColorTransform = new ColorTransform(.8+Math.random(), .8+Math.random(), .8+Math.random(), Math.random()*.5 + .4/*.45*/)
private var matrix:Matrix = new Matrix()
private var R:Number = 0, G:Number = 0, B:Number = 0, R2:Number = 0, G2:Number = 0, B2:Number = 0;
//
private var rect1:Rectangle = new Rectangle(132.5, 0, 33, 26)
private var rect2:Rectangle = new Rectangle(0,0,96.75,26)
private var rect3:Rectangle = new Rectangle(96.75, 0, 35.75, 26)
//partículas
private var particulas:int = Math.random()*Math.random()*5000
private var posX:Vector.<Number> = new Vector.<Number>(particulas)
private var posY:Vector.<Number> = new Vector.<Number>(particulas)
private var veloX:Vector.<Number> = new Vector.<Number>(particulas)
private var veloY:Vector.<Number> = new Vector.<Number>(particulas)
//
private var tempo:int = 0, tempoMax:int = 100
private var col_alpha:ColorTransform = new ColorTransform()
//
private const scale:Number = 4
private const W:Number = stage.stageWidth
private const H:Number = stage.stageHeight
private const Ws:Number = W / scale
private const Hs:Number = H / scale
//adiciona layers
private var layer0:Sprite = new Sprite()//fundão
private var layer1:Sprite = new Sprite()
private var layer2:Sprite = new Sprite()
private var layer3:Sprite = new Sprite()
private var layer4:Sprite = new Sprite()//nome
private var layer5:Sprite = new Sprite()//fundinho
private var layer6:Sprite = new Sprite()//botões
private var layer7:Sprite = new Sprite()//frame
private var layer8:Sprite = new Sprite()
private var layer9:Sprite = new Sprite()
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
Security.allowDomain("*")
//Security.loadPolicyFile("http://thethi.webs.com/crossdomain.xml")
//Security.LOCAL_TRUSTED
stage.addEventListener(Event.MOUSE_LEAVE, mouse_leave)
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouse_enter)
stage.frameRate = 0
newPart()
newGraficos()
EntrosaLoader()
}
private function mouse_leave(e:Event):void
{
countFrameRate = 30
bool_frameRate = false
stage.addEventListener(Event.ENTER_FRAME, zerar_frame_rate)
stage.removeEventListener(Event.MOUSE_LEAVE, mouse_leave)
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouse_enter)
}
private function mouse_enter(e:MouseEvent):void
{
stage.frameRate = 30
bool_frameRate = true
stage.addEventListener(Event.MOUSE_LEAVE, mouse_leave)
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouse_enter)
}
private function zerar_frame_rate(e:Event):void
{
countFrameRate -= 1
if (bool_frameRate)
{
stage.removeEventListener(Event.ENTER_FRAME, zerar_frame_rate)
return;
}
if (countFrameRate < 0)
{
stage.frameRate = 0
stage.removeEventListener(Event.ENTER_FRAME, zerar_frame_rate)
}
}
private function newGraficos():void
{
//mostro todas as layers no DispplayList
stage.addChild(layer0)
stage.addChild(layer1)
stage.addChild(layer2)
stage.addChild(layer3)
stage.addChild(layer4)
stage.addChild(layer5)
stage.addChild(layer6)
stage.addChild(layer7)
stage.addChild(layer8)
stage.addChild(layer9)
//crio textfield, e o formato
var nome:TextField = new TextField()
var format:TextFormat = new TextFormat()
format.size = 16
format.font = "Arial"
//ajusto, e escrevo no texto o nome da pessoa
nome.defaultTextFormat = format
nome.autoSize = TextFieldAutoSize.LEFT
nome.textColor = 0x141414
nome.antiAliasType = "advanced"
nome.text = Name
//pego valores como largura e altura
var Wt:Number = nome.width
var Ht:Number = nome.height
//crio bitmap e sua data
var data:BitmapData = new BitmapData(Wt<<1,Ht<<1, true, 0x0000FF)
var bmp:Bitmap = new Bitmap(data, "auto", true)
data.draw(nome)
//crio uma matrix (pra dar um 'flip vertical'
var matr:Matrix = new Matrix()
matr.a = 1
matr.d = -1
matr.ty = Ht-9
matr.translate(0, Ht)
//color transform que fará o texto ficar branco
var colTr:ColorTransform = new ColorTransform(1,1,1,1, 255, 255, 255)
data.draw(data, matr, colTr)
//refaço a matrix pra criar um gradientBox
matr = new Matrix()
matr.createGradientBox(Wt,Ht+9,Math.PI/2)
//a gradientBox
var mask:Shape = new Shape()
mask.graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF,0xFFFFFF, 0xFFFFFF], [1, 1,1,0], [0, 127,128,255], matr)
mask.graphics.drawRect(0, 0, Wt, Ht+9)
mask.graphics.endFill()
//coloco na displayList, e faço cache (tem que fazer)
stage.addChild(bmp)
stage.addChild(mask)
mask.cacheAsBitmap = true
bmp.cacheAsBitmap = true
//e faço com que a máscara seja a máscara
bmp.mask = mask
//Agora criarei uma nova data e bmp FINAL para copiar tudo pronto
var data_nome:BitmapData = new BitmapData(Wt, (Ht<<1)-9, true, 0x0000FF)
var bmp_nome:Bitmap = new Bitmap(data_nome)
data_nome.draw(stage, null, null, null, null, false)
//e me livro da sobra da construção da data2 e bmp2
bmp.mask = null
stage.removeChild(bmp)
stage.removeChild(mask)
bmp.cacheAsBitmap = false
mask.cacheAsBitmap = false
//mask.graphics.clear()
//mask = null
bmp = null
//data = null
//matr = null
//colTr = null
//nome = null
//format = null
//Wt = NaN
//Ht = NaN
//Aqui começa a construção dos menús
var i:int = 0
var length:int = Menus.length
while (i < length)
{
//distrói as coisas feita pelo menú de antes
mask.graphics.clear()
data = null
//texto do menu atual
nome.text = Menus[i][0]
//pego valores como largura e altura
Wt = nome.width
Ht = nome.height
//~~Aqui começa os desenhos~~
//a matrix pro botão
matr = new Matrix()
matr.createGradientBox(Wt<<1, Ht, Math.PI/2)
//o botão (estou chamando ele de mask, mas não será uma mask)
mask.graphics.lineStyle(1, 0x000000, 1, true)
mask.graphics.beginGradientFill(GradientType.LINEAR, [0x202326, 0x2F2F2F, 0x010305, 0x000000], [1, 1, 1, 1], [0, 127, 128, 255], matr)
mask.graphics.drawRoundRect(0, 0, Wt << 1, Ht, 5, 5)
mask.graphics.endFill()
//
Wt = mask.width
Ht = mask.height
//crio bitmap e sua data
data = new BitmapData(Wt,Ht, true, 0x0000FF)
//bmp = new Bitmap(data, "auto", true)
data.draw(mask)
nome.textColor = 0xffffff
matr = new Matrix()
matr.tx = nome.width >> 1
data.draw(nome, matr, null, BlendMode.DIFFERENCE/*INVERT*/)
//cria uma data só pro menu0
var data_menu:BitmapData = data.clone()
data_menus[i] = data_menu
var conteiner:Sprite = new Sprite()
conteiner.addChild(new Bitmap(data_menus[i], "auto", false))
bmp_menus[i] = conteiner
data_menu = null
++i
}
//limpar a sjugeira que sobra
mask.graphics.clear()
//mask = null
data = null
//matr = null
colTr = null
//nome = null
//format = null
//Wt = NaN
//Ht = NaN
conteiner = null
//Construção do fundo deslizante
//distrói as coisas feita pelo menú de antes
mask.graphics.clear()
data = null
//invento valores como largura e altura
Wt = bmp_menus[0].width
Ht = 100-bmp_menus[0].height
//~~Aqui começa os desenhos~~
//a matrix pro botão
matr = new Matrix()
matr.createGradientBox(Wt<<1, Ht, Math.PI/2)
//o botão (estou chamando ele de mask, mas não será uma mask)
mask.graphics.lineStyle(1, 0x000000, 1, true)
mask.graphics.beginGradientFill(GradientType.LINEAR, [0x2F2F2F,0x202326,0x010305, 0x000000], [1, 1, 1, 1], [0, 63, 127, 255], matr)
mask.graphics.drawRoundRect(0, 0, Wt << 1, Ht, 5, 5)
mask.graphics.endFill()
//
Wt = WFundinho = mask.width
Ht = HFundinho = mask.height
//crio bitmap e sua data
data = new BitmapData(Wt,Ht, true, 0x0000FF)
//bmp = new Bitmap(data, "auto", true)
data.draw(mask)
//cria uma data só pro sliding menu
var data_rollMenu:BitmapData = data.clone()
spr_rollMenu = new Sprite()
spr_rollMenu.addChild(new Bitmap(data_rollMenu, "auto", false))
newTopicMenu()
//cria nova barra de rolagem
spr_rollBar = new Sprite()
spr_rollBar.graphics.lineStyle(1, 0xFF0000, 1, true, "none")
spr_rollBar.graphics.beginFill(0x00FF00, 1)
spr_rollBar.graphics.drawRoundRect(0, 0, 10, 10, 1, 1)
spr_rollBar.graphics.endFill()
spr_rollBar.x = (WFundinho - spr_rollBar.width) - 5
//limpa a sjugeira que sobrar
mask.graphics.clear()
mask = null
data = null
matr = null
colTr = null
nome = null
format = null
Wt = NaN
Ht = NaN
conteiner = null
//cria as bordas do .swf
desenharFundinho()
//e finalmente tenho:
//*nome*
bmp_Nome = bmp_nome
layer4.addChild(bmp_Nome)
width_nome = bmp_nome.width
height_nome = bmp_nome.height
bmp_nome.x = stage.stageWidth-60 - width_nome*.5
bmp_nome.y = stage.stageHeight - height_nome
//arruma os negócios do spectrum
rX = width_nome
cX = stage.stageWidth -60
cY = stage.stageHeight - height_nome * .5
layer3.addChild(circ_back)
layer7.addChild(circ_front)
//*menús*
layer6.addChild(bmp_menus[0])
layer6.addChild(bmp_menus[1])
bmp_menus[1].x = bmp_menus[0].width + 0
trace(bmp_menus[0].width)
//adiciona Listeners nos 2 menús
bmp_menus[0].addEventListener(MouseEvent.ROLL_OVER, over)
bmp_menus[1].addEventListener(MouseEvent.ROLL_OVER, over)
bmp_menus[0].addEventListener(MouseEvent.ROLL_OUT, out)
bmp_menus[1].addEventListener(MouseEvent.ROLL_OUT, out)
//arruma os data e bmp do sound
data_sound = new BitmapData(Ws, Hs, true, 0x959595)
data_force = new BitmapData(Ws, Hs, false, 0x000000)
data_force.perlinNoise(Ws, Hs, 2, Math.random()*Math.random()*100, false, true, 3)
data_perlin = data_force.clone()
data_perlin2 = data_force.clone()
data_perlin2.perlinNoise(Ws, Hs, 2, Math.random() * Math.random() * 100, false, true, 3)
bmp_sound = new Bitmap(data_sound/*data_force*/, "auto", true)
bmp_sound.scaleX = bmp_sound.scaleY = scale
matrix = new Matrix()
matrix.a = 1/scale
matrix.d = 1/scale
matrix.ty = 1/scale
//bmp_sound.x = stage.stageWidth -60 - width_nome -5
/**/layer1.addChild(bmp_sound)/**/
}
private function desenharFundinho():void
{
frame.graphics.lineStyle(1, 0, 1, true)
frame.graphics.drawRoundRect(0, 0, stage.stageWidth - 1, stage.stageHeight - 1, 5, 5)
newGrass(Math.random() * 600, true)
newGrass(Math.random()*300, false)
newFlor(Math.random()*10, 200)
data_fundinho.draw(frame)
layer2.addChild(bmp_fundinho)
//frame.cacheAsBitmap = true
}
private function newGrass(i:int, boo:Boolean):void
{
while (i > 0)
{
var X:Number = Math.random() * stage.stageWidth
var Y:Number = 100 - Math.random() * Math.random() * 100
if (boo)
{
if (Math.random() > .9)
{
Y = 100 - Math.random() * 30
} else
{
Y = 100 - Math.random() * Math.random() * 20
}
}
with (frame.graphics)
{
var cor:uint = uint(Math.random() * 0xFF << 16 | Math.random() * 0x95 << 8 | Math.random() * 0x40)
lineStyle(Math.random()+.5, 0, 1, true)
moveTo(X, 100)
curveTo(X, 95, X - Math.random() * 10 + 5, Y - Math.random()*2)
moveTo(X, 100)
curveTo(X, 95, X - Math.random() * 10 + 5, Y+Math.random()*2)
}
--i
}
}
private function newFlor(i:int, j:Number):void
{
var k:Number = j
while (i > 0)
{
var X:Number = Math.random() * stage.stageWidth
var Y:Number = 100 - Math.random() * Math.random()*80
var X2:Number = X - Math.random() * 10 + 5
var Y2:Number = Y - Math.random()
var r:Number = Math.random()*10
with (frame.graphics)
{
lineStyle(Math.random()+.5, 0, 1, true)
moveTo(X, 100)
curveTo(X, 95, X2, Y2)
beginFill(0)
drawCircle(X2, Y2, r)
endFill()
}
while (j > 0)
{
var a:Number = Math.random()*Math.PI*2
with (frame.graphics)
{
moveTo(X2, Y2)
lineTo(X2 + Math.cos(a)*r*(Math.random() + 1), Y2 + Math.sin(a)*r*(Math.random() + 1))
--j
}
}
j = k
--i
}
}
//function de Listeners e outros, dos Menus
private function newTopicMenu():void
{
trace("ATIV MENUS = ", ativ_menus)
//se livra das coisas do menu de antes
var i:int = 1
var length:int = spr_rollTextos.numChildren
//trace("vai começar")
while (i < length)
{
//trace("é,",i,"é menor do que",length)
spr_rollTextos.removeChildAt(i)
length--
//i++
}
// trace("cabo")
if (spr_rollMenu.numChildren > 1)
{
//trace(spr_rollMenu.numChildren, "é maior q um")
spr_rollMenu.removeChildAt(1)
// trace("ae")
}
spr_rollTextos = null
spr_rollTextos = new Sprite()
i = 0
length = list_top.length
while (i < length)
{
list_top[i] = null
i++
}
list_top = []
//construção dos sub-menús deslizantes
i = 0
if (ativ_menus == 0)
{
length = Menus[0].length -1
} else {
length = Menus[ativ_menus - 1].length-1
}
while (i < length)
{
//cria o formato do texto
var format:TextFormat = new TextFormat()
format.size = 12
format.font = "Arial"
//texto do menu atual
var nome:TextField = new TextField()
nome.defaultTextFormat = format
if (ativ_menus == 0)
{
nome.text = Menus[0][i+1][0]
} else
{
nome.text = Menus[ativ_menus-1][i+1][0]
}
nome.textColor = 0xFFFFFF
nome.selectable = false
nome.height = 25
nome.border = true
nome.borderColor = uint((Math.random()*0xFF << 16) | (Math.random()*0xFF << 8) | (Math.random()*0xFF))
list_top.push(nome)
//spr_rollTextos
spr_rollTextos.addChild(nome)
nome.x = 10
nome.y = i * 25
//nome.autoSize = TextFieldAutoSize.LEFT
nome.width = WFundinho-32
++i
nome.addEventListener(MouseEvent.ROLL_OVER, OVERtxt)
nome.addEventListener(MouseEvent.ROLL_OUT, OUTtxt)
nome.addEventListener(MouseEvent.CLICK, CLICKtxt)
trace("TEXTO Y", nome.y,"TEXTO HEIGHT",nome.height+nome.y, "BOUNDS", nome.getBounds(stage))
}
spr_rollMenu.addChild(spr_rollTextos)
var matr:Matrix = new Matrix()
matr.createGradientBox(WFundinho, HFundinho, Math.PI/2)
shpMask.graphics.clear()
shpMask.graphics.beginGradientFill(GradientType.LINEAR, [0x0,0x0,0x0,0x0],[0,1,1,0],[0,30,205,255],matr)
shpMask.graphics.drawRect(0,0,WFundinho,HFundinho)
shpMask.graphics.endFill()
stage.addChild(shpMask)
shpMask.cacheAsBitmap = true
spr_rollTextos.cacheAsBitmap = true
spr_rollTextos.mask = shpMask
//no fim, adiciona CADA Campo de Texto no (list_top)(array) e no (spr_rollMenu)(sprite)
//cria a barra de rolagem (sprite)
trace(spr_rollMenu.numChildren, "children")
if (spr_rollMenu.numChildren > 2)
{
spr_rollMenu.removeChild(spr_rollBar)
}
}
private function over(e:MouseEvent):void
{
trace("aleugém OVER")
var quem:Object = e.target
if (quem == bmp_menus[0])
{
ativ_menus = 1
trace("ATIV MENUS = 1")
if (!fundinho)
{
//mostra o fundinho
fundinho = true
layer5.addChild(spr_rollMenu)
spr_rollMenu.addChild(spr_rollTextos)
newTopicMenu()/**/
spr_rollMenu.x = 0
spr_rollMenu.y = -spr_rollMenu.height
destinoY = bmp_menus[0].height
spr_rollMenu.addEventListener(Event.ENTER_FRAME, andarFundinho)
} else {
ativ_over = true
if (ativ_menus_antes != 1)
{
//mudou de menu
newTopicMenu()/**/
spr_rollMenu.x = 0
spr_rollMenu.y = -spr_rollMenu.height
destinoY = bmp_menus[0].height
spr_rollMenu.addEventListener(Event.ENTER_FRAME, andarFundinho)
}
}
} else if (quem == bmp_menus[1])
{
ativ_menus = 2
trace("ATIV MENUS = 2")
if (!fundinho)
{
//cria fundinho
fundinho = true
layer5.addChild(spr_rollMenu)
spr_rollMenu.addChild(spr_rollTextos)
newTopicMenu()/**/
spr_rollMenu.x = bmp_menus[1].x
spr_rollMenu.y = -spr_rollMenu.height
destinoY = bmp_menus[0].height
spr_rollMenu.addEventListener(Event.ENTER_FRAME, andarFundinho)
} else {
ativ_over = true
if (ativ_menus_antes != 2)
{
//mudou de menu
newTopicMenu()/**/
spr_rollMenu.x = bmp_menus[1].x
spr_rollMenu.y = -spr_rollMenu.height
destinoY = bmp_menus[0].height
spr_rollMenu.addEventListener(Event.ENTER_FRAME, andarFundinho)
}
}
}
}
private function out(e:MouseEvent):void
{
ativ_menus_antes = ativ_menus
ativ_over = false
ativ_menus = 0
trace("ATIV MENUS = 0")
vai_fazer_deslizar_de_volta = 5
stage.addEventListener(Event.ENTER_FRAME, regressivo_slide_voltar)
}
private function andarFundinho(e:Event):void
{
var Y:Number = spr_rollMenu.y
if (Y >= destinoY-1 && Y <= destinoY+1)
{
trace("chegou", destinoY)
spr_rollMenu.removeEventListener(Event.ENTER_FRAME, andarFundinho)
if (destinoY < 1) {
fundinho = false
slide_over = false
spr_rollMenu.removeEventListener(MouseEvent.ROLL_OVER, OVERslide)
spr_rollMenu.removeEventListener(MouseEvent.ROLL_OUT, OVERslide)
layer5.removeChild(spr_rollMenu)
} else {
if (list_top.length > 3)
{
spr_rollMenu.addChild(spr_rollBar)
spr_rollBar.height = HFundinho * 3 / list_top.length
spr_rollBar.y = 0
spr_rollBar.addEventListener(MouseEvent.MOUSE_DOWN, DOWNslideBar)
spr_rollBar.addEventListener(MouseEvent.MOUSE_UP, UPslideBar)
}
}
} else {
spr_rollMenu.addEventListener(MouseEvent.ROLL_OVER, OVERslide)
spr_rollMenu.addEventListener(MouseEvent.ROLL_OUT, OUTslide)
if (Y < 0 && destinoY>0)
{
spr_rollMenu.y -= (Y - destinoY) * .2
} else if (destinoY > 0) {
spr_rollMenu.y += (destinoY-Y)* .2
} else {
spr_rollMenu.y += (destinoY-Y)* .2
}
shpMask.y = spr_rollMenu.y
shpMask.x = spr_rollMenu.x
}
}
private function OVERslide(e:MouseEvent):void
{
slide_over = true
}
private function OUTslide(e:MouseEvent):void
{
slide_over = false
vai_fazer_deslizar_de_volta = 5
stage.addEventListener(Event.ENTER_FRAME, regressivo_slide_voltar)
}
private function regressivo_slide_voltar(e:Event):void
{
--vai_fazer_deslizar_de_volta
if (vai_fazer_deslizar_de_volta < 0)
{
stage.removeEventListener(Event.ENTER_FRAME, regressivo_slide_voltar)
if (fundinho && !slide_over && !ativ_over)
{
trace("FILHO DA PUTA")
ativ_menus_antes = 0
destinoY = -spr_rollMenu.height
spr_rollBar.removeEventListener(Event.ENTER_FRAME, andarScrool)
spr_rollMenu.addEventListener(Event.ENTER_FRAME, andarFundinho)
if (spr_rollMenu.numChildren > 2)
{
spr_rollMenu.removeChild(spr_rollBar)
}
} else {
if (ativ_menus == 0)
{
trace("PUTA QUI PARIU")
ativ_menus = ativ_menus_antes
}
}
}
}
private function DOWNslideBar(e:MouseEvent):void
{
slidingBar = true
point_scrool = (mouseY - (100 - HFundinho+spr_rollBar.y))
destinoY_scrool = (mouseY - (100-HFundinho)) - point_scrool
spr_rollBar.addEventListener(Event.ENTER_FRAME, andarScrool)
}
private function UPslideBar(e:MouseEvent):void
{
slidingBar = false
var Y:Number = -spr_rollTextos.y
trace("Y",Y)
//var modulo:Number = (Y % 25)
var iten_proximo:Number = Math.round(Y / 25)
var spaceScrool:Number = HFundinho - (HFundinho * (3/list_top.length))
var spaceTxt:Number = (list_top.length - 3) * 25
destinoY_scrool = (iten_proximo * 25) /(spaceTxt/spaceScrool)
spr_rollBar.addEventListener(Event.ENTER_FRAME, andarScrool)
trace("final", iten_proximo, "Y Final", destinoY_scrool)
}
private function andarScrool(e:Event):void
{
if (slidingBar)
{
destinoY_scrool = (mouseY - (100-HFundinho)) - point_scrool
}
var Y:Number = spr_rollBar.y
if (!slidingBar)
{
if (Y >= destinoY_scrool-.5 && Y <= destinoY_scrool+.5)
{
spr_rollBar.y = destinoY_scrool
spr_rollBar.removeEventListener(Event.ENTER_FRAME, andarScrool)
} else {
spr_rollBar.y += (destinoY_scrool - Y) *.5
}
} else {
spr_rollBar.y += (destinoY_scrool - Y) *.5
}
spr_rollBar.y = spr_rollBar.y<0? 0 : spr_rollBar.y+spr_rollBar.height>HFundinho? HFundinho-spr_rollBar.height : spr_rollBar.y
Y = spr_rollBar.y
var spaceScrool:Number = HFundinho - (HFundinho * (3/list_top.length))
var spaceTxt:Number = (list_top.length - 3) * 25
spr_rollTextos.y = 0 - Y*spaceTxt/spaceScrool
//spr_rollTextos.y = 0 - (spr_rollBar.y * ((list_top.length-2)*25/(3/list_top.length)))
//4 + i * 25
//spr_rollBar.height = HFundinho * 3 / list_top.length
}
private function OVERtxt(e:MouseEvent):void
{
var txt:Object = e.target
txt.textColor = 0x0000FF
}
private function OUTtxt(e:MouseEvent):void
{
var txt:Object = e.target
txt.textColor = 0xFFFFFF
}
private function CLICKtxt(e:MouseEvent):void
{
var txt:Object = e.target
var item:int = Math.round(-spr_rollTextos.y / 25)
var mY:Number = Math.floor((mouseY - (100 - HFundinho)) / 25)
item += mY
//Menus[ativ_menus - 1][i + 1][1]
//trace(Menus[0/*aqui é o menuzão, 0 ou 1*/][1/*não pode ser 0*/][1]/*link*/)
trace("íten", item,/*"mY", mY, "final", item+mY,*/ "atv menu", ativ_menus, "url", Menus[ativ_menus - 1][item + 1][1])
var url:URLRequest = new URLRequest(Menus[ativ_menus - 1][item + 1][1])
navigateToURL(url)
//diminui o framerate, já que essa página não será a 'atual'
countFrameRate = 30
bool_frameRate = false
stage.addEventListener(Event.ENTER_FRAME, zerar_frame_rate)
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouse_enter)
}
private function EntrosaLoader():void
{
//E eu carrego o carregador das musicas ^^
Entrosa = new Loader()
Entrosa.load(new URLRequest("http://thethi.webs.com/Entrosa8.swf"))
Entrosa.contentLoaderInfo.addEventListener(Event.COMPLETE, Ccomp)
Entrosa.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, Cprog)
}
//function sobre as músicas etc
private function newPlayer():void
{
var matr:Matrix = new Matrix()
matr.createGradientBox(10,10,Math.PI/2)
var shp:Shape = new Shape()
shp.graphics.lineStyle(0,0,0,true)
shp.graphics.beginGradientFill(GradientType.LINEAR, [0x202326, 0x2F2F2F],[1,1],[0,255],matr)
shp.graphics.drawRoundRect(0, 0, 10, 10, 2, 2)
shp.graphics.endFill()
//crio bitmap e sua data
var data:BitmapData = new BitmapData(10,10, true, 0x0000FF)
var bmp:Bitmap = new Bitmap(data, "auto", true)
data.draw(shp)
var i:int = 0
var length:int = 4
while (i < length)
{
data_player[i] = data.clone()
var conteiner:Sprite = new Sprite()
conteiner.addChild(new Bitmap(data_player[i], "auto", true))
bmp_player[i] = conteiner
layer5.addChild(bmp_player[i])
bmp_player[i].x = stage.stageWidth - (4 * 20 + 15) + i*20
bmp_player[i].y = 17
i++
}
data_player[4] = data.clone()
//desenha individualmente em cada botão
//matrix que será usada
matr = new Matrix()
//shape do botão 0
shp.graphics.clear()
shp.graphics.lineStyle(0, 0, 0, true)
shp.graphics.beginFill(0xFFFFFF)
shp.graphics.moveTo(1, 5)
shp.graphics.lineTo(9,5)
shp.graphics.lineTo(5,9)
shp.graphics.lineTo(1, 5)
shp.graphics.endFill()
//desenha o botão 0 (v)
matr.ty = -2
data_player[0].draw(shp, matr)
//shape dos botões 2,3,1
shp.graphics.clear()
shp.graphics.lineStyle(0, 0, 0, true)
shp.graphics.beginFill(0xFFFFFF)
shp.graphics.moveTo(5, 1)
shp.graphics.lineTo(5,9)
shp.graphics.lineTo(9,5)
shp.graphics.lineTo(5, 1)
shp.graphics.endFill()
//desenha botão 2 (>)
matr.ty = 0
matr.tx = -2
data_player[2].draw(shp, matr)
//desenha botão 3 (<<)
matr.tx = -4
data_player[3].draw(shp)
data_player[3].draw(shp, matr)
//desenha botão 1 (>>)
matr.tx = 0
matr.a = -1
matr.translate(10, 0)
data_player[1].draw(data_player[3], matr)
//shape do botão 4
shp.graphics.clear()
shp.graphics.lineStyle(1, 0xFFFFFF, 1, true)
shp.graphics.moveTo(3, 2)
shp.graphics.lineTo(3, 8)
shp.graphics.moveTo(6,2)
shp.graphics.lineTo(6,8)
//desenha o botão 0 (||)
data_player[4].draw(shp)
//adiciona listeners
//bmp_player[0].addEventListener(MouseEvent.CLICK, PlayPause)
bmp_player[1].addEventListener(MouseEvent.CLICK, Previus)
bmp_player[2].addEventListener(MouseEvent.CLICK, PlayPause)
bmp_player[3].addEventListener(MouseEvent.CLICK, Next)
//newLoadingSpr()
//sortear musicas:
//rand = int(Math.random() * Musicas.length)
//rand = Musicas.length-1
//novaMusica()
}
private function newLoadingSpr():void
{
//agora vou desenhar a linha do Loading (move; line branco)
//linha da reprodução (line laranja, move)
spr_loading = new Sprite()
spr_loading.graphics.moveTo(0/*carregado*/, 0)
spr_loading.graphics.lineStyle(1, 0xFFFFFF, 1)
spr_loading.graphics.lineTo(110, 0)
//
spr_playing = new Sprite()
spr_playing.graphics.lineStyle(2, 0xFF7F00, 1)
spr_playing.graphics.lineTo(0/*tocado*/, 0)
layer5.addChild(spr_loading)
layer5.addChild(spr_playing)
spr_loading.x = spr_playing.x = stage.stageWidth-120
spr_loading.y = 13
spr_playing.y = 13
//texto de informações da música
var format:TextFormat = new TextFormat()
format.size = 9
format.font = "Arial"
Tinf = new TextField()
Tinf.defaultTextFormat = format
Tinf.selectable = false
Tinf.textColor = 0x000000
Tinf.autoSize = TextFieldAutoSize.LEFT
Tinf.y = -1
layer5.addChild(Tinf)
}
//som
private function Ccomp(e:Event):void
{
trace("FINALMENTE CARREGOU O LOADER")
objEntrosa = Object(Entrosa.content)
//carregadorCarregado = true
//stage.addChild(Entrosa)
trace("AGORA VAI COMEÇAR UMA NOVA MÚSICA")
newLoadingSpr()
rand = Musicas.length-1
novaMusica()
trace("JÁ CARREGO UMA NOVA MUSICA, AGR VAI ESPERAR PEGAR O ID3")
//newPlayer()
//adiciona o Enter Frame relacionado ao Entrosa
stage.addEventListener(Event.ENTER_FRAME, novoFrame)
}
private function Cprog(e:ProgressEvent):void
{
trace("tá carregano o filho da puta", 100*e.bytesLoaded/e.bytesTotal)
}
private function novaMusica():void
{
//avança para a próxima musica e grava o endereço da música
trace("vai ver nova musica.. próxima = ",proxima,"index de antes = ",rand)
rand = proxima? (rand < Musicas.length - 1? rand+1 : 0) : (rand > 0? rand-1 : Musicas.length-1)
musica = Musicas[rand][5] == undefined || null || "" ? Musicas[rand][0] : Musicas[rand][5]
trace("index depois = ", rand)
id3Pego = false
trace("MANDOU O LINK PRO CARREGADOR")
/*Object(Entrosa.content)*/objEntrosa.link = musica
/*Object(Entrosa.content)*/objEntrosa.loadLink()
somC = new SoundChannel()
som = new Sound()
som = /*Object(Entrosa.content)*/objEntrosa.som
//som.addEventListener(Event.ID3, ID3)
som.addEventListener(Event.COMPLETE, Lcomp)
som.addEventListener(ProgressEvent.PROGRESS, Lprog)
//som.addEventListener(IOErrorEvent.IO_ERROR, Lerro)
}
private function Lcomp(e:Event):void
{
trace("COMPLETOU o Loading")
som.removeEventListener(Event.COMPLETE, Lcomp)
som.removeEventListener(ProgressEvent.PROGRESS, Lprog)
//som.removeEventListener(IOErrorEvent.IO_ERROR, Lerro)
carregou = true
}
private function Lprog(e:ProgressEvent):void
{
//trace("progressando", e.bytesLoaded)
//mostra o loading bar
spr_loading.graphics.clear()
/**/spr_loading.graphics.lineStyle(1, 0)/**/
porc_som = e.bytesLoaded/e.bytesTotal
spr_loading.graphics./*move*/lineTo(109*porc_som, 0)
spr_loading.graphics.lineStyle(1, 0xFFFFFF, 1)
spr_loading.graphics.lineTo(110, 0)
//algumas coisas
carregou = false
}
/*private function Lerro(e:IOErrorEvent):void
{
trace("erro", e)
}*/
private function PlayPause(e:MouseEvent):void
{
PP()
}
private function PP():void
{
var conteiner:Sprite = new Sprite()
if (somP)
{
trace("DEU PLAY POHA")
//som.play()
somC = som.play(pauseP)
somP = false
conteiner.addChild(new Bitmap(data_player[4], "auto", true))
bmp_player[2].removeEventListener(MouseEvent.CLICK, PlayPause)
layer5.removeChild(bmp_player[2])
trace(bmp_player[2])
bmp_player[2] = null
bmp_player[2] = conteiner
bmp_player[2].x = stage.stageWidth - (4 * 20 + 15) + 2*20
bmp_player[2].y = 17
layer5.addChild(bmp_player[2])
conteiner = null
} else {
trace("DEU PAUSE POHA")
pauseP = somC.position
somC.stop()
somP = true
conteiner.addChild(new Bitmap(data_player[2], "auto", true))
bmp_player[2].removeEventListener(MouseEvent.CLICK, PlayPause)
layer5.removeChild(bmp_player[2])
trace(bmp_player[2])
bmp_player[2] = null
bmp_player[2] = conteiner
bmp_player[2].x = stage.stageWidth - (4 * 20 + 15) + 2*20
bmp_player[2].y = 17
layer5.addChild(bmp_player[2])
conteiner = null
}
bmp_player[2].addEventListener(MouseEvent.CLICK, PlayPause)
}
private function Previus(e:MouseEvent):void
{
trace("DEU PREVIOUS POHA")
proxima = proxima? !proxima : proxima
pauseP = 0.00
somC.stop()
if (!carregou)
{
som.close()
}
novaMusica()
}
private function Next(e:MouseEvent):void
{
trace("DEU NEXT POHA")
proxima = proxima? proxima : !proxima
pauseP = 0.00
somC.stop()
if (!carregou)
{
som.close()
}
novaMusica()
}
//O Enter Frame do stage
private function novoFrame(e:Event):void
{
if (!somP && id3Pego)
{
length_som = som.length
spr_playing.graphics.clear()
spr_playing.graphics.lineStyle(2, 0xFF7F00, 1)
//spr_playing.graphics.lineTo((110 * somC.position / length_som)*porc_som/*tocado*/, 0)
spr_playing.graphics.lineTo(109*somC.position/((1/porc_som)*length_som)+1/*tocado*/, 0)
//trace(/*"posição", somC.position, "duração", length_som, "o que é igual á",*/ 100*somC.position/length_som ,"porcentos")
//trace(/*"posição", somC.position, "duração", length_som, "o que é igual á",*/ 100*somC.position/((1/porc_som)*length_som) ,"porcentos")
spec()
} else if (somP && id3Pego && !primeiroID3)
{
primeiroID3 = true
newPlayer()
}
if (/*Object(Entrosa.content)*/objEntrosa.id3Pronto == true && !id3Pego)
{
if (!somP)
{
somP = true
PP()
}
id3Pego = true
trace("Finalmente o ID3 ficou pronto")
Tinf.text = (objEntrosa.id3.songName == null ? Musicas[rand][1] : objEntrosa.id3.songName) + " - " + (objEntrosa.id3.artist == null ? Musicas[rand][2] : objEntrosa.id3.artist)
Tinf.x = stage.stageWidth - Tinf.width
}
}
private function spec():void
{
objEntrosa.getByteArray()
ba = objEntrosa.ba
++ang
rY += ((mouseY * .066) - rY) * .1 //min = 0; max = 10
circ_back.graphics.clear()
circ_back.graphics.lineStyle(.5, /*amp * .66*/0x000000)
circ_back.graphics.moveTo(cX + Math.cos((ang) * rads) * rX, cY + Math.sin((ang) * rads) * rY)
circ_front.graphics.clear()
circ_front.graphics.lineStyle(.5, /*amp * .66*/0x000000)
circ_front.graphics.moveTo(cX + Math.cos((ang + i) * rads) * rX, cY + Math.sin((ang + i) * rads) * rY)
amp = 0
var a:Number = ang
var i:int = 0
while (i < 256)
{
var num:Number = ba.readFloat()
amp += num
var A:Number = a * rads
a += 1.4
var sin:Number = Math.sin(A)
var X:Number = Math.cos(A) * rX
var Y:Number = sin * rY
//trace("i",i, "cY",cY, "Y",Y, "num",num)
//trace(rY)
sin += 2
if (sin > 2)
{
//trace(">",i)
//acima
circ_front.graphics.lineTo(cX + X, cY + Y - num * 15)
if (sin < 2.022)
{
circ_back.graphics.moveTo(cX + X, cY + Y - num*15)
}
} else
{
//atrás
circ_back.graphics.lineTo(cX + X, cY + Y - num * 15)
if (sin > 1.96)
{
circ_front.graphics.moveTo(cX + X, cY + Y - num * 15)
}
}
++i
}
/*R2 = Math.random()
G2 = Math.random()
B2 = Math.random()
R += (R2 - R) * .2
G += (G2 - G) * .2
B += (B2 - B) * .2*/
//faz o draw da parte dos sons
data_sound.draw(stage, matrix, null, null, rect1)
//faz draw da parte dos menus
data_sound.draw(stage, matrix, null, null, rect2)
//faz draw da parte branca 1
data_sound.draw(stage, matrix, null, null,rect3)
//data_sound.draw(stage, matr)
movePart()
data_sound.scroll(0, -1)
data_sound.applyFilter(data_sound, data_sound.rect, new Point(0, 0), blur)
data_sound.colorTransform(data_sound.rect, col)
}
private function newPart():void
{
var i:int = 0
while (i < particulas)
{
posX[int(i)] = Math.random() * Ws
posY[int(i)] = Math.random() * Hs
veloX[int(i)] = Math.random() * 3 - 1.5
veloY[int(i)] = Math.random() * 3 - 1.5
++i
}
}
private function movePart():void
{
if (tempo > tempoMax)
{
trace("zero")
tempo = 0
data_perlin.draw(data_perlin2)
data_perlin2.perlinNoise(Ws, Hs, 2, Math.random()*Math.random()*100, false, true, 3)
}
++tempo
data_force.draw(data_perlin)
col_alpha.alphaMultiplier = tempo*.01
data_force.draw(data_perlin2, null, col_alpha)
var i:int = 0
while (i < particulas)
{
var X:Number = posX[int(i)]
var Y:Number = posY[int(i)]
var vX:Number = veloX[int(i)]
var vY:Number = veloY[int(i)]
var cor:String = data_force.getPixel(X, Y).toString(16)
var r:uint = uint(String("0x" + cor.charAt(0) + cor.charAt(1)))
var g:uint = uint(String("0x" + cor.charAt(2) + cor.charAt(3)))
vX += (r-127) / 510
vY += (g - 127) / 510
vX = vX>.5? .5 : vX<-.5? -.5 : vX
vY = vY>.5? .5 : vY<-.5? -.5 : vY
X += vX
Y += vY
//if(X < 0) trace("POHA", X)
X = X > Ws? X - Ws : X < 0? Ws - X : X
Y = Y > Hs? Y - Hs : Y < 0? Hs - Y : Y
data_sound.setPixel(X, Y+4, 0xFFFFFF)
posX[int(i)] = X
posY[int(i)] = Y
veloX[int(i)] = vX
veloY[int(i)] = vY
++i
}
}
}
}