android air flash,在Adobe Flash上触摸滚动Android上的Air
解決方案
1:嘗試用以下替換Math.max(Math.min(maxY, _startY + offsetY), minY);:
clamp(mouseY - _startY + offsetY, minY, maxY);
function clamp(original:Number, low:Number, high:Number):Number {
return (original > high) ? high : (original < low) ? low : original;
}
2:將所有內容移動到一個容器中。移動一個對象比移動多個對象更容易。
多個對象:
0:MainTimeline
0:background_scroll_product //.y += offsetY;
1:davies //.y += offsetY;
2:toa //.y += offsetY;
...
一個對象:
0:MainTimeline
0:container //.y += offsetY;
0:background_scroll_product
1:davies
2:toa
...
示范
下面的代碼,你可以拖放到一個新的項目,它將與編譯工作滾動容器。請注意,其他人在問問題時可能需要這樣的Minimal, Complete, and Verifiable example。
var background_scroll_product, davies, toa;
demoSetup();
/* ^^^ Omit this if you already have these objects defined ^^^ */
// Create a container for our content.
var container:Sprite = new Sprite();
addChild(container);
// Put the content inside the container.
container.addChild(background_scroll_product);
container.addChild(davies);
container.addChild(toa);
// setup the min based on the size of the contents.
var loc:Object = {
"max":50,
"min":stage.stageHeight - container.height
};
addEventListener("mouseDown", mouseHandler);
function mouseHandler(e:Event):void {
switch (e.type) {
case "mouseDown":
loc.start = mouseY;
loc.container = container.y;
addEventListener("mouseUp", mouseHandler);
addEventListener("mouseMove", mouseHandler);
break;
case "mouseUp":
removeEventListener("mouseUp", mouseHandler)
removeEventListener("mouseMove", mouseHandler);
break;
case "mouseMove":
// Scroll the container.
container.y = clamp(mouseY - loc.start + loc.container, loc.min, loc.max);
break;
}
}
function clamp(original:Number, low:Number, high:Number):Number {
return (original > high) ? high : (original < low) ? low : original;
}
function demoSetup():void {
// This sets up a facsimile of the project, to create a Minimal, and Verifiable example.
var bg:Sprite = new Sprite();
bg.graphics.beginFill(0xA1A1A1);
bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
bg.graphics.endFill();
addChild(bg);
background_scroll_product = new Shape();
background_scroll_product.graphics.beginFill(0xf0e3e5);
background_scroll_product.graphics.drawRect(0, 0, 250, 750);
background_scroll_product.graphics.endFill();
davies = new Shape();
davies.graphics.beginFill(0x243066);
davies.graphics.drawRect(0, 0, 200, 400);
davies.graphics.endFill();
davies.x = davies.y = 25;
toa = new Shape();
toa.graphics.beginFill(0xdc3734);
toa.graphics.drawRect(0, 0, 200, 200);
toa.graphics.endFill();
toa.x = 25;
toa.y = 525;
}
響應FLA
我強烈建議你不要用工作場景,特別是因為他們創造骯臟的國家不是迫切辨認。事實上,由于您似乎正在努力實現移動應用,您絕對應該考慮使用完整的UI框架,如FeathersUI。不管...
揮之不去的集裝箱
的Timeline試圖把每一幀作為程序的唯一狀態。您可以通過這種方式直觀地構建用戶界面,但它很笨拙。此外,正如您發現的那樣,當您將WYSIWYG與功能性編程混合在一起時,Flash UI永遠不會意識到并永遠不會“清理”。您手動添加了addChild(container),因此您還需要手動添加removeChild(container)。你可以把它放在你的監聽器函數里面,作為后退按鈕。
集裝箱懸停在標題欄
考慮你的主菜單heiarchy:
0: instance15 (Shape)
1: button_back (SimpleButton)
2: instance16 (StaticText)
3: container (Sprite)
正如你所看到的,層0通過2是你的頂部菜單的對象。在菜單后面移動container與調用addChildAt()一樣簡單,并將第二個參數設置為0索引。
addChildAt(container, 0);
最后圖像被剪輯
這樣做的原因是,你的內容不位于y:0。如果要解決這個問題,無論是在y:0移動到開始的內容,或加上抵消你的第一個圖形的最小值的...
"min":this.loaderInfo.height - container.height - davies.y
總結
以上是生活随笔為你收集整理的android air flash,在Adobe Flash上触摸滚动Android上的Air的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: delphi7 如何判定dbgrid两行
- 下一篇: oracle证书洛阳,ORACLE手工建