Hello All,

I am in the process of converting my Flash Application (which is simply
a Map Viewer program), into a Flex Application.  When it comes to Flash,
it is incredibly simple to manipulate assets directly on the stage -
like dragging, dropping, scaling, etc.

When it comes to Flex, it's a bit different.  Flex seems to be very
"Container-Centric", and it's not as simple to drag assets around on the
stage.  When it comes to dragging and dropping "Data" from one control
to another, YES - Flex made that quite easy to do.  But graphics are a
bit different.  This is where I may be a little fuzzy, and need some
direction.

In my Flash App, I obviously have a main stage, as well as several
layers - so things appear to be on top of one another.  On the sides, I
have all my navigation controls, on the bottom I have all my Zooming and
Panning controls, and on the top I have all my drop-down menus.  It
looks like a very typical Windows-type application.

When the user wants to load a new map, the app fetches an external SWF
File, and loads it using the MovieClipLoader control.  Once it's
finished, the user can pan & zoom the maps.  They can Pan by simply
dragging the map with the mouse cursor, and they can Zoom the map using
the Slider Control (also with the Mouse Wheel, in which the Scroll event
gets broadcast to the Slider).

My main problem with the Flex App, is tying the Slider Control to the
Zoom level of the SWF Files.  Maybe I am doing something wrong, but here
is how I am doing it:

I have a SWFLoader which loads the Map - which works beautifully upon
the initial load.  Once the Map is loaded, the user can Zoom the Map by
dragging the Slider Control back and forth.  The Slider Control's value
is bound to a Function, which in essence scales the content of the SWF
Loader.  Assuming that "platVectorImage" is the name of my SWFLoader,
the function that gets called is the following:

private function scalePlat( zoomLevel:Number ):void
{
        platVectorImage.content.scaleX = zoomLevel;
        platVectorImage.content.scaleY = zoomLevel;
}

And here is the function that kicks off, when the "onChange" event of
the Slider Control gets broadcast:

private function onPlatZoomSlider_Change( event:Event ):void
{
        var zoomLevel:Number = event.target.value;
        scalePlat( zoomLevel );
}

When I change the Slider Control, I get erratic results - almost like
1,000 times Zoom, or something crazy like that.  I would have thought,
by setting the value to "100" which is the starting value of the Slider
Control, that it would cause the SWF Loader to reset the SWF file back
to it's original size (which is 100%).

I will post the remaining code if I must, but I wanted to see if anybody
could throw some suggestions my way - as I'd like to think that I have a
good feel on how to write Flex Apps.  I am a very accomplished Flash
Programmer, and have a very good grasp of writing clean ActionScript.
But at this point, I am not even sure if using the SWFLoader is the most
appropriate control to be using.

Thanks in advance for any information you can offer regarding this
problem,

Mike

Reply via email to