Copy link to clipboard
Copied
Hey everyone,
I'm a new as3 student taking my first steps foward into a map-based tourism app.
I'm using the MapQuest API for as3, it's the first time I'm using an api and so far I've made the basic AS3 map from here.
At the moment I'm trying to use the 'MouseWheel ZoomControl' from the link I left above but I've no idea how to get the code right, since it looks like xml and I'm working with AS3 on Flash Pro CC.
Can anybody help me?
It's for a college work and I'm losing my mind so far
Thanks a lot everyone, best regards.
1 Correct answer
use:
...
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import com.mapquest.tilemap.*
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
public class AS3Map extends Sprite {
var zs:ZoomSettings;
var map:TileMap
public function AS3Map():void {
//turn scaling off
this.stage.scaleMode = StageScaleMode.NO_SCALE;
//create a new TileMap
Copy link to clipboard
Copied
this is the code from mapquest:
import com.mapquest.*;
import com.mapquest.tilemap.*
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
private var zs:ZoomSettings;
/*===================================================================
** A note to developers want to support mousewheel zoom for Mac users
Issue: MousewheelZoom may waork intermittently or not all all or Macs:
---------------------------------------------------------------------
This is an issue with Adobe's implementation of mousewheel scrolling
functionality in Mactintosh versions of Flash Player. Apparently it's
a long-standing issue and developers have had to use JavaScript in
their applications to provide their own solution.
Suppoorting this can be accomplished, but it must be done in the
application, in the HTMLWapper. A sample script resolving the issue
is called macmousewheel and can be found at the link below.
http://blog.pixelbreaker.com/flash/swfmacmousewheel
===================================================================*/
/*
function to setup the map and add controls
*/
private function onCC():void{
//set the map center and zoom level
this.myMap.setCenter(new LatLng(38.895,-77.036697),8);
//add a control to the map
this.myMap.addControl(new SMLargeZoomControl());
//make a zoomSettings object
this.zs = new ZoomSettings();
this.zs.animate = true;
this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;
//add the mousewheelzoomcontrol to the map
this.myMap.addControl(new MouseWheelZoomControl());
}
/*
function to create zoomsettings for the map (smooth zoom)
*/
private function makeZoomSettings():void {
if (this.btnZoom.label == "Enable Smooth Zoom") {
this.myMap.zoomSettings = (this.zs);
this.btnZoom.label = "Disable Smooth Zoom";
}
else {
this.myMap.zoomSettings = (null);
this.btnZoom.label = "Enable Smooth Zoom";
}
}
Copy link to clipboard
Copied
Thanks a lot for your quick reply.
I tried to add that code into my basic AS3 Map (I got the code from the website I mentioned before) and I got the 1013 error (The private attribute may be used only on class property definitions), so I removed the 'private' word from this var and functions:
private var zs:ZoomSettings;
private function onCC():void{
private function makeZoomSettings():void {
I don't know if I should be doing that, but the error was gone.
Then I got the 1120 error (Access of undefined property mx) from this line:
this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;
I don't know how to fix that, I tried to remove the whole '//make a zoomSettings object' section but with those changes my map looks exactly the same as before I applied the zoom code.
------------------------------------------------------------------------------------------------------------------------------
Here's my whole code so far:
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import com.mapquest.tilemap.*;
public class AS3Map extends Sprite {
public function AS3Map():void {
//turn scaling off
this.stage.scaleMode = StageScaleMode.NO_SCALE;
//create a new TileMap object, passing your platform key
var map:TileMap = new TileMap("Fmjtd%7Cluurn96rnl%2Cra%3Do5-9w80lr");
//set the size of the map
map.size = new Size(stage.stageWidth, stage.stageHeight);
//add the map to the sprite
addChild(map);
}
}
}
import com.mapquest.*;
import com.mapquest.tilemap.*
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
var zs:ZoomSettings;
/*
function to setup the map and add controls
*/
function onCC():void{
//set the map center and zoom level
this.myMap.setCenter(new LatLng(38.895,-77.036697),8);
//add a control to the map
this.myMap.addControl(new SMLargeZoomControl());
//make a zoomSettings object
this.zs = new ZoomSettings();
this.zs.animate = true;
this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;
//add the mousewheelzoomcontrol to the map
this.myMap.addControl(new MouseWheelZoomControl());
}
/*
function to create zoomsettings for the map (smooth zoom)
*/
function makeZoomSettings():void {
if (this.btnZoom.label == "Enable Smooth Zoom") {
this.myMap.zoomSettings = (this.zs);
this.btnZoom.label = "Disable Smooth Zoom";
}
else {
this.myMap.zoomSettings = (null);
this.btnZoom.label = "Enable Smooth Zoom";
}
}
--------------------------------------------------------------------------------------------------------------------
Can you tell me what I'm doing wrong and how to fix it?
Your help would be priceless.
Thanks a lot, best regards.
Copy link to clipboard
Copied
use:
package {
import flash.display.Sprite;
import flash.display.StageScaleMode;
import com.mapquest.tilemap.*
import com.mapquest.tilemap.controls.inputdevice.*;
import com.mapquest.tilemap.controls.shadymeadow.*;
public class AS3Map extends Sprite {
var zs:ZoomSettings;
var map:TileMap
public function AS3Map():void {
//turn scaling off
this.stage.scaleMode = StageScaleMode.NO_SCALE;
//create a new TileMap object, passing your platform key
map = new TileMap("Fmjtd%7Cluurn96rnl%2Cra%3Do5-9w80lr");
//set the size of the map
map.size = new Size(stage.stageWidth, stage.stageHeight);
//add the map to the sprite
addChild(map);
addMapCenterF();
addControlsF();
}
private function addMapCenterF():void{
//set the map center
map.setCenter(new LatLng(38.895,-77.036697),8);
}
private function addControlsF():void{
//add a control to the map
map.addControl(new SMLargeZoomControl());
//make a zoomSettings object
this.zs = new ZoomSettings();
this.zs.animate = true;
this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;
//add the mousewheelzoomcontrol to the map
map.addControl(new MouseWheelZoomControl());
}
}
}
Copy link to clipboard
Copied
I got the following errors:
1180 @ map.setCenter(new LatLng(38.895,-77.036697),8);
1120 @ this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;
Isn't mx a flex library or something?
Copy link to clipboard
Copied
yes, you have to add the main flex libraries, core.swc, framework.swc and mx.swc. you can dl here: Download Adobe Flex SDK
Copy link to clipboard
Copied
Thanks a lot mate, I had some issues but it's finally working
Anyway I'll need some help getting the points of interest working, I'll create a new thread about it, please stay tuned.
Thanks a lot again, best regards.
Copy link to clipboard
Copied
you're welcome.

