检测swf的大小。柔性/as3

发布于 2024-08-14 23:08:57 字数 3045 浏览 2 评论 0原文

我正在创建一张有兴趣点的地图。 (POI) 当用户将鼠标悬停在 POI 上时,屏幕上会弹出一个信息气泡并加载一个 swf。我目前有 3 个问题。我的第四个问题是截止日期是 21 日星期一!因此,任何帮助将不胜感激!

  1. 我无法检测到 swf 的大小,以便我的 infobubble 能够根据 swf 的大小调整自身的大小。

  2. 当我将鼠标悬停在 swf 文件上时,它会消失。

  3. 我希望我的 swf 文件能够在自己的图层中弹出,而不是出现在我的主 Flex 文件的舞台上...但我不知道如何执行此操作。

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

I'm creating a map that has points of interest. (POI) When a user mouses over the POI an info bubble pops onto the screen and it loads an swf. I currently have 3 problems. My 4th problem is that this is due Monday 21st! so any help would be greatly appreciated!

  1. I can't detect the size of the swf so that my infobubble will size itself to the size of the swf.

  2. When I mouse over my swf file, it disappears.

  3. I would love to have the my swf file pop up in a layer on its own instead of being on the stage of my main flex file...but i have no clue how to do this.

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();
}
}
}
}

I hope you more skilled coders can help me out. I'm new to flex and as3

Edit: There is no javascript in this file. All of it is AS3.
Edit2: This is the temporary site I am testing it on http://cjbutchershop.com/temp/adtypes/mapTest.swf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜还是长夜 2024-08-21 23:08:57

您可以通过执行以下操作来获取应用程序的大小:

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

关于将鼠标悬停在信息气泡上时文本消失的情况;您可能需要重新考虑您的方法。我没有加载外部 swf,而是通过向我的标记对象(扩展 Sprite)添加/删除子对象(如 TextField)来响应适当的鼠标事件,从而实现了适度地图的信息气泡。

You can get the size of your application by doing:

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

With regards to the text disappearing when you hover over the info bubble; you might want to reconsider your approach. Rather than loading an external swf, I have implemented info bubbles for modest maps by adding/removing child objects (like a TextField) to my marker object (which extends Sprite) in response to the appropriate mouse events.

半衬遮猫 2024-08-21 23:08:57

我自己是 Flex 新手,但我在学习时尝试示例时做过类似的事情。
基本上我的建议是使用父窗口(在地图上)的 MouseOver 事件上的 PopUpManager 类在新的弹出窗口中打开气泡。
并在 TitleWindow 组件中显示弹出窗口,同时点击 Title 窗口组件上的关闭事件。这样您将返回到同一页面。希望这会有所帮助。

在这里发布代码

< ? xml版本=“1.0”编码=“utf-8”? >
< mx:应用程序 xmlns:mx =“http://www.adobe.com/2006/mxml”布局=“垂直”>

<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>

弹出窗口中显示的组件代码

< ? xml版本=“1.0”编码=“utf-8”? >
< mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
显示关闭按钮=“真”
样式名称=“无填充”
创建完成=“初始化();”
close="titleWindow_close(event);" >

< ![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:标题窗口>

I am new to Flex myself, but i have done something similar while trying out an example while learning.
Basically what i suggest is Open the bubble in a new popup window using the PopUpManager class on MouseOver event on the parent window (on your map).
And show the popup in a TitleWindow Component,also tap the close event on Title window component.That way you will come back to the same page.Hope this helps.

Posting code here

< ? 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>

CODE FOR THE COMPONENT shown on PopUP

< ? 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(event);" >

< ![CDATA[
import mx.managers.IFocusManagerComponent;
import mx.controls.Alert;
import mx.core.IFlexDisplayObject;
import mx.events.CloseEvent;
import 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:TitleWindow >

七禾 2024-08-21 23:08:57

“那么您试图从信息气泡 swf 中获取应用程序大小?为什么信息气泡位于单独的 swf 中?如果您有信息气泡源代码,我建议将其添加到您的地图应用程序中并直接实例化信息气泡object. – elevine 2 小时前”

我有三种不同类型的 infoBubbles(仅显示静态气泡)。我的一些信息气泡包含移动内容。我不是在寻找气泡中外部swf的应用程序大小,我正在寻找物理大小。填充气泡的外部 swf 的高度和宽度。如果我知道高度和宽度,我可以让信息气泡匹配高度和宽度。现在,我将信息气泡硬编码为当前信息气泡的大小;但是,我会有不同大小的信息气泡 swf 文件。

"So you are trying to get the application size from within the info bubble swf? Why is the info bubble in a separate swf? If you have the info bubble source code, I suggest adding it into your map application and directly instantiate the info bubble object. – elevine 2 hours ago"

I have three different type of infoBubbles (only static bubble is shown). Some of my info bubbles have moving content. I am not looking for the application size of the external swf in the bubble, i am looking for the physical size. The height and width of the external swf that is populating the bubble. If I knew the height and width, I can have the infobubble match the height and width. Right now I have the info bubble hardcoded to the size of the current info bubble; however, i will have different sizes of info bubbles swf files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文