Hello Again,

Sorry about the last post - I JUST figured this out (it was just by
chance that I tried something just for the heck of it).

I figured, since Flex uses the decimal values "Zero through One" to
specify Alpha values (versus 1% - 100%), I would try the same thing when
it came to Scaling MovieClips - and it DOES apply.

Either I overlooked this, or it's not in the documentation...  Coming
from a heavy Flash background, I am obviously going to try and drop in
most of my code Verbatim, since I was already coding in AS 2.0 -

With that said, I thought there would be very little tweaking involved -
but I guess I will still have to sift through the docs, and find all the
small changes that were made - especially things that relate to coding
for Flash, and converting it to Flex....

Just thought I'd post the solution, in case this happens to anybody
else.

Mike

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Anderson
Sent: Thursday, January 04, 2007 10:13 PM
To: [email protected]
Subject: [flexcoders] Desperate for help, on scaling external SWF files
within Flex Apps

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


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links



Reply via email to