PDA

View Full Version : Accessing the root of My Clip



jocenunes
August 12th, 2008, 10:04 AM
Good evening is following, I am finishing a site, and I am inside a movie clip, and within it I have a movie clip that when I clip it has to go to the root, access a movieclip on stage and perform it within a Frame,, I do not know how to access already tried several ways, ... But I do not know how it is because this movie clip is placed on stage with addChild ... I am sorry I rookie lack of knowledge.

The logic is that he has to go in and root access the movie clip loaded with addChild - quadUm within it pgServicos.gotoAndStop (2)


My code in Timeline


stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;


//variaveis
var objectCom:Number = links.home_quad.quadDesc_mc.height;
var objectComEmp:Number = links.empresa_quad.quadDescEmp_mc.height;
var objectComSer:Number = links.servicos_quad.quadDescSer_mc.height;
var objectComCli:Number = links.clientes_quad.quadDescCli_mc.height;
var objectComPor:Number = links.portfolio_quad.quadDescPor_mc.height;
var objectComCon:Number = links.contato_quad.quadDescCon_mc.height;





//variavel do quadrado um
var quadUm:Um;
// variavel do quadrado dois
var quadDois:Dois;
// frame pega o valor do botão para ir para o frame
var frame:Number;
var frameVideo:Number;

//cria o quadrado um e quadrad dois
quadUm = new Um();
quadDois = new Dois();



//variaveis de posição do quadrado um e dois da tela X
var quadUmX:Number = 250;
var quadDoisX:Number = 490;

//valores dos quadrado um e dois
quadUm.x = quadUmX;
quadDois.x = quadDoisX;
quadUm.y = 210;
quadDois.y = 210;



//fazar a primeira animação
stage.addEventListener(Event.ENTER_FRAME, andar);


//botaum um
links.home.addEventListener(MouseEvent.CLICK, btn);
links.home.addEventListener(MouseEvent.MOUSE_OVER, efeitoOver);
links.home.addEventListener(MouseEvent.MOUSE_OUT, efeitoOut);
//botaum dois
links.empresa.addEventListener(MouseEvent.CLICK, btn2);
links.empresa.addEventListener(MouseEvent.MOUSE_OV ER, efeitoOverEmp);
links.empresa.addEventListener(MouseEvent.MOUSE_OU T, efeitoOutEmp);
//botaum tres
links.servicos.addEventListener(MouseEvent.CLICK, btn3);
links.servicos.addEventListener(MouseEvent.MOUSE_O VER, efeitoOverSer);
links.servicos.addEventListener(MouseEvent.MOUSE_O UT, efeitoOutSer);
//botaum quatro
links.clientes.addEventListener(MouseEvent.CLICK, btn4);
links.clientes.addEventListener(MouseEvent.MOUSE_O VER, efeitoOverCli);
links.clientes.addEventListener(MouseEvent.MOUSE_O UT, efeitoOutCli);

links.portfolio.addEventListener(MouseEvent.CLICK, btn5);
links.portfolio.addEventListener(MouseEvent.MOUSE_ OVER, efeitoOverPor);
links.portfolio.addEventListener(MouseEvent.MOUSE_ OUT, efeitoOutPor);

links.contato.addEventListener(MouseEvent.CLICK, btn6);
links.contato.addEventListener(MouseEvent.MOUSE_OV ER, efeitoOverCon);
links.contato.addEventListener(MouseEvent.MOUSE_OU T, efeitoOutCon);







//função do botão um
function btn(event:MouseEvent):void {

stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 1;
links.gotoAndStop(35);
links.home.gotoAndStop(2);
links.empresa.gotoAndStop(1);
links.servicos.gotoAndStop(1);
links.clientes.gotoAndStop(1);
links.portfolio.gotoAndStop(1);
links.contato.gotoAndStop(1);


}

//função do botão dois
function btn2(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 2;
links.gotoAndStop(35);
links.home.gotoAndStop(1);
links.empresa.gotoAndStop(2);
links.servicos.gotoAndStop(1);
links.clientes.gotoAndStop(1);
links.portfolio.gotoAndStop(1);
links.contato.gotoAndStop(1);
}

//função do botão tres
function btn3(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 3;
links.gotoAndStop(35);
links.home.gotoAndStop(1);
links.empresa.gotoAndStop(1);
links.servicos.gotoAndStop(2);
links.clientes.gotoAndStop(1);
links.portfolio.gotoAndStop(1);
links.contato.gotoAndStop(1);

}

//função do botão quatro
function btn4(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 4;
links.gotoAndStop(35);
links.home.gotoAndStop(1);
links.empresa.gotoAndStop(1);
links.servicos.gotoAndStop(1);
links.clientes.gotoAndStop(2);
links.portfolio.gotoAndStop(1);
links.contato.gotoAndStop(1);

}
function btn5(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 5;
links.gotoAndStop(35);
links.home.gotoAndStop(1);
links.empresa.gotoAndStop(1);
links.servicos.gotoAndStop(1);
links.clientes.gotoAndStop(1);
links.portfolio.gotoAndStop(2);
links.contato.gotoAndStop(1);
}
function btn6(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, andar2);
frame = 6;
links.gotoAndStop(35);
links.home.gotoAndStop(1);
links.empresa.gotoAndStop(1);
links.servicos.gotoAndStop(1);
links.clientes.gotoAndStop(1);
links.portfolio.gotoAndStop(1);
links.contato.gotoAndStop(2);
}

//função que faz o objeto andar na primeir parte
function andar(event:Event):void {

stage.removeEventListener(Event.ENTER_FRAME,andar2 );


addChild(quadUm);// colocar o quadado um no stage
addChild(quadDois);// coloca o quadrado dois no stage

quadUm.x += 15;//faz andar quadrado um de 15 em 15
quadDois.x -= 15;//faz voltar quadrado um de 15 em 15

if (quadUm.x == quadDoisX || quadDois.x == quadUmX) {
stage.removeEventListener(Event.ENTER_FRAME, andar);
}
if (quadDois.x == quadUm.x) {
quadUm.gotoAndStop(frame);
quadDois.gotoAndStop(frame);
fundo_mc.gotoAndStop(frame);
}
}


//função que faz voltar o quadrado apos clicar.
function andar2(event:Event):void {

removeChild(quadUm);// remove do stage
removeChild(quadDois);// remove do stage

addChild(quadDois);// coloca no stage
addChild(quadUm);//coloca no stage


quadDois.x += 15;// andar
quadUm.x -= 15;// volta


//se a condição for verdadeira ele para o andar dois e executa o andar um
if (quadUm.x == quadUmX) {
stage.addEventListener(Event.ENTER_FRAME, andar);
}

}



function efeitoOver(e:MouseEvent):void {
new Tween(links.home_quad.quadDesc_mc,"height",Strong.easeOut,objectCom,objectCom+10,10,false);

}
function efeitoOut(e:MouseEvent):void {
new Tween(links.home_quad.quadDesc_mc,"height",Strong.easeOut,links.home_quad.quadDesc_mc.height ,objectCom,10,false);
}

function efeitoOverEmp(e:MouseEvent):void {
new Tween(links.empresa_quad.quadDescEmp_mc,"height",Strong.easeOut,objectComEmp,objectComEmp+10,10,fa lse);

}
function efeitoOutEmp(e:MouseEvent):void {
new Tween(links.empresa_quad.quadDescEmp_mc,"height",Strong.easeOut,links.empresa_quad.quadDescEmp_mc. height,objectComEmp,10,false);
}
function efeitoOverSer(e:MouseEvent):void {
new Tween(links.servicos_quad.quadDescSer_mc,"height",Strong.easeOut,objectComSer,objectComSer+10,10,fa lse);

}
function efeitoOutSer(e:MouseEvent):void {
new Tween(links.servicos_quad.quadDescSer_mc,"height",Strong.easeOut,links.servicos_quad.quadDescSer_mc .height,objectComSer,10,false);
}
function efeitoOverCli(e:MouseEvent):void {
new Tween(links.clientes_quad.quadDescCli_mc,"height",Strong.easeOut,objectComCli,objectComCli+10,10,fa lse);

}
function efeitoOutCli(e:MouseEvent):void {
new Tween(links.clientes_quad.quadDescCli_mc,"height",Strong.easeOut,links.clientes_quad.quadDescCli_mc .height,objectComCli,10,false);
}

function efeitoOverPor(e:MouseEvent):void {
new Tween(links.portfolio_quad.quadDescPor_mc,"height",Strong.easeOut,objectComPor,objectComPor+10,10,fa lse);

}
function efeitoOutPor(e:MouseEvent):void {
new Tween(links.portfolio_quad.quadDescPor_mc,"height",Strong.easeOut,links.portfolio_quad.quadDescPor_m c.height,objectComPor,10,false);
}
function efeitoOverCon(e:MouseEvent):void {
new Tween(links.contato_quad.quadDescCon_mc,"height",Strong.easeOut,objectComCon,objectComCon+10,10,fa lse);

}
function efeitoOutCon(e:MouseEvent):void {
new Tween(links.contato_quad.quadDescCon_mc,"height",Strong.easeOut,links.contato_quad.quadDescCon_mc. height,objectComPor,10,false);
}




links.home.buttonMode = true;
links.empresa.buttonMode = true;
links.servicos.buttonMode = true;
links.clientes.buttonMode = true;
links.portfolio.buttonMode = true;
links.contato.buttonMode = true;
quadUm.videoMaquina.buttonMode = true;


my code into MovieClip quadDois

fotolito.addEventListener(MouseEvent.MOUSE_OVER, servOver);
fotolito.addEventListener(MouseEvent.MOUSE_OUT, servOut);
fotolito.addEventListener(MouseEvent.MOUSE_OUT, servClick);


gravacao.addEventListener(MouseEvent.MOUSE_OVER, servOver);
gravacao.addEventListener(MouseEvent.MOUSE_OUT, servOut);

estLocalizada.addEventListener(MouseEvent.MOUSE_OV ER, servOver);
estLocalizada.addEventListener(MouseEvent.MOUSE_OU T, servOut);

estFrontal.addEventListener(MouseEvent.MOUSE_OVER, servOver);
estFrontal.addEventListener(MouseEvent.MOUSE_OUT, servOut);

maquinaCarrosel.addEventListener(MouseEvent.MOUSE_ OVER, servOver);
maquinaCarrosel.addEventListener(MouseEvent.MOUSE_ OUT, servOut);

aerografo.addEventListener(MouseEvent.MOUSE_OVER, servOver);
aerografo.addEventListener(MouseEvent.MOUSE_OUT, servOut);

prensa.addEventListener(MouseEvent.MOUSE_OVER, servOver);
prensa.addEventListener(MouseEvent.MOUSE_OUT, servOut);


function servOver(e:Event):void
{
var nome:String = e.currentTarget.name;
linksServ_mc.gotoAndStop(nome);
servCirculo.sergira_mc.alpha = 0.5;
}
function servOut(e:Event):void
{
linksServ_mc.gotoAndStop(1);
servCirculo.sergira_mc.alpha = 1;
}

function servClick(e:Event):void
{
root.quadUm.pgServicos.gotoAndStop(2);
}



error: 1119: Access of possibly undefined property quadUm through a reference with static type flash.display:DisplayObject.

thanks

ratstew
August 12th, 2008, 10:31 AM
just starting out with as3 myself so i may be wrong but try calling the movieclip with stage instead of root since you addChild to stage.

stage.quadUm.pgServicos.gotoAndStop(2);

this should gotoAndStop at frame 2 within pgServicos which is within quadUm at the top level.

jocenunes
August 12th, 2008, 10:57 AM
generates error, 1119: Access of possibly undefined property quadUm through a reference with static type flash.display: Stage.


The event, Click is within the quadDois, when clicked it has to go on stage and access the quadDois after pgServicos and go in the frame 3 ...

need so much lack of help to end this web site ...

I am a novice in as3

toscaner
August 12th, 2008, 12:30 PM
(root as MovieClip).

only if root IS a movieclip