3 Replies Latest reply on Oct 2, 2008 6:57 AM by Newsgroup_User

    ScrollTo command

    brad_rice
      I've created an application with a canvas. Inside the canvas is a large swf. I want to be able to pan left, right, up and down. I am able to do it but the scroll bars don't roll with the swf inside the canvas. Is there a way I can have the scrollbars update as the swf pans inside the canvas? Something like a scrollTo command.

      Here is the mxmlc:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" height="800" width="1024" layout="absolute" xmlns:local="*">

      <mx:Script>
      <![CDATA[
      import com.hexagonstar.util.debug.Debug;


      ]]>
      </mx:Script>

      <mx:Canvas width="1024" height="800" id="outerCanvas" >



      <mx:VDividedBox x="800" y="0" height="800" width="216">
      </mx:VDividedBox>
      <mx:Canvas y="0" x="0" width="800" height="800" id="mapCanvas" >
      <local:D_Map id="dmap" />
      </mx:Canvas>
      <mx:Canvas width="88" height="276" backgroundColor="#FFFFFF" backgroundAlpha="0.2" y="10" x="10">
      <mx:VSlider x="21" y="30" width="17.85" height="238" minimum="15" maximum="100" value="100" id="zoomSlider" change="dmap.zoomMap(zoomSlider.value);" liveDragging="true"/>
      <mx:Label x="21" y="10" text="Scale Map" color="#000000" fontWeight="bold"/>
      <mx:Label x="47" y="30" text="100%" alpha="1.0" color="#000000"/>
      <mx:Label x="46.85" y="250" text="15%" color="#000000"/>
      </mx:Canvas>
      <mx:Button x="106" y="10" label="Move Right" click="dmap.moveRight(100);"/>

      </mx:Canvas>
      </mx:Application>

      Here is the actionscript:

      package {
      import flash.display.MovieClip;
      import mx.flash.UIMovieClip;
      import caurina.transitions.Tweener;

      public class D_Map extends UIMovieClip
      {
      public function D_Map():void
      {
      }


      public function zoomMap( factor:Number ) : void {
      base_map_mc.scaleX = (factor *.01);
      base_map_mc.scaleY = (factor * .01);
      }

      public function moveRight(factor:Number):void {
      if (base_map_mc.x < 0) {
      Tweener.addTween(base_map_mc, {x:(base_map_mc.x + factor), time:0.5})
      }
      }

      public function moveLeft(factor:Number):void {
      // base_map_mc.x = (base_map_mc.x + factor);
      }
      }
      }