Hi Goran-
Did you figure it out? It might be simpler for you to put the loading
outside of the makePolygon function, and just pass the XML into the
makePolygon function. Then you wouldn't need to deal with the asynchronous
nature.
If you still need help, please send over the full code for me to experiment
with.
- pamela
On Fri, Oct 17, 2008 at 7:34 PM, Goran <[EMAIL PROTECTED]> wrote:
>
> Many thanks for your reply, but I am not sure what exactly do you mean
> by that, could You show the example on my code? Thanks.
>
>
> On 16 list, 01:58, "pamela (Google Employee)" <[EMAIL PROTECTED]>
> wrote:
> > Hi Goran-
> >
> > The Loader is an asynchronous function - so the return statement is
> > reached before the loader finishes loading the file. One suggestion
> > would be to pass a callback function reference into the function and
> > call that when the polygon is actually created, passing the polygon to
> > it.
> >
> > - pamela
> >
> >
> >
> > On Tue, Oct 14, 2008 at 8:26 PM, Goran <[EMAIL PROTECTED]> wrote:
> >
> > > Please help, i'm stuck with this. I want to make function that adds
> > > polygon from XML and RETURNS POLYGON OBJECT
> >
> > > (specPoly=makePolygonFromXML("data/xml/Opcine/desinic.xml",
> > > 0xfab000,0.3,2)
> >
> > > so I can reference it later to hide it or remove it, or use it in a
> > > loop as an array of polygons.
> >
> > > function makePolygonFromXML works, it makes a polygon from XML file
> > > but it doesn't return the polygon specified
> > > in function call, specPoly.hide() method doesn't work and all code
> > > after this method doesn't execute.
> >
> > > Any help would be much appreciated.
> > > Tnx in advance.
> >
> > > here is the code:
> >
> > > private var specPoly:Polygon //global variable
> >
> > > specPoly=makePolygonFromXML("data/xml/Opcine/desinic.xml",
> > > 0xfab000,0.3,2) //works
> > > specPoly.hide() //doesnt'work
> >
> > > private function
> > >
> makePolygonFromXML(xmlFile:String,col:Number,al:Number,wid:Number):Polygon
> > > {
> > > var polygon:Polygon
> > > polygonLoader = new URLLoader()
> > > polygonLoader.addEventListener(Event.COMPLETE,
> > > function(event:Event):void {
> > > var xmlCont:XML=new
> XML(polygonLoader.data);
> > > var points:Array = new Array;
> > > for each (var location:XML in
> xmlCont..*)
> > > {
> > > var LLfromXML:LatLng = new
> LatLng([EMAIL PROTECTED],
> > > [EMAIL PROTECTED]);
> > > points.push (LLfromXML)
> > > }
> > > var polygonOptions:PolygonOptions= new
> PolygonOptions
> > > var fillStyle:FillStyle = new FillStyle;
> > > fillStyle.alpha = al;
> > > fillStyle.color = col;
> > > polygonOptions.fillStyle = fillStyle;
> >
> > > var strokeStyle:StrokeStyle = new StrokeStyle;
> > > strokeStyle.thickness=wid
> > > strokeStyle.color = 0x000000;
> > > strokeStyle.alpha=1
> > > polygonOptions.strokeStyle = strokeStyle
> >
> > > var polygon = new Polygon (points,
> polygonOptions)
> > > gMap.addOverlay(polygon);
> >
> > > })
> >
> > > var request:URLRequest=new URLRequest(xmlFile)
> >
> > > try
> > > {
> > > polygonLoader.load(request);
> > > }
> > > catch(error:Error)
> > > {
> >
> > > }
> > > return polygon
> > > }- Sakrij citirani tekst -
> >
> > - Prikaži citirani tekst -
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---