Avatar billede danishhoward Nybegynder
26. maj 2009 - 11:17

Actionscript : Få movieclip fuldt fjernet, så de starter fra starten af igen

Jeg har følgende kode, hvor jeg på nuværende tid, har sat nogle variabler til at være enten 1023 eller derunder, hvor 1023 er aktiveret, som så starter et movieclip - og skulle egentlig gerne fjerne det igen, men når det loades ind igen, så starter det fra samme position som det blev fjernet, hvilket ikke er meningen.

Hjælp bitte :)

KODE -----------------------------------------------------

import fl.transitions.Tween;
import fl.transitions.easing.*;


stop();
// <<---------------------------------->>
// oprettelse af varibler
var circle_mc =        new circle();
var circle_mc1 =     new circle();
var firkant_mc=     new firkant();
var firkant_mc1 =     new firkant();
var trekant_mc=     new trekant();
var trekant_mc1 =     new trekant();
var polygon_mc=     new polygon();
var polygon_mc1 =     new polygon();
var pauseskaerm_mc1 =     new pauseskaerm();

var sensor_1:Number;
var sensor_2:Number;
var sensor_3:Number;
var sensor_4:Number;
var sensor_5:Number;
var sensor_6:Number;
var sensor_7:Number;
var sensor_8:Number;




function testlayers() {
sensor_1 = Number(testlayer.text);
sensor_2 = Number(testlayer.text);
sensor_3 = Number(testlayer.text);
sensor_4 = Number(testlayer.text);
sensor_5 = Number(testlayer.text);
sensor_6 = Number(testlayer.text);
sensor_7 = Number(testlayer.text);
sensor_8 = Number(testlayer.text);

}testlayers()


if(bgscreen.numChildren == 0) {bgscreen.addChild(pauseskaerm_mc1);}
// <<---------------------------------->>

// Begyndelse på mini-kontrol-clips, Bliver ikke vist,
// men er tilstede i baggrunden til at kontrollere, hvad der skal
// vises på bigscreen





var minTimer:Timer = new Timer(1000,1);

minTimer.addEventListener("timer", tidsfunktion);


function tidsfunktion(TimerEvent)
{
// Start the timer
minTimer.start();
trace(minTimer.currentCount);

    if(minTimer.currentCount == 1)
        {
            minTimer.reset();
           
            minTimer.start();
            sensor();
            testlayers();
           
           
        }
}





sensor();
function sensor() {



if(sensor_1 == 1023 && sensor_2 == 1023) {movie1.addChild(circle_mc);}
if(sensor_1 != 1023 || sensor_2 != 1023) {
    if( movie1.numChildren == 1) {
    movie1.removeChildAt(0);}
    }

if(sensor_1 == 1023 &&
  sensor_2 == 1023 &&
  sensor_3 == 1023 &&
  sensor_4 == 1023) {movie2.addChild(firkant_mc)}

if(sensor_1 != 1023 ||
  sensor_2 != 1023 ||
  sensor_3 != 1023 ||
  sensor_4 != 1023) {
    if(movie2.numChildren == 1) {
    movie2.removeChildAt(0);}
    }


if(sensor_3 == 1023 &&
  sensor_4 == 1023 &&
  sensor_7 == 1023 &&
  sensor_8 == 1023 ) {movie3.addChild(trekant_mc)}

if(sensor_3 != 1023 ||
  sensor_4 != 1023 ||
  sensor_7 != 1023 ||
  sensor_8 != 1023) {
    if(movie3.numChildren == 1) {
    movie3.removeChildAt(0);}
   
    }


if(sensor_1 == 1023 &&
  sensor_2 == 1023 &&
  sensor_3 == 1023 &&
  sensor_4 == 1023 &&
  sensor_5 == 1023 &&
  sensor_6 == 1023 &&
  sensor_7 == 1023 &&
  sensor_8 == 1023) {movie4.addChild(polygon_mc)}


if(sensor_1 != 1023 ||
  sensor_2 != 1023 ||
  sensor_3 != 1023 ||
  sensor_4 != 1023 ||
  sensor_5 != 1023 ||
  sensor_6 != 1023 ||
  sensor_7 != 1023 ||
  sensor_8 != 1023) {
    if(movie4.numChildren == 1) {
    movie4.removeChildAt(0);}
   
    }




// Slut på mini-kontrol-clips

// <<---------------------------------->>



// Tjekker om vores kontrol miniclips er aktive, hvis ja bliver de vist på
// bigscreen efter den valgte prioritet

bgscreen.background =  0xFFFFFF;
if(movie1.numChildren == 0 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 0 &&
  movie4.numChildren == 0) {trace("adder intet");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{bgscreen.removeChild(polygon_mc1); }

bgscreen.addChild(pauseskaerm_mc1);
pauseskaerm_mc1.play();


}

if(movie1.numChildren == 0 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 0 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();

}

if(movie1.numChildren == 0 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");
if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();

}

if(movie1.numChildren == 0 &&
  movie2.numChildren == 1 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();

}

if(movie1.numChildren == 1 &&
  movie2.numChildren == 1 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");



if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();


;}




if(movie1.numChildren == 1 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 0 &&
  movie4.numChildren == 0) {trace("movie 1 aktiv");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object polygon]")
  { bgscreen.removeChild(polygon_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(circle_mc1);



var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);


circle_mc1.play();

; }

if(movie1.numChildren == 1 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 0 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();

}

if(movie1.numChildren == 1 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 1) {trace("movie 4 aktiv");

if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{ bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }

bgscreen.addChild(polygon_mc1);

var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede5, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede6, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
polygon_mc1.play();

}



if(movie1.numChildren == 1 &&
  movie2.numChildren == 1 &&
  movie3.numChildren == 0 &&
  movie4.numChildren == 0) {trace("movie 2 aktiv");




if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{ bgscreen.removeChild(polygon_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object trekant]")
{bgscreen.removeChild(trekant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }



bgscreen.addChild(firkant_mc1);
var myTweenAlpha:Tween = new Tween(saede1, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede2, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
firkant_mc1.play();

}

if(movie1.numChildren == 1 &&
  movie2.numChildren == 1 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 0) {trace("movie 3 aktiv");



if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{ bgscreen.removeChild(polygon_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }



bgscreen.addChild(trekant_mc1);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
trekant_mc1.play();

}

if(movie1.numChildren == 0 &&
  movie2.numChildren == 1 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 0) {trace("movie 3 aktiv");


if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{ bgscreen.removeChild(polygon_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }



bgscreen.addChild(trekant_mc1);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
trekant_mc1.play();

}

if(movie1.numChildren == 1 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 0) {trace("movie 3 aktiv");


if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{ bgscreen.removeChild(polygon_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }



bgscreen.addChild(trekant_mc1);
var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);
trekant_mc1.play();
}

if(movie1.numChildren == 0 &&
  movie2.numChildren == 0 &&
  movie3.numChildren == 1 &&
  movie4.numChildren == 0) {trace("movie 3 aktiv");


if(bgscreen.getChildAt(0).toString() == "[object polygon]")
{ bgscreen.removeChild(polygon_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object circle]")
  { bgscreen.removeChild(circle_mc1);}
 
else if(bgscreen.getChildAt(0).toString() == "[object firkant]")
{bgscreen.removeChild(firkant_mc1); }

else if(bgscreen.getChildAt(0).toString() == "[object pauseskaerm]")
{bgscreen.removeChild(pauseskaerm_mc1); }



bgscreen.addChild(trekant_mc1);
trekant_mc1.play();

var myTweenAlpha:Tween = new Tween(saede3, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede4, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede7, "alpha", Strong.easeOut, 0, 1, 3, true);
var myTweenAlpha:Tween = new Tween(saede8, "alpha", Strong.easeOut, 0, 1, 3, true);



}
}
// <<---------------------------------->>
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester



IT-JOB

Metroselskabet og Hovedstadens Letbane

BIM Coordinator

Unik System Design A/S

Strategic Customer Success Manager

Normann Copenhagen ApS

Product Data Specialist