Posts Tagged flash

Movieclip pile-up

ETA: Oops, some of my code got eaten up. Sorry about that! The for statement has been corrected.
================

WHY, in the below function snippet, would adding x,y coordinates to the mcOrg movieclip cause the collection of movieclips to dogpile on top of each other? W.T.F.??

var mcOrg:TouchMovieClip = new TouchMovieClip();
var mcOrgContainer:TouchMovieClip = new TouchMovieClip();

function xmlLoaded(e:Event) {
xmlORG=new XML(ulXML.data);
var numMuseums:Number=xmlORG.museum.length();

for (var i:int=0; i<numMuseums; i++) {
var genText:TextField = new TextField();
var genFormat:TextFormat = new TextFormat();
genFormat.color = 0x000000;
genFormat.size = 12;
genFormat.font = "Arial";
genText.embedFonts = true;
genText.type = "dynamic";
genText.x = 10;
//genText.y = 35*(i+1);
genText.y = 10;
genText.background = false;
genText.backgroundColor = 0xffffff;
genText.width = 280;
genText.height = 20;
genText.multiline = true;
genText.wordWrap = true;
genText.antiAliasType = "advanced";
genText.autoSize = TextFieldAutoSize.NONE;
genText.defaultTextFormat = genFormat;
genText.htmlText=xmlORG.museum[i].iwindow[0].name.children();
//trace(genText.htmlText);
genText.setTextFormat(genFormat);
mcOrg.addChild(genText);
mcOrg.x = -10;
mcOrg.height=30;
mcOrg.y =mcOrg.height * i;
mcOrg.addEventListener(TouchEvent.TOUCH_DOWN, traceContent);
mcOrgContainer.addChild(mcOrg);

}//close for statement
orgContainer.addChild(mcOrgContainer);

Comments (4)

Still working on Clickable Markers

So, it turns out I was wrong. After much digging in the sample files sent by Ideum, I finally found where they declare the markers as TouchSprites. D’oh!

Off I go to try to work that into my function, which now looks something like this:

  private function onMapReady(event:MapEvent):void {
   lat=new Array(“34.056415″,”34.059065″,”34.01583″,”34.0729″,”33.763479”);
   lon=new Array(“-117.750086″,”-118.443755″,”-118.283498″,”-118.4414″,”-118.164778″);
   museums=new Array(“museum1″,”museum2″,”museum3″,”museum4″,”museum5”);
   //map.enableScrollWheelZoom();
   //map.crosshairsEnabled();
   //map.enableContinuousZoom();

   for (var i:int = 0; i < lat.length; i++) {
    var newLat:Number=lat[i];
    var newLng:Number=lon[i];
    var lat_long:LatLng = new LatLng(lat[i],lon[i]);
    var point:Point = map.fromLatLngToViewport(lat_long);
    
    var temp:Number=i;
    
    var marker:CustomMarker = new CustomMarker(i);
    this.addChild(marker);
    marker.x = point.x;
    marker.y = point.y;
    marker.visible = false;
    
    markerArray.push(marker);
    markerLL.push(lat_long);
    
    var mediaPoint:Point = new Point(point.x,point.y);
    mediaPos.push(mediaPoint);
    
    markerArray[i].name=i;
    markerArray[i].addEventListener(TouchEvent.TOUCH_DOWN, openMarkerLabel, false, 0, true);
    
    if (i+1==lat.length) {
     map_holder.addEventListener(TouchEvent.TOUCH_DOWN, touchDownHandler);
     map_holder.addEventListener(TouchEvent.TOUCH_UP, touchUpHandler);
    }
    /*var museumMarker:Marker = new Marker(
     new LatLng(newLat, newLng),
     new MarkerOptions({
          // label:  museums[i]
     })
    );*/
    /*museumMarker.addEventListener(TouchEvent.TOUCH_DOWN, this.openMarkerLabel, false, 0, true);*/
    //map.addOverlay(museumMarker);
   }
   map.removeEventListener(MapEvent.MAP_READY, onMapReady);
  }

Hoo-rah!

Comments off

Clickable Markers, take two

Ok, so I checked the sample code sent by the vendor, and the  markers weren’t individual sprites, so I didn’t try that. I went with my original-original event listener and function, which more closely matched the working sample:

museumMarker.addEventListener(TouchEvent.TOUCH_DOWN, openMarkerLabel, false, 0, true)

private function openMarkerLabel(e:TouchEvent):void {
   window = new NewWindow(); //NewWindow is a movieclip created in the 
                                                               //fla and exported as a class for AS
   this.addChild(window);
   window.x=0;
   window.y=0;
   window.z=10;
   window.width=299;
   window.height=123;   
  }

It didn’t get any errors, but neither did it open a window when I tested it on the table.

I think my next step might be moving NewWindow out of the fla and into its own class definition file. Yay. I hate those, ’cause I have very little experience with them, and so little time to refresh my memory.

Comments off

Clickable markers

What I have accomplished to date–and it’s taken an embarassingly long time to get even this far–is to create a google map (yay) that drags (yay–seriously, this one was an issue) and has markers (yay) where I want them to be (yay–actually this one was easy).

My next step is to make the markers clickable. My former next step was to make the markers open a window with info, until I realized they just weren’t clickable at all, so I’m back to baby steps.

My most recent event listener looked like this:

    museumMarker.addEventListener(MapMouseEvent.CLICK,
         function(event:MapMouseEvent):void {
                     trace(“marker clicked”);
          });

But I kept getting this error:

1119: access of possibly undefined property click through a reference with static type class.

I talked to my teammate T, and she thinks my problem is that every marker needs to be its own TouchSprite, so that’s what I’ll be trying next. Seriously, trying to sort out flash events with map events with touch events is driving me bonkers!

Comments off