表面上的 Playbook AIR SDK 圖像 (Playbook AIR SDK images on surface)


問題描述

表面上的 Playbook AIR SDK 圖像 (Playbook AIR SDK images on surface)

I am trying to write a Playbook app using the AIR SDK, I need a surface of some kind that I can load a large image onto, then subsequently place some smaller images on top of and add the whole lot to a ScrollPane so I can pan it around the screen.

I have tried by adding the image to a sprite and displaying that in a group in the application but the image does not show up.

What is the correct surface kind I should be using here and how should I be loading the images? (currently using "Embed" and loading the image into a BitmapAsset.)

Thanks

EDIT:

        var scroll:ScrollPane = new ScrollPane();

        scroll.setScrollContent(image);
        scroll.update();

        scroll.graphics.beginBitmapFill(icon.bitmapData);
        scroll.graphics.drawRect(100,100,56,56);
        scroll.graphics.endFill();

        scroll.update();

This code causes a non‑moving icon to be drawn behind the scrollContent, I want to add something on top of the scroll content that moves with it.

‑‑‑‑‑

參考解法

方法 1:

Rather than adding your images via the graphics api, you need to be adding components as I mentioned in the comment.  Now that I know you're trying to use the QNX component set, the situation is a little different.

What you need to do is stick with the QNX components if at all possible otherwise they may not get updated in the display list properly (like things being drawn in the background like you're experiencing)

For the images you should be using something like this : 

var newImg : qnx.ui.display.Image = new qnx.ui.display.Image();
newImage.setImage( youImgObj );

For adding containers like you mentioned, you should be using (or similar) : 

qnx.ui.core.Container

Then you should find things are drawn in a predictable order (last obj added is on top of stage).

方法 2:

Make your own custom component (you can put it on a ScrollPane later) and draw the images yourself ‑

MyComp.mxml:

<?xml version="1.0" encoding="utf‑8"?>
<s:ViewNavigatorApplication 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    firstView="views.MyCompHomeView">
</s:ViewNavigatorApplication>

views\MyCompHomeView.mxml:

<?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"
    xmlns:comps="comps.*" title="HomeView">
    <comps:MyRect width="100%" height="100%"/>
</s:View>

comps\MyRect.mxml (draws a red rectangle with shadow underneath):

<?xml version="1.0" encoding="utf‑8"?>
<mx:UIComponent xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx"
    width="100%" height="100%">

    <fx:Script>
        <![CDATA[
            import flash.filters.*;

            public static const SHADOW:Array = [ 
                        new DropShadowFilter(10, 80, 0x000000, 
                        0.5, 32, 32, 1, 1, false, false, false) ];
            public static const GLOW:Array = [ 
                        new GlowFilter(0xFFFF00, 0.5, 
                        36, 36, 1, 1, false, false) ];

            private var rect:Shape = new Shape();

            override protected function createChildren():void {
                super.createChildren();
                rect.graphics.beginFill(0xFF0000);
                rect.graphics.drawRect(0, 0, 20, 20);
                rect.filters = SHADOW;
                addChild(rect);
            }

            override protected function updateDisplayList(
                        unscaledWidth:Number,
                        unscaledHeight:Number):void {

                super.updateDisplayList(
                    unscaledWidth, unscaledHeight);
                rect.x = unscaledWidth / 2;
                rect.y = unscaledHeight / 2;
            }
        ]]>
    </fx:Script>
</mx:UIComponent>

(by HamidNateAlexander Farber)

參考文件

  1. Playbook AIR SDK images on surface (CC BY‑SA 3.0/4.0)

#air #image #blackberry-playbook #apache-flex






相關問題

如何在 Adobe Air 的 LIKE 運算符模式中使用命名參數 (How to use named parameters inside LIKE operator pattern in Adobe Air)

Android 和 Flash Professional CS 5 Adobe Air Audio:流錯誤 (Android & Flash Professional CS 5 Adobe Air Audio: Stream Error)

可以從 web 視圖中的鏈接觸發我的 Air 應用程序中的操作嗎? (It's possible to trigger an action in my Air app, from a link in a webview?)

動作腳本、NativeProcess、resolvePath 和 swf 不起作用 (Action script, NativeProcess , resolvePath and swf does not work)

如何在創建新線程的同時停止運行線程並恢復同一個線程? (how to stop running thread and resume the same thread beside create new thread?)

我怎樣才能很好地在視圖堆棧之間製作動畫 (How can I nicely animate between viewstacks)

Adobe AIR 從 Flash 是一場大災難? (Adobe AIR from Flash a big disaster?)

“Adobe Flex”和使用 fl.controls 和 fl.events 庫的 AS3 應用程序有什麼區別? (what is the difference between "Adobe Flex" and an AS3 app using fl.controls and fl.events libraries?)

表面上的 Playbook AIR SDK 圖像 (Playbook AIR SDK images on surface)

Adobe AIR 應用程序音頻 (Adobe AIR application audio)

需要在 AIR 上設置 cookie 標頭,使用 SWFLoader 檢索遠程 Flex .swf 文件 (Need to set cookie header on AIR use of SWFLoader to retrieve remote Flex .swf file)

AIR 應用程序的 ActionScript 項目? (ActionScript Project to AIR Application?)







留言討論