1

興味のあるポイントを含むマップを作成しています。(POI) ユーザーが POI の上にマウスを置くと、情報バブルが画面に表示され、swf が読み込まれます。現在、3つの問題があります。私の 4 番目の問題は、これが月曜日の 21 日に締め切られることです。どんな助けでも大歓迎です!

  1. swf のサイズを検出できないため、infobubble のサイズが swf のサイズに合わせられます。

  2. swf ファイルにマウスを合わせると、そのファイルが消えます。

  3. メインの flex ファイルのステージではなく、swf ファイルを独自のレイヤーにポップアップ表示したいのですが、これを行う方法がわかりません。

package com.modestmaps
{
import flash.display.Graphics;
import flash.display.Loader;
import flash.display.Shape;
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.text.TextField;

public class InfoBubble extends Sprite
{
public var textField:TextField;
public var background:Shape;
public var shadow:Shape;

public function InfoBubble(text:String)
{
//I name the instance of my POI marker on my map to the url link of my swf file. So whatever marker i click on the correct url will
this.name = urlLink;

this.mouseEnabled = true;
this.mouseChildren = false;

//this creates a shadow behind my infobubble
shadow = new Shape();
shadow.filters = [ new BlurFilter(16, 16) ];
shadow.transform.matrix = new Matrix(1, 0, -0.5, 0.5, 0, 0);
addChild(shadow);

background = new Shape();
addChild(background);

textField = new TextField();
textField.selectable = true;
textField.multiline = true;
textField.wordWrap = true;
//textField.text = urlLink;


textField.width = textField.textWidth+300;
textField.height = textField.textHeight+288;
//addChild(textField);

var request:URLRequest = new URLRequest(urlLink);
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);

//marker clips are positioned with (0,0) at the given location
//current measurements of swf file w432 h288
//if i could dynamically determine the size of the loaded swf file its position would be automatically calculated

loader.y = -288 - 37;
loader.x = -8;


//marker clips are positioned with (0,0) at the given location
textField.y = -textField.height - 35;
textField.x = -10;

//currently my rectangle's size is determined by the textField size. I don't even use the textfield. I want the rectangle to be drawn using the dimensions of the swf file instead.
var rect:Rectangle = textField.getRect(this);

// get your graph paper ready, here's a "speech bubble"
background.graphics.beginFill(0x12345);
shadow.graphics.beginFill(0x000000);

for each (var g:Graphics in [ background.graphics, shadow.graphics ] ) {
g.moveTo(rect.left, rect.top);
g.lineTo(rect.right, rect.top);
g.lineTo(rect.right, rect.bottom);
g.lineTo(rect.left+15, rect.bottom);
g.lineTo(rect.left+10, rect.bottom+15);
g.lineTo(rect.left+5, rect.bottom);
g.lineTo(rect.left, rect.bottom);
g.lineTo(rect.left, rect.top);
g.endFill();
}
}
}
}

より熟練したコーダーが私を助けてくれることを願っています。私はflexとas3が初めてです

編集: このファイルには JavaScript がありません。すべてAS3です。Edit2: これは、http://cjbutchershop.com/temp/adtypes/mapTest.swf でテストしている一時的なサイトです

4

3 に答える 3

1

次の手順でアプリケーションのサイズを取得できます。

var width:int = Application.application.width;
var height:int = Application.application.height;

情報バブルにカーソルを合わせるとテキストが消えます。あなたはあなたのアプローチを再考したいかもしれません。外部swfをロードするのではなく、適切なマウスイベントに応答して、マーカーオブジェクト(Spriteを拡張する)に子オブジェクト(TextFieldなど)を追加/削除することで、適度なマップの情報バブルを実装しました。

于 2009-12-17T15:34:12.253 に答える
0

「では、情報バブル SWF 内からアプリケーション サイズを取得しようとしているのですか? なぜ情報バブルは別の SWF にあるのですか? 情報バブルのソース コードがある場合は、それをマップ アプリケーションに追加し、情報バブルを直接インスタンス化することをお勧めします。 object. – elevine 2 時間前"

3 つの異なるタイプの infoBubbles があります (静的なバブルのみが表示されます)。吹き出しの一部に、動くコンテンツが含まれています。バブル内の外部 SWF のアプリケーション サイズを探しているのではなく、物理的なサイズを探しています。バブルに取り込まれている外部 SWF の高さと幅。高さと幅がわかっている場合は、インフォバブルを高さと幅に一致させることができます。現在、情報バブルを現在の情報バブルのサイズにハードコーディングしています。ただし、情報バブルの swf ファイルのサイズはさまざまです。

于 2009-12-18T03:23:33.530 に答える
0

私自身、Flex は初めてですが、学習中に例を試しながら、似たようなことをしました。基本的に私が提案するのは、親ウィンドウ(マップ上)のMouseOverイベントでPopUpManagerクラスを使用して、新しいポップアップウィンドウでバブルを開くことです。また、TitleWindow コンポーネントでポップアップを表示し、Title Window コンポーネントの close イベントもタップします。そうすれば、同じページに戻ることができます。これが役に立てば幸いです。

投稿コードはこちら

< ? xml version="1.0" encoding="utf-8" ? >
< mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
    <![CDATA[
        import mx.events.ListEvent;
        import mx.controls.Alert;
        import mx.managers.PopUpManager;
        import mx.rpc.events.ResultEvent;
        import mx.collections.ArrayCollection;

       [Bindable]
       public var photoFeed:ArrayCollection;

        public function searchFlickr():void {
            photoService.cancel();
            var params:Object = new Object();
                params.format = 'rss_200_enc';
                params.tags = srchTxtId.text;               
            photoService.send(params);
        }

        public function resultHandler(event:ResultEvent):void {
            photoFeed = event.result.rss.channel.item as ArrayCollection;
        }

        public function openPanel(levent:ListEvent):void {
            var panelCmpObj:panelcomp = new panelcomp();    
               panelCmpObj.source = levent.itemRenderer.data.content.url;           
            PopUpManager.addPopUp(panelCmpObj,this,true);
        }
        public function test():void {
            Alert.show('testtest');
            }           

    ]]>
</mx:Script>

<mx:HTTPService id="photoService" url="http://api.flickr.com/services/feeds/photos_public.gne" result="resultHandler(event)"/>

<mx:HBox width="362" height="24">
    <mx:TextInput id="srchTxtId"/>
    <mx:Button label="Search for pics" id="srchBtnId" click="searchFlickr()"/>
</mx:HBox>
<mx:TileList id="imgTileList" dataProvider="{photoFeed}" width="100%" height="100%" itemClick="openPanel(event)">   
<mx:itemRenderer>
    <mx:Component>
      <mx:VBox width="125" height="125"
            paddingBottom="5"
            paddingLeft="5"
            paddingTop="5"
            paddingRight="5">
            <mx:Image width="75" height="75" source="{data.thumbnail.url}"/>
      </mx:VBox>
    </mx:Component>
</mx:itemRenderer>
</mx:TileList>

PopUP に表示される CODE FOR THE COMPONENT
< ? xml version="1.0" encoding="utf-8" ? >
< mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" showCloseButton="true" styleName="noPadding" creationComplete="init();" close="titleWindow_close(イベント);" >
< ![CDATA[ インポート mx.managers.IFocusManagerComponent; mx.controls.Alert をインポートします。mx.core.IFlexDisplayObject をインポートします。mx.events.CloseEvent をインポートします。mx.managers.PopUpManager をインポートします。

        [Bindable]
        public var source:String;

        private function init():void {
            PopUpManager.centerPopUp(this);
        }

        private function titleWindow_close(evt:CloseEvent):void {
            PopUpManager.removePopUp(evt.target as IFlexDisplayObject);
        }
    ]] >
< /mx:Script>

< mx:Image width="379" height="261" id="imgId" source="{source}"/>
   <mx:ControlBar horizontalAlign="right" width="100%">
</ mx:ControlBar>

< /mx:タイトルウィンドウ >

于 2009-12-17T15:52:06.087 に答える