English 中文(简体)
AIR - PhaseWebView.
原标题:AIR - StageWebView on iPhone

我正在利用第4.5号闪电机建造一个 iPhone。

为了展示第一版,计划使用“电网”和装上载有“密码”的网页。

请允许我说,这辆汽车是320x50个。 因此,《行动守则》将采取类似做法:

adView = new StageWebView();
adView.loadURL("http://www.myadishere.com/ad.html");
var top:Number = navigator.actionBar.measuredHeight + 1
adView.viewPort = new Rectangle(0, top, 320, 50);
adView.stage = stage;

In the application I have set the applicationDPI="160" so the application is displayed properly when run on iPhone3 and iPhone4. However the content of the StageWebView looks tiny on iPhone4. If I do adView.drawViewPortToBitmapData() the bitmap s size is OK.

因此,问题是,如何使阶段网的电文内容相应地扩大,这样,不论新闻部的屏幕如何,都看着科索沃?

最佳回答
 You need to scale by yourself. Here is sample code.


<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%" top="0">
    <fx:Declarations>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            import mx.core.IVisualElement;
            import mx.events.FlexEvent;

            import spark.components.View;
            import spark.events.ViewNavigatorEvent;

            [Bindable]
            public var htmlText:String;
            public var url:String;
            private var swv:StageWebView;
            private function resizeSWV():void{
                var currentFlexScalingFactor:Number=FlexGlobals.topLevelApplication.runtimeDPI/FlexGlobals.topLevelApplication.applicationDPI;
                if(swv!=null){

    //swv.viewPort=new Rectangle(0, stage.stageHeight-height*currentFlexScalingFactor-FlexGlobals.topLevelApplication.tabbedNavigator.tabBar.height*currentFlexScalingFactor,width*currentFlexScalingFactor,height*currentFlexScalingFactor);

    swv.viewPort=new Rectangle(0, systemManager.screen.height*currentFlexScalingFactor-height*currentFlexScalingFactor-FlexGlobals.topLevelApplication.tabbedNavigator.tabBar.height*currentFlexScalingFactor,width*currentFlexScalingFactor,height*currentFlexScalingFactor);

                }
            }

        ]]>
    </fx:Script>
    <s:creationComplete>
        <![CDATA[
        swv=new StageWebView();
        resizeSWV();
        swv.stage=stage;


        var htmlString:String=htmlText;
        var urlL:String=url;

        swv.loadURL(url);
        (owner as View).addEventListener(ViewNavigatorEvent.REMOVING,
        function(event:ViewNavigatorEvent):void{
            swv.viewPort=null;
            swv.dispose();
            swv=null;
        }
        );
        ]]>
    </s:creationComplete>
    <s:resize>
        resizeSWV();
    </s:resize>
</s:Group>

 This is for TabbedViewNavigatorApplication.
问题回答

在<代码><head>节中添加以下代码:

<meta name="viewport" content="width=XXXpx, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

将“三十”改为“三十”字。 这将使情况与你打算的规模看齐。

@OMA 我认为,“阶段网”是一小ug。 当(以超文本形式)我说:

<meta name="viewport" content="initial-scale=x.x">

the iPhone app crashes. Any ...-scale crashes the app. Without the ...-scale instruction it works fine.

目前,我手法是:

<meta name="viewport" content="width=320px, height=50px, user-scalable=no"> 
<style type="text/css">

body, html {margin: 0 0; padding: 0 0; overflow: hidden;}
body {width: 320px; height: 50px;}
html {height: 50px;}

这类工程——ADL显示内容不准确,但在大多数情况下,Piper本身显示的是应该做的。 然而,有时当事人的体积为半部分,但不能确定为何如此——它完全是同一个超文本页和相同的《航空法》全时都有,但当事人的表现方式有所不同。

在这方面,我是怎样做的:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
viewActivate="openSWV(event)"
viewDeactivate="closeSWV(event)">

    <s:states>
        <s:State name="portrait"/>
        <s:State name="landscape"/>
    </s:states> 

    <s:navigationContent>
        <s:Button icon="@Embed( assets/icons/back.png )" label.landscape="Back" click="navigator.popView()"/>
    </s:navigationContent>

    <s:titleContent>
        <s:Label text="Help" color="#FFFFFF" textAlign="center" fontWeight="bold" width="100%" />
    </s:titleContent>

    <fx:Declarations>
        <fx:String id="_help">
            <![CDATA[
            <html>
            <body>
            <p>Blah blah blah</p>
            </body>
            </html>
            ]]>
        </fx:String>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            import mx.events.FlexEvent;
            import flash.media.StageWebView;

            private var _swv:StageWebView;

            private function openSWV(event:Event=null):void {
                _swv = new StageWebView();
                stage.addEventListener(Event.RESIZE, resizeSWV);

                _swv.stage = stage;
                resizeSWV();

                _swv.loadString(_help,  text/html );
            }

            private function closeSWV(event:Event=null):void {
                stage.removeEventListener(Event.RESIZE, resizeSWV);
                if (! _swv)
                    return;
                _swv.dispose();
                _swv = null;
            }           

            private function resizeSWV(event:Event=null):void {
                if (! _swv)
                    return;

                var scale:Number = FlexGlobals.topLevelApplication.runtimeDPI / FlexGlobals.topLevelApplication.applicationDPI;

                // align to the right-bottom corner
                _swv.viewPort = new Rectangle(stage.stageWidth - scale * width, stage.stageHeight - scale * height, scale * width, scale * height);

            }
        ]]>
    </fx:Script>
</s:View>

我赞成右上角,因为我使用

如果你只是想与底线一致,那么就应该做到:

_swv.viewPort = new Rectangle(0, stage.stageHeight - scale * height, scale * width, scale * height);

第一,你为什么需要人工确定新闻部? 问题在于讲英语的4 新闻部比160多得多(我认为它翻了一番,但我没有用这个词说话)。 为什么仅仅根据相对价值(百分比)重新适用,或者甚至根据决议有不同的规定。 你们总是可以检查<代码>Capabilities.pixelAspectRatio,看看一看复制件,并相应修改内容。

同样,如果是我的话,我会把百分比用于大多数事情。 这种做法越好越好,而且总体而言,你们的法典就越少。





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签