0
如何從剛添加到它的Starling類中更改構造函數類的屬性。或者我如何調用從主類的盯着類的功能如何從Starling類更改構造函數類的屬性
在我的情況下如何更改FLA的mainClass中的對象的alpha,從starling類(PuzzleGame)和反之亦然。
我有這樣的:
public class MainClass extends Sprite
{
private var myStarling:Starling;
public var square:Sprite;
public function MainClass()
{
myStarling = new Starling(PuzzleGame, stage);
myStarling.start();
createAbox();
}
public function SendText()
{
trace("we are changing this in the main class")
}
public function createAbox()
{
square = new Sprite();
square.graphics.beginFill(0x0000FF);
square.graphics.drawRect(0,0,100,100);
square.graphics.endFill();
square.x = 100;
square.y = 100;
square.alpha = 0.5;
addChild(square);
square.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(ev:MouseEvent):void
{
this.square.alpha = 1;
//here how do i make the circle.alpha = 0.5;
//circle is an object created in the PuzzleGame
}
和
public class PuzzleGame extends Sprite
{
public var circle:Image;
public function PuzzleGame()
{
super();
trace("you are in PuzzleGame");
var s2:flash.display.Shape = new flash.display.Shape ;
s2.graphics.beginFill(0xff0000,1);
s2.graphics.drawCircle(40,40,40);
s2.graphics.endFill();
var bmpData:BitmapData = new BitmapData(100,100);
bmpData.draw(s2);
circle = Image.fromBitmap(new Bitmap(bmpData));
circle.x = 400;
circle.y = 150;
circle.alpha = 0.5;
addChild(circle);
circle.addEventListener(TouchEvent.TOUCH,onTouch);
}
private function onTouch(e:TouchEvent):void
{
parent.SendText();
var touch:Touch = e.getTouch(circle);
if (touch)
{
if (touch.phase == TouchPhase.ENDED)
{
circle.alpha = 1;
//here how do i make the square.alpha = 0.5
//something like parent.square.alpha = 0.5
}
}
}
可能這是相關的:http://stackoverflow.com/questions/16441734/send-data-from-flash-to-starling-class/16443089 #16443089 – Cherniv
welll:D我在谷歌和椋鳥foruns搜索了很多,但從來沒有看過那個頁面,但它說它不是一個真正的解決方案,所以,有什麼新的從那時起? – GregorII