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:將所有內(nèi)容移動(dòng)到一個(gè)容器中。移動(dòng)一個(gè)對(duì)象比移動(dòng)多個(gè)對(duì)象更容易。
多個(gè)對(duì)象:
0:MainTimeline
0:background_scroll_product //.y += offsetY;
1:davies //.y += offsetY;
2:toa //.y += offsetY;
...
一個(gè)對(duì)象:
0:MainTimeline
0:container //.y += offsetY;
0:background_scroll_product
1:davies
2:toa
...
示范
下面的代碼,你可以拖放到一個(gè)新的項(xiàng)目,它將與編譯工作滾動(dòng)容器。請(qǐng)注意,其他人在問(wèn)問(wèn)題時(shí)可能需要這樣的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;
}
響應(yīng)FLA
我強(qiáng)烈建議你不要用工作場(chǎng)景,特別是因?yàn)樗麄儎?chuàng)造骯臟的國(guó)家不是迫切辨認(rèn)。事實(shí)上,由于您似乎正在努力實(shí)現(xiàn)移動(dòng)應(yīng)用,您絕對(duì)應(yīng)該考慮使用完整的UI框架,如FeathersUI。不管...
揮之不去的集裝箱
的Timeline試圖把每一幀作為程序的唯一狀態(tài)。您可以通過(guò)這種方式直觀地構(gòu)建用戶界面,但它很笨拙。此外,正如您發(fā)現(xiàn)的那樣,當(dāng)您將WYSIWYG與功能性編程混合在一起時(shí),Flash UI永遠(yuǎn)不會(huì)意識(shí)到并永遠(yuǎn)不會(huì)“清理”。您手動(dòng)添加了addChild(container),因此您還需要手動(dòng)添加removeChild(container)。你可以把它放在你的監(jiān)聽(tīng)器函數(shù)里面,作為后退按鈕。
集裝箱懸停在標(biāo)題欄
考慮你的主菜單heiarchy:
0: instance15 (Shape)
1: button_back (SimpleButton)
2: instance16 (StaticText)
3: container (Sprite)
正如你所看到的,層0通過(guò)2是你的頂部菜單的對(duì)象。在菜單后面移動(dòng)container與調(diào)用addChildAt()一樣簡(jiǎn)單,并將第二個(gè)參數(shù)設(shè)置為0索引。
addChildAt(container, 0);
最后圖像被剪輯
這樣做的原因是,你的內(nèi)容不位于y:0。如果要解決這個(gè)問(wèn)題,無(wú)論是在y:0移動(dòng)到開(kāi)始的內(nèi)容,或加上抵消你的第一個(gè)圖形的最小值的...
"min":this.loaderInfo.height - container.height - davies.y
總結(jié)
以上是生活随笔為你收集整理的android air flash,在Adobe Flash上触摸滚动Android上的Air的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: delphi7 如何判定dbgrid两行
- 下一篇: oracle证书洛阳,ORACLE手工建