卡在交互式地图上

发布于 2024-07-26 06:27:56 字数 3659 浏览 3 评论 0原文

所以,我正在抓紧时间制作 HTML/Flash 混合交互式地图,但它还远没有完成。 我不断地接近解决每个问题,却发现了更多的错误。 当你看作品时,其中大多数都是非常明显的。 我想至少消除大错误,所以我非常感谢任何建议。 请帮忙!

基本上,我以两种方式使用工具提示:[0] 传统上基于 Flash 的 onMouseMove(工作正常),以及 [1] 非常规地瞄准 Flash 影片中的某个点来自 HTML 列表。 工具提示显示正常,但由于地图移动和移动而位于错误的位置。 通过 TweenLite 进行缩放。 onMouseOver/onMouseOut 事件也存在错误,其中 onMouseOver 再次触发 onMouseOut,使工具提示在 _alpha 应该为 0 时可见。

链接到作品: http://muralapts.com/test/neighborhood.php

---- 大问题#1: HTML onMouseOver 再次触发onMouseOut,有效地“重新打开”我的工具提示。 当工具提示不会消失时,看起来真的很糟糕。 没有错误,因此我无法弄清楚为什么 onMouseOver 会触发两次。 似乎是 HTML 问题,而不是 Flash 问题。

---- 大问题#2:由于父剪辑被缩放和缩放,从页面左侧的 HTML 列表触发的工具提示显示在错误的位置。 与 TweenLite 一起移动。 工具提示附加到 _root,但“定位”多个容器剪辑中的一个点(下面未指定路径)。 我试图获取这样的工具提示位置:

Tooltip._x = ( dot._x + parentClip._x ) * parentClip._xscale/100;
Tooltip._y = ( dot._y + parentClip._y ) * parentClip._yscale/100;

交互式地图详细信息:

  • XML 内容动态生成 HTML 和 Flash 地图数据(id、名称、 链接、简介、类别编号 [艺术, 购物等],清单编号 [内的数字 类别] )。 使用 Magic Parser 从 Flash 使用的同一 XML 文件呈现 HTML 输出。

  • HTML/Javascript 与自定义 AS2 对话 通过外部接口的地图组件

  • 地图最初放大到 140% 并使用 TweenLite 移动到某个点

  • Flash 中点的 onRollOver影片显示带有地名的工具提示,更改点颜色

  • 放大/缩小按钮设置父剪辑 _xscale + _yscale 并在更新时使用 TweenLite 进行记录

  • HTML 列表中的 onMouseOver 显示带有地图数据的工具提示,但在错误的位置,因为地图已被缩放和放大。 与 TWENLITE 一起感动。 使用 TweenLite onUpdate 记录父剪辑的比例 + 位置值。

  • 从 HTML 更改点的颜色适用于 MouseOver,在 MouseOut 上“粘性”(点保持黑色)

XML 代码:(显示一个类别+列表,还有更多)

 <category title="Arts &amp; Entertainment">
     <loc id="artsWest_mc" name="Arts West" website="http://www.artswest.org/" cat="0" num="0">
         <content><![CDATA[The Junction's thriving community playhouse &amp; art gallery.]]></content>
     </loc>
  </category>

HTML 代码:

 <script type="text/javascript"><!--
      function showTooltip(btnID,catNum,listNum) {
          thisMovie("map").showTooltip(btnID,catNum,listNum);
      }
      function removeTip(btnID, catNum, isExternal) {
          thisMovie("map").removeTip(btnID, catNum, true);
      }
      function thisMovie(movieName) {
          if (navigator.appName.indexOf("Microsoft") != -1) {
              return window[movieName]
          } else {
              return document[movieName]
          }
      }
      //--></script>

 <a onMouseOver="showTooltip( btnID, categoryNum, listingNum )" onMouseOut="removeTip()">Arts West</a>; 

FLASH 代码:

public function showTooltip( bt:MovieClip, catNum:Number, listNum:Number ){ //MOVES MAP & SHOWS TOOLTIP
      TweenLite.to(map_mc, 1, {_x:destX, _y:destY, ease:'easeOutQuad',
          onUpdate: trickTip, 
          onUpdateParams: [bt, contentArr[catNum].childNodes[listNum].attributes.name] 
       });

}
public function trickTip( btnID:MovieClip, btnName:String ){    //CALLED FROM EXTERNAL INTERFACE
      theTip.theText.text = btnName;
      theTip._x = ((btnID._x + btnID._parent._x) * (map_mc._xscale/100)) - (theTip._width *.75);

      theTip._y = ((btnID._y + btnID._parent._y) * (map_mc._yscale/100)) + 20;

      TweenLite.to(theTip, .01, {_alpha:99, overwrite:1});
}

public function removeTip( bt:MovieClip, catNum:Number ){
       TweenLite.to(theTip, .01, {_alpha:0, overwrite:1});
 }

SO, I am getting down to the wire on a deadline for an HTML/Flash hybrid interactive map, and it is not anywhere near finished. I keep getting close to solving each problem, only to discover more bugs. Most of them are quite obvious when you look at the work. I would like to at least squash the big bugs, so I am VERY appreciative of any suggestions. PLEASE HELP!

Basically, I am using a Tooltip in two ways: [0] conventionally Flash-based onMouseMove (works fine), and [1] unconventionally targeting a point in the Flash movie from an HTML list. The Tooltip comes up fine, but is in the wrong place due to the Map moving & scaling via TweenLite. There are also bugs with the onMouseOver/onMouseOut events, where the onMouseOver fires again onMouseOut, leaving the Tooltip visible when it should have an _alpha of 0.

Link to the work: http://muralapts.com/test/neighborhood.php

---- BIG ISSUE #1: HTML onMouseOver is firing again onMouseOut, effectively "turning back on" my Tooltip. Really buggy looking when Tooltip won't go away. No errors, therefore I can't figure out why onMouseOver is firing twice. Appears to be an HTML issue, not a Flash issue.

---- BIG ISSUE #2: Tooltip triggered from HTML list on the left of page shows up in the wrong place due to parent clip being scaled & moved with TweenLite. Tooltip is attached to _root, but is "targeting" a dot within several container clips (paths not specified below). I am trying to get the Tooltip position like this:

Tooltip._x = ( dot._x + parentClip._x ) * parentClip._xscale/100;
Tooltip._y = ( dot._y + parentClip._y ) * parentClip._yscale/100;

INTERACTIVE MAP DETAILS:

  • XML Content dynamically generates
    HTML and Flash map data (id, name,
    link, blurb, category number
    [Arts,
    Shopping, etc.], list number
    [number within
    category] ). Uses Magic Parser to render HTML Output from the same XML file that Flash is using.

  • HTML/Javascript talks to custom AS2
    map component via External Interface

  • Map Initially zooms in to 140% and moves to a certain point using TweenLite

  • onRollOver of dots in Flash movie shows Tooltip with place name, changes dot color

  • Zoom In/Out buttons set parent clip _xscale + _yscale and record with TweenLite onUpdate

  • onMouseOver of list in HTML shows Tooltip w/ map data but in the WRONG PLACE, since Map has been zoomed & moved with TWEENLITE. Using TweenLite onUpdate to record parent clip's scale + placement values.

  • Changing color of dot from HTML works onMouseOver, is "sticky" onMouseOut (dots stay black)

XML CODE: (showing one category + listing, there are many more)

 <category title="Arts & Entertainment">
     <loc id="artsWest_mc" name="Arts West" website="http://www.artswest.org/" cat="0" num="0">
         <content><![CDATA[The Junction's thriving community playhouse & art gallery.]]></content>
     </loc>
  </category>

HTML CODE:

 <script type="text/javascript"><!--
      function showTooltip(btnID,catNum,listNum) {
          thisMovie("map").showTooltip(btnID,catNum,listNum);
      }
      function removeTip(btnID, catNum, isExternal) {
          thisMovie("map").removeTip(btnID, catNum, true);
      }
      function thisMovie(movieName) {
          if (navigator.appName.indexOf("Microsoft") != -1) {
              return window[movieName]
          } else {
              return document[movieName]
          }
      }
      //--></script>

 <a onMouseOver="showTooltip( btnID, categoryNum, listingNum )" onMouseOut="removeTip()">Arts West</a>; 

FLASH CODE:

public function showTooltip( bt:MovieClip, catNum:Number, listNum:Number ){ //MOVES MAP & SHOWS TOOLTIP
      TweenLite.to(map_mc, 1, {_x:destX, _y:destY, ease:'easeOutQuad',
          onUpdate: trickTip, 
          onUpdateParams: [bt, contentArr[catNum].childNodes[listNum].attributes.name] 
       });

}
public function trickTip( btnID:MovieClip, btnName:String ){    //CALLED FROM EXTERNAL INTERFACE
      theTip.theText.text = btnName;
      theTip._x = ((btnID._x + btnID._parent._x) * (map_mc._xscale/100)) - (theTip._width *.75);

      theTip._y = ((btnID._y + btnID._parent._y) * (map_mc._yscale/100)) + 20;

      TweenLite.to(theTip, .01, {_alpha:99, overwrite:1});
}

public function removeTip( bt:MovieClip, catNum:Number ){
       TweenLite.to(theTip, .01, {_alpha:0, overwrite:1});
 }

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

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

发布评论

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

评论(3

肤浅与狂妄 2024-08-02 06:27:56

使用 MovieClip::localToGlobal对于位置问题...

import flash.geom.Point;

var pt:Point = new Point();
dot.localToGlobal(pt);//dot being the clip with the position you actually need ...
//pt.x and pt.y are the required positions now ...

关于奇怪的 HTML 行为,如果不亲自调试,我无法为您提供很多帮助...我不是该领域的专家...:-D

一个快速的 hacky 修复可能是,延迟工具提示隐藏:

  • 先决条件是,您始终将活动对象存储在某个变量中,例如 activeID ...
  • 当您获得 mouseOut 时,然后设置超时...也许 100-200 msecs ...(创建一个将从 JS 调用的额外函数,该函数基本上执行 setTimeOut(removeTip, 100, bt, catNum)
  • 然后,由于某些未知的错误,将发送 mouseOver之后...如果 mouseOver 重新请求已经处于活动状态的对象,请忽略它...
  • 在超时提供的暂停之后,工具提示将被隐藏...
  • 确保删除该对象 ID,否则,如果不激活中间的另一个对象,您将无法两次激活同一个对象的工具提示...所以将 activeID = null 放入removeTip

我希望,这更不太清楚...

嗯调用showTooltip 中的trickTip onUpdate 对我来说似乎很奇怪...我认为你应该真正清理它...有一个函数,它既是补间的更新函数,又是从外部接口调用的,真的很混乱。 ..最好现在改变它,虽然你知道它的作用...

好吧,希望这有帮助...

greetz

back2dos

use MovieClip::localToGlobal for the position issue ...

import flash.geom.Point;

var pt:Point = new Point();
dot.localToGlobal(pt);//dot being the clip with the position you actually need ...
//pt.x and pt.y are the required positions now ...

concerning the strange HTML behaviour, i can't help you a lot without debugging myself ... i am not that much of an expert on the field ... :-D

a quick hacky fix could be, to delay tooltip hiding:

  • a prequisite is, that you always store the active object in some variable, say activeID ...
  • when you get an mouseOut, then set a timeout ... maybe 100-200 msecs ... (make an extra function that will be called from the JS, that basically does setTimeOut(removeTip, 100, bt, catNum))
  • then, by some unknown bug, the mouseOver will be sent just afterward ... if a mouseOver comes in rerequesting the object that is already active anyway, ignore it ...
  • after the pause provided by the timeout, the tooltip will be hidden ...
  • make sure, you delete that objects ID, otherwise, you will not be able to activate the tooltip for the same object twice without activating another object inbetween ... so put activeID = null into removeTip

i hope, this is more less clear ...

uhm calling trickTip onUpdate from showTooltip seems very strange to me ... i think you should really clean that up ... having a function, that is both an update function for a tween, and is being called from an external interface, is really messy ... better change it now, while you know, what it does ...

alright, hope this helps ...

greetz

back2dos

一百个冬季 2024-08-02 06:27:56

关于大问题#2:

我觉得我有点理解localToGlobal,但它正在记录xy 对于远离地图的每个点。

父地图剪辑为 760 x 916 像素(屏蔽 @ 400 x 600),但是我的代码输出记录每个点的“localToGlobal”x 值在 800 到 1600 之间 - 远离舞台。

在 Flash 影片中的 OnMouseOver 中,每个 dot._x 都记录在 100 到 300 之间,父剪辑位于左上角的 0,0...那么 877 来自哪里? 是否考虑到我正在动态设置父剪辑的 _x/_y 动画并增加 _xscale/_yscale (最初为140)?

_xscale/_yscale 如何影响 localToGlobal x 坐标?

我在启动点的位置添加了建议的代码(同时循环遍历 XML 层次结构) – 有 2 个循环,一个循环用于每个 XML 类别 [i] 和列表 [g]。 不可否认,我的代码变得复杂了。 我尝试向工具提示传递与移动地图相同的“destX”值,但这不起作用 - 可能是因为我传递的是相对于地图本身的值,而工具提示位于 _root。 这是 localToGlobal 应该提供帮助的地方吗?

 /////* Map.as */////

 private function initMap() {
    // contentArr = XML Array
    for(var i:Number = 0; i < contentArr.length; i++){
       categories = contentArr[i].childNodes;
       numCategories = categories.length;

      for(var g:Number = 0; g < numCategories; g++){

         dotIDs = categories[g].attributes.id;  
         dot = map_mc[dotIDs];
              // link dot movieClips on Stage to each XML listing   

         dot.catNum = i; // category number - Arts [0], Shopping[1], etc.
         dot.listingNum = g; // each indiv. listing number

         pt = new Point(); // New code
         pt = eval('pt_' + i + '_' + g); //Appending cat/list numbers for unique ids
         ptArray.push(pt);
         ptArray['pt_' + i + '_' + g] = {x:dot._x, y:dot._y};
         dot.localToGlobal(ptArray['pt_' + i + '_' + g]);
         }
    }
 }

 // ˘˘being called from externalInterface
 public function showTooltip(bt, catNum, listNum){ 

      var newBT = eval(_root.mapContainer_mc.map_mc + '.' + bt); 
      // so I don't have to use the entire path in HTML
      goto(newBT, catNum, listNum); 
 }
 public function goto(bt, catNum, listNum){ // moves map, calls Tooltip.trickTip()
      destX = 0-(bt._x-(mask_mc._width/3));
      destY = 0-(bt._y-(mask_mc._height/3));

      if(destX < 10-(map_mc._width-mask_mc._width)) destX = 10-(map_mc._width-mask_mc._width);
      if(destY < 10-(map_mc._height-mask_mc._height)) destY = 10-(map_mc._height-mask_mc._height);
      if(destX > 10) destX = 10;
      if(destY > 10) destY = 10;

      TweenLite.to(map_mc, 1, {_x:destX, _y:destY, ease:'easeOutQuad', overwrite:3, 
      onUpdate:trickTip, 
      onUpdateParams:[ bt, 
                       catNum, 
                       listNum, 
     /* theText*/      contentArr[catNum].childNodes[listNum].attributes.name
                       ]
       });
 }

 /////* Tooltip.as */////

 public function trickTip(catNum:Number, listNum:Number, theText:String):Void {

      theTip._x = ptArray['pt_'+catNum+'_'+listNum].x; //Somewhere way off stage
      theTip._y = ptArray['pt_'+catNum+'_'+listNum].y;
 }

Regarding BIG ISSUE #2:

I feel like I sort-of understand localToGlobal, but it is recording an x and y for each point that is way off the map.

The parent map clip is 760 x 916 pixels (masked @ 400 x 600), however my code output is recording each dot's "localToGlobal" x value between 800 and 1600 – way off of the Stage.

OnMouseOver in the Flash movie, each dot._x is recorded between 100 and 300, with the parent clip at 0,0 in the top left corner... So where is the 877 coming from? Is it factoring in that I am dynamically animating the parent clip's _x/_y and increasing the _xscale/_yscale (initially to 140)?

How does _xscale/_yscale affect localToGlobal x coordinates?

I added the suggested code where I initiate the dots (simultaneously looping through the XML hierarchy) – there are 2 loops, one for each XML category [i] and listing [g]. Admittedly, my code has gotten complicated. I tried passing Tooltip the same "destX" value I am using to move the map, but that didn't work – probably because I am passing values relative to the map itself, while the Tooltip is on the _root. Is that where localToGlobal is supposed to help?

 /////* Map.as */////

 private function initMap() {
    // contentArr = XML Array
    for(var i:Number = 0; i < contentArr.length; i++){
       categories = contentArr[i].childNodes;
       numCategories = categories.length;

      for(var g:Number = 0; g < numCategories; g++){

         dotIDs = categories[g].attributes.id;  
         dot = map_mc[dotIDs];
              // link dot movieClips on Stage to each XML listing   

         dot.catNum = i; // category number - Arts [0], Shopping[1], etc.
         dot.listingNum = g; // each indiv. listing number

         pt = new Point(); // New code
         pt = eval('pt_' + i + '_' + g); //Appending cat/list numbers for unique ids
         ptArray.push(pt);
         ptArray['pt_' + i + '_' + g] = {x:dot._x, y:dot._y};
         dot.localToGlobal(ptArray['pt_' + i + '_' + g]);
         }
    }
 }

 // ˘˘being called from externalInterface
 public function showTooltip(bt, catNum, listNum){ 

      var newBT = eval(_root.mapContainer_mc.map_mc + '.' + bt); 
      // so I don't have to use the entire path in HTML
      goto(newBT, catNum, listNum); 
 }
 public function goto(bt, catNum, listNum){ // moves map, calls Tooltip.trickTip()
      destX = 0-(bt._x-(mask_mc._width/3));
      destY = 0-(bt._y-(mask_mc._height/3));

      if(destX < 10-(map_mc._width-mask_mc._width)) destX = 10-(map_mc._width-mask_mc._width);
      if(destY < 10-(map_mc._height-mask_mc._height)) destY = 10-(map_mc._height-mask_mc._height);
      if(destX > 10) destX = 10;
      if(destY > 10) destY = 10;

      TweenLite.to(map_mc, 1, {_x:destX, _y:destY, ease:'easeOutQuad', overwrite:3, 
      onUpdate:trickTip, 
      onUpdateParams:[ bt, 
                       catNum, 
                       listNum, 
     /* theText*/      contentArr[catNum].childNodes[listNum].attributes.name
                       ]
       });
 }

 /////* Tooltip.as */////

 public function trickTip(catNum:Number, listNum:Number, theText:String):Void {

      theTip._x = ptArray['pt_'+catNum+'_'+listNum].x; //Somewhere way off stage
      theTip._y = ptArray['pt_'+catNum+'_'+listNum].y;
 }
蒗幽 2024-08-02 06:27:56

嘿,不太确定您对工具提示的问题,但是我在不同的应用程序上使用相同的概念。 我在一些增强现实 3D 模型上放置了工具提示,但遇到了鼠标悬停问题,即鼠标移开时工具提示会重复。 我 100% 在 flash 中执行此操作,因此我知道这不是 HTML 问题。

不管怎样,在谷歌搜索中发现了这个,我想让你知道这也发生在我身上,而且我不使用 HTML。

Hey Not really sure about your problems with the tooltip thing however I am using the same concept on a different application. I am putting a tooltip on some Augmented Reality 3D models and I am having a mouse over issue where the tooltip duplicates on mouse out. I am doing this 100% in flash so I know it is not a HTML problem.

Anyways, found this in a google search and thought I would let you know that it is happening to me too and I don't use HTML.

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