我正在尝试使用ActionScript 3在Flash Pro中制作一个特定设备屏幕上的用户交互原型。需要在设备屏幕的真实尺寸中测试这个用户交互原型。测试将使用普通pc执行,但不是特定的,所以问题是如何在原型电影中设置设备屏幕的真实尺寸,以及如何控制和保持其尺寸,以适应任何可能的显示器屏幕尺寸和分辨率(真实世界屏幕尺寸的精确副本)。
换句话说:屏幕尺寸是2x1英寸,我需要在原型中保留这些尺寸。
我试着使用这种方法,但我没有正确应用它的技能水平:
this.addEventListener(Event.ENTER_FRAME,loop)
function loop(e:Event):void
{
trace(stage.stageWidth)
}提前感谢你们所有人!
发布于 2013-03-07 22:51:46
使用:
stage.addEventListener(Event.RESIZE, onStageResized, false, 0, true);
//and handler
protected function onStageResized(e:Event=null):void
{
//here code to do something with size change
}同样值得注意的是,你必须设置阶段,以不被调整大小,例如通过网页
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;发布于 2013-03-08 04:07:36
实际上,我在大约一年前创建了一个原型应用程序,用于在移动设备上执行此操作。我使用的是Flex,但是你可以通过这个来解决所有的数学问题。这是为移动设备制作的,但我认为这没有理由不能在桌面屏幕上运行。
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Declarations>
<fx:Number id="spacing">5</fx:Number>
</fx:Declarations>
<s:Rect id="rectangle" width="{this.sliderWidth.value}" height="{this.sliderHeight.value}" x="{this.spacing}" y="{this.spacing}">
<s:fill>
<s:SolidColor color="#ff000f"/>
</s:fill>
</s:Rect>
<s:VGroup bottom="10" width="100%"
horizontalAlign="center" gap="20"
left="{this.spacing * 2}" right="{this.spacing * 2}"
maxWidth="{this.width - 4 * this.spacing}">
<s:Label id="measurements" opaqueBackground="#ffffff"
text="
Box: {(this.rectangle.width/Capabilities.screenDPI).toFixed(2)}in x {(this.rectangle.height/Capabilities.screenDPI).toFixed(2)}in —
{this.rectangle.width}px x {this.rectangle.height}px"
textAlign="center" />
<s:Label id="screenStats" opaqueBackground="#ffffff"
text="
Screen DPI: {Capabilities.screenDPI} —
Resolution: {Capabilities.screenResolutionX}x{Capabilities.screenResolutionY} —
Size: {(Capabilities.screenResolutionX / Capabilities.screenDPI).toFixed(2)}in x {(Capabilities.screenResolutionY / Capabilities.screenDPI).toFixed(2)}in"
maxWidth="{this.width - 4 * this.spacing}"/>
<s:HGroup width="100%" horizontalAlign="center" verticalAlign="middle">
<s:Label text="Width:" opaqueBackground="#ffffff"/>
<s:HSlider id="sliderWidth" width="100%" height="5%"
maximum="{this.width - 2 * this.spacing}" minimum="{this.spacing}"
value="50" />
</s:HGroup>
<s:HGroup width="100%" horizontalAlign="center" verticalAlign="middle">
<s:Label text="Height:" opaqueBackground="#ffffff"/>
<s:HSlider id="sliderHeight" width="100%" height="5%"
maximum="{this.height - 2 * this.spacing}" minimum="{this.spacing}"
value="50"/>
</s:HGroup>
</s:VGroup>
</s:Application>我强烈建议把它放到一个快速的Flex项目中并运行它。基本上,它允许您在舞台上抛出一个红色矩形,并将其大小调整为像素大小,然后在屏幕上输出实际大小。自从我构建它以来,我还没有测试过它,但它在我的Nexus7和iPad 3上总是运行得很好,而且准确无误。这可能是错误的唯一可能性是如果设备报告了错误的screenDPI,闪存偶尔会这样做(DPI3有一段时间是错误的)。例如)。
https://stackoverflow.com/questions/15273857
复制相似问题