Solved

How do I get around the super-statement

Posted on 2008-06-24
12
1,174 Views
Last Modified: 2013-11-11
Im trying to implement the content of a package with xml, which means that Im trying to use the package-code in the actual .fla-file.
But I have a problem with the super-statement, that creates this error:
1007: A super statement can be used only inside class instance constructors.

    import flash.events.Event;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapType;
    import com.google.maps.LatLng;
      function initiateMap() {
      super();
      key = "Here there is a google maps key";
                addEventListener(MapEvent.MAP_READY, onMapReady);
              }
                  
              function onMapReady(event:MapEvent):void {
        setCenter(new LatLng(zlatitude,zlongitude), 7, MapType.HYBRID_MAP_TYPE);
}
}

In the code snippet you can see the package that Im trying to bring to use in the .fla-file.

package
{
 
	import flash.events.Event;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapType;
    import com.google.maps.LatLng;
      public class HelloWorld extends Map {
          public function HelloWorld() {
			  super();
			  key = "Here there is a google maps key";
              addEventListener(MapEvent.MAP_READY, onMapReady);
              }
			 
              private function onMapReady(event:MapEvent):void {
				  
                  setCenter(new LatLng(zlatitude,zlongitude), 7, MapType.HYBRID_MAP_TYPE);
 
}
}
}

Open in new window

0
Comment
Question by:SimonAdrian
  • 7
  • 5
12 Comments
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21854344
In AS3.0, the call to super is added to the constructor by default, so you don't need to - so without giving you any clear answer to why you are getting an error-message, I can tell you that you will not loose anything by removing it in this case..

Kindly,
Samuel
0
 

Author Comment

by:SimonAdrian
ID: 21855518
Well, except I then get two - new - errors.
1120: Access of undefined property key.
1180: Call to a possibly undefined method setCenter.

Im not sure if they just didnt show up before, because of the existing super-statement or why....
0
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21864214
Hi again.

Well, that's because you are trying to modify a variable that has not been defined yet, and you are trying to call a function that has not been created yet.

The following code should be compiled:
[CODESNIP]

Kindly,
Samuel
package
{
 
	import flash.events.Event;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapType;
    import com.google.maps.LatLng;
      public class HelloWorld extends Map {
          var key :String;
          public function HelloWorld() {
			  super();
			  key = "Here there is a google maps key";
              addEventListener(MapEvent.MAP_READY, onMapReady);
              }
			 
              private function onMapReady(event:MapEvent):void {
                  setCenter(new LatLng(zlatitude,zlongitude), 7, MapType.HYBRID_MAP_TYPE);
 
	     }
	     private function setCenter(_lat :LatLng, _number :Number, _maptype) :void {
	     // CODE HERE
	     }
	}
}

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:SimonAdrian
ID: 21864910
Im not sure I follow the last part:
I got rid of the key-error, but Im not sure what to do with your suggestion of a setcenter-function. The function already exist in one of the imported classes - I assume, since the package-solution works fine.
Just to clarify: What Im trying to do is NOT using a package-solution - thats whats its all about, because Im trying to make it work based on xml-parameters.
I was hoping for something like what you see in the below codesnippet.
Thats based on my first codesnippet.


var xmlLoader:URLLoader = new URLLoader(); 
var xmlData:XML = new XML(); 
xmlLoader.addEventListener(Event.COMPLETE, LoadXML); 
xmlLoader.load(new URLRequest("map.xml")); 
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data); 
var zlatitude=xmlData.attribute("latitude");
var zlongitude=xmlData.attribute("longitude");
var zzoom=xmlData.attribute("zoom");
			import flash.events.Event;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapType;
    import com.google.maps.LatLng;  
			  function HelloWorld() {
			  var key :String;
			  key = "Here theres a google map key";
              addEventListener(MapEvent.MAP_READY, onMapReady);
			  }
			  function onMapReady(event:MapEvent):void {
				  
                  setCenter(new LatLng(12,55), 7, MapType.HYBRID_MAP_TYPE);
 
} 
	     }

Open in new window

0
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21864945
Ok, then you have to refer to the class where the setCenter-function is placed...

like:
var thatClass = new TheUsedClass();

then, later:
thatClass.setCenter(....)

Can you try that out?
0
 

Author Comment

by:SimonAdrian
ID: 21865271
Can you specify that for me.
Im pretty sure the function is in    com.google.maps.LatLng;
0
 

Author Comment

by:SimonAdrian
ID: 21865351
If I try it this way I get an error:

function onMapReady(event:MapEvent):void {
1136        var newlatlong = new com.google.maps.LatLng();
                  newlatlong.setCenter(new LatLng(12,55), 7, MapType.HYBRID_MAP_TYPE);

}

1136: Incorrect number of arguments.  Expected 2.
0
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21872689
Hmm, I don't think the function is in LatLng, as the LatLng function is used within the setCenter-function...
0
 

Author Comment

by:SimonAdrian
ID: 21873455
Well, Ive tried with the others too,
When I use Map, I dont get errors, but apart from that nothing happens.
The other two gives me similar errors - respectively 2 and 3 expected numbers of arguments.
0
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21873828
Can you possibly zip the project down and upload it somewhere, and I'll take a look?

Easier that way..
0
 

Author Comment

by:SimonAdrian
ID: 21874128
Sure.
http://www.dego.dk/zipped/helloworld.zip
It contains
helloworld.xml
helloworld.fla with my attempt to get around the use of
HelloWorld.as, which contains the working package-code.

If you refer to the HelloWorld.as in the Document class, you will see the map, whn you test the .fla.
Its presently Hybrid - if you want to change it to map-view, write NORMAL instead.
Bear over with me that I dont supply a google-maps key.
You can get one here if you have a google-account
http://code.google.com/apis/maps/signup.html
If necesseray I can upload a file for a short period with a key
0
 

Accepted Solution

by:
SimonAdrian earned 0 total points
ID: 21874145
I forgot to tell you that the google-code is in a component, that is in the library. Just leave it there.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash doesn't load in Iphone and Ipad 22 492
Embedded Video Download (Flash) 3 1,162
Video sharing with user login 3 209
Open Source MP4 Flash Player 2 189
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question