views:

308

answers:

3

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 &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 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});
 }
A: 

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

back2dos

back2dos
Marcy Sutton
A: 

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;
 }
Marcy Sutton
localToGlobal translates coordinates from within one clip, to to stage coordinates. for example, if you have a clip rotated by 90 degrees, on (100, 100), scaled down by 50%, then the point (50,0) in the relative coordinates of that clip is at (100,150) on stage. localToGlobal does this for you. translating relative (local) to absolute, stage-based (global) coords. if you move around _root, than you will need to retransform these coords with globalToLocal. also, you should use the function JIT and not while initializing, since your objects move/zoom around.
back2dos
A: 

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.

ZergCow