Tråd: Hello World.
View Single Post
Sitat av 10goto10 Vis innlegg
Ble imponert over marsboer's flash, men hvor i all verden er data'ene til "hello world" punktene som utgjør skriften? Så ingenting i koden du postet, marsboer.
Vis hele sitatet...
Akkurat "Hello World"-lysene er egentlig et movieclip, som blir utløst når kranen trykker knappen. Den heter forøvrig neon.play(); som starter avspillingen.

Ja, jeg tror jeg brøt reglene, hehe. Men denne gangen lager jeg noe annet som er nesten ren kode. En rotasjonskode der du må rotere bokstavene for å få dem i riktig rekkefølge.

http://flash.tripossible.no/rotasjonskode.html (eller rotasjonskode.swf)


Kode

var empty:String = "none";

var a1:String = "L";
var b1:String = "O";
var c1:String = "E";
var d1:String = "L";
var e1:String = "O";

var a2:String = "R";
var b2:String = "D";
var c2:String = "L";
var d2:String = "W";
var e2:String = "H";

a1T.text = a1.toString();
b1T.text = b1.toString();
c1T.text = c1.toString();
d1T.text = d1.toString();
e1T.text = e1.toString();
	
a2T.text = a2.toString();
b2T.text = b2.toString();
c2T.text = c2.toString();
d2T.text = d2.toString();
e2T.text = e2.toString();

var counting:uint = 0;

stage.addEventListener(Event.ENTER_FRAME, Update);

abLeft.addEventListener(MouseEvent.CLICK, abLeftFunc);
abRight.addEventListener(MouseEvent.CLICK, abRightFunc);

bcLeft.addEventListener(MouseEvent.CLICK, bcLeftFunc);
bcRight.addEventListener(MouseEvent.CLICK, bcRightFunc);

cdLeft.addEventListener(MouseEvent.CLICK, cdLeftFunc);
cdRight.addEventListener(MouseEvent.CLICK, cdRightFunc);

deLeft.addEventListener(MouseEvent.CLICK, deLeftFunc);
deRight.addEventListener(MouseEvent.CLICK, deRightFunc);

congrats.visible = false;
congrats.tryAgain.addEventListener(MouseEvent.CLICK, restartFunc);

function Update(e:Event):void
{
	a1T.text = a1.toString();
	b1T.text = b1.toString();
	c1T.text = c1.toString();
	d1T.text = d1.toString();
	e1T.text = e1.toString();
	
	a2T.text = a2.toString();
	b2T.text = b2.toString();
	c2T.text = c2.toString();
	d2T.text = d2.toString();
	e2T.text = e2.toString();
	
	countT.countN.text = counting.toString();
	
	if(a1 == "H" && b1 == "E" && c1 == "L" && d1 == "L" && e1 == "O" && a2 == "W" && b2 == "O" && c2 == "R" && d2 == "L" && e2 == "D")
	{
		trace("Hello, World");
		
		congrats.visible = true;
	}
}

function abLeftFunc(event:MouseEvent):void 
{
	empty = a1;
	a1 = b1;
	b1 = b2;
	b2 = a2;
	a2 = empty;
	
	counting += 1;
}

function abRightFunc(event:MouseEvent):void 
{
	empty = a1;
	a1 = a2;
	a2 = b2;
	b2 = b1;
	b1 = empty;
	
	counting += 1;
}

function bcLeftFunc(event:MouseEvent):void 
{
	empty = b1;
	b1 = c1;
	c1 = c2;
	c2 = b2;
	b2 = empty;
	
	counting += 1;
}

function bcRightFunc(event:MouseEvent):void 
{
	empty = b1;
	b1 = b2;
	b2 = c2;
	c2 = c1;
	c1 = empty;
	
	counting += 1;
}

function cdLeftFunc(event:MouseEvent):void 
{
	empty = c1;
	c1 = d1;
	d1 = d2;
	d2 = c2;
	c2 = empty;
	
	counting += 1;
}

function cdRightFunc(event:MouseEvent):void 
{
	empty = c1;
	c1 = c2;
	c2 = d2;
	d2 = d1;
	d1 = empty;
	
	counting += 1;
}

function deLeftFunc(event:MouseEvent):void 
{
	empty = d1;
	d1 = e1;
	e1 = e2;
	e2 = d2;
	d2 = empty;
	
	counting += 1;
}

function deRightFunc(event:MouseEvent):void 
{
	empty = d1;
	d1 = d2;
	d2 = e2;
	e2 = e1;
	e1 = empty;
	
	counting += 1;
}

function restartFunc(event:MouseEvent):void 
{
	congrats.visible = false;
	
	a1 = "L";
	b1 = "O";
	c1 = "E";
	d1 = "L";
	e1 = "O";

	a2 = "R";
	b2 = "D";
	c2 = "L";
	d2 = "W";
	e2 = "H";
	
	counting = 0;
}