Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing loops, arrays and IEventDispatcher with URLRequest
    primarykey
    data
    text
    <p>So basically I have this map. On this map I have points, and when you click on these points it goes to a URL.</p> <p>The code setup is as follows:</p> <ul> <li><p>Arrays to define the movieclip locations and another for the urls (this one is an associative array).</p></li> <li><p>I then create a function loop to make an event listener for each point. When the point is clicked it will run another function that handles the URLs.</p></li> <li><p>The URL function is to grab the target point that has been click, use the url array type to find the key, and then throw it in to the URLRequest.</p></li> </ul> <p>So far I have this code:</p> <pre><code>var places:Array = new Array(); places = [ map.paulsens, map.paraburdoo, map.plutonic, map.wiluna, map.gwalia, map.wallaby, map.sunrise, map.moora, map.marvel, map.flyingFox, map.ernest, map.rosebery, map.lyell, map.renison, kalMap.kanowna, kalMap.frogsLeg, kalMap.tindals, kalMap.miitel, kalMap.higginsville ]; var links:Array = new Array(); links[ "paulsens" ] = "http://mywebsite.com/"; links[ "paraburdoo" ] = "http://mywebsite.com/"; links[ "plutonic" ] = "http://mywebsite.com/"; links[ "wiluna" ] = "http://mywebsite.com/"; links[ "gwalia" ] = "http://mywebsite.com/"; links[ "wallaby" ] = "http://mywebsite.com/"; links[ "sunrise" ] = "http://mywebsite.com/"; links[ "moora" ] = "http://mywebsite.com/"; links[ "marvel" ] = "http://mywebsite.com/"; links[ "flyingFox" ] = "http://mywebsite.com/"; links[ "ernest" ] = "http://mywebsite.com/"; links[ "rosebery" ] = "http://mywebsite.com/"; links[ "lyell" ] = "http://mywebsite.com/"; links[ "renision" ] = "http://mywebsite.com/"; links[ "kanowna" ] = "http://mywebsite.com/"; links[ "frogsLeg" ] = "http://mywebsite.com/"; links[ "tindals" ] = "http://mywebsite.com/"; links[ "miitel" ] = "http://mywebsite.com/"; links[ "higginsville" ] = "http://mywebsite.com/"; function listenerLoop():void { var i:int; for( i = 0; i &lt; places.length; i++ ) { ( places[ i ] as IEventDispatcher ).addEventListener( MouseEvent.CLICK, openLink ); } } function openLink( event:MouseEvent ):void { var link:URLRequest = new URLRequest( links[ event.target ] ); navigateToURL( link, "_blank" ); } listenerLoop(); </code></pre> <p>Now all works fine until I click on the point, giving me this error:</p> <pre><code>TypeError: Error #2007: Parameter url must be non-null. at global/flash.net::navigateToURL() </code></pre> <p>at</p> <pre><code>navigateToURL( link, "_blank" ); </code></pre> <p>So it's obvious to me that the openLink(); function isn't doing what I want it to. I can kind of guess because event.target isn't being turned in to a string or not pulling the array's type? I'm a very rusty ActionScripter so bare with me :).</p> <p>Any ideas on how to make this thing work? Cheers for any help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload