Flash - Using Loops, Arrays And IEventDispatcher With URLRequest?

Dec 10, 2009

So basically I have this map. On this map I have points, and when you click on these points it goes to a URL.The code setup is as follows:

Arrays to define the movieclip locations and another for the urls (this one is an associative array). 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. 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.

So far I have this 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,

[code]....

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?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Flash - Using Arrays/loops To Control Sound Playback?

May 22, 2010

1. a button is clicked (calling the playSound function)2. the sound is then played, also a small instance of the button is called from the AS library and placed within a sprite that is within a movie clip at the bottom. The event listener is also removed from the main button so it can only be called once.3. when the small instance of the button is pressed (within the sprite) it stops the sound, removes the icon and re enables the buttons event listener.It all works fine, and it is worth mentioning i am still new to Flash but getting to understand it more (after a little bit of light hearted abuse from a few members ). What i am struggling to understand is how to 'streamline' my code. I plan on having 20 buttons on the screen, and surely theres an easier way then having 20 functions, all more or less doing the same thing!

View 3 Replies

Comparing Arrays And Loops

Nov 29, 2010

The scenario is to create a lotto game that matches 6 user inputted numbers with 7 randomly generated numbers. The 7th number is a special case (eg bonus ball) WOULD LIKE TO SHOW A KIND HEARTED FALSH GENIUS ALL OF THE SCRIPT IF POSS! (its not tooo long) This code works, but it just outputs the default message: There seems to be a problem with my arrays not comparing? Part of the code is: (prioir to this the user inputs numbers, they are copied to text areas beginning with O, on a button press) On a second button press randomly generated number appear to a timer. //compareResult checks how many numbers match between the two sets of numbers to determine winnings.

[Code]....

View 4 Replies

ActionScript 2.0 :: Arrays And For Loops Maybe?

Sep 14, 2005

I would've thought of a better title but I honestly have no idea what's going on. I have this code on the main timeline:

Code:
dots = new Array();
for (i = 0; i < 10; i++) {

[Code]...

View 1 Replies

AS3 :: Variable Naming With Loops And Arrays?

Aug 1, 2009

I am wanting to create an array. 10 values in it (couting from 0 index to 9). Each 'place holder' will have a corresponding value to it;s index i.e.

myArray[0]=0
myArray[1]=1 etc...

I can do that in a for loop. But then I want to attach each value to a single variable name. I then want to change that each variable to a string. I then want access to all the variables outside of the for loop.

var i:Number;
var aArray:Array = new Array();
for (i=0; i<10; i++) {

[code]....

The output error is 1084: expecting identifier before aArray.

View 1 Replies

Arrays :: Count Only Set Indexes Using Loops

May 19, 2011

In PHP you can do something like this:
Array1 = 0,0,3,6,6,6,7,8,8,9

Then loop through Array1 and set the keys of Array2
Array2[0] = true;
Array2[3] = true;
Array2[6] = true;
Array2[7] = true;
Array2[8] = true;
Array2[9] = true;
Array2.count = 6;

But doing a similar thing in AS3 would result in a count of 10 (true,,,, true,,,, true, true, true, true) as all of the keys that are not set are counted. Is there a way of doing this without using any more loops? or Functions, simplicity and efficiently are important here.

View 1 Replies

ActionScript 2.0 :: Calculator (arrays And Loops)?

Aug 1, 2010

I am trying to create a script, where the user inputs a maths equation (something simple like 5 + 2 * 10), I have managed to break down the text into an array and have the numbers in one array and the symbols in another, I wanted the computer to then work it out, however I cant seem to think of how to do this and the methods that I have tried have failed.So there is one dynamic box and the value of that is then broken down by an array split(" "), however this leaves the values in an array and it is percieved as a string not a number and so when i try to work it out

View 1 Replies

ActionScript 3.0 :: Stuck With Loops And Arrays

Jan 31, 2012

My objective is to create a horizontal menu spaced evenly, using dynamic random widths fed from xml.

I'm playing with arrays in the dynamic loop, but i really have no clue to what i'm doing. Can someone take a look at my loop code, i'm getting all my individual widths but i don't know what to do with them. In the cas e below i get item 1 and 2 in position but the rest are not moving![code]...

View 5 Replies

ActionScript 2.0 :: Using Associative Arrays And For Loops Together

Apr 24, 2006

I have regarding associative arrays. Basically, I'm trying to use the current index of a for loop, which is looping through xml attributes, as the key for an associative array.

[Code]...

View 9 Replies

ActionScript 3.0 :: How Arrays And For Loops Work Together

Apr 4, 2011

understand how arrays and for loops work together? In the following code 100 rain drops are created with the first for loop and then moved with a second for loop the part that I don't know understand 100% are as follow...

var rainDropArray = new Array();
for(var i:int=0; i<100; i++) {
var rainDrop:RainDrop = new RainDrop();
rainDrop.x = Math.random() * 550;

[code]....

View 6 Replies

ActionScript 3.0 :: Associative Arrays And For Loops

Feb 25, 2012

I was trying something out, and came across a little error. I wrote the following code to create an array and, using each value of that array, create an associative array for the values of xVelocity and yVelocity.[code]But I get an error from that as well. I think I understand basically why this doesn't work, but I'm wondering if, given the spirit of what I'm trying to do, you can think of a working alternative.

View 3 Replies

ActionScript 3.0 :: Calling Functions With Loops And Arrays?

Feb 9, 2009

I want to loop through a array to call my functions, but can't get the syntax right?

var myArray:Array = ['function1()', 'function2()'];
for (var key:String in myArray){
// I want to call the function here
}

View 1 Replies

ActionScript 3.0 :: Call Functions With Loops And Arrays?

Feb 9, 2009

I want to loop through a array to call my functions, butcan't get the syntax right, is this possible?[code]....

View 1 Replies

ActionScript 2.0 :: A Menu With Loops - Arrays And MADNESS [CS4]

May 13, 2009

it's a scrolling list with a series of movieclips within it which are each different items. When you click one of the items, that movieclip that you have clicked runs a little function which tells it to move 10 pixels to the right smoothly. It also checks to see if any of the other movieclips have been previously selected, and if they have, it runs a function that tells them to move back 10 pixels to the left.

[Code]...

View 6 Replies

ActionScript 3.0 :: Controlling And Referencing Arrays And For Loops

Jan 13, 2010

I am dynamically generating buttons and textfields using an array and a for loop. It all works well and creates buttons and textfields ... but once they are created is there a way I can cast them to a movieclip so that I can then control the visibility etc.

Here's the code:
//define variables
var _buttons:Buttons;
var _buttonsX:Number;
var _buttonsY:Number;
var textArray:Array = new Array()
[Code] ......

View 3 Replies

ActionScript 3.0 :: For Loops And Arrays - Run The Specific Animation Of Enemy

Oct 31, 2009

how can i find out from a for loop that which object from the array has been hit; For eg - i have 2 enemies in an array and i run a for loop

[Code]..

View 2 Replies

ActionScript 3.0 :: Accessing Mc's On Stage That Were Created Using A Loops And Arrays?

Feb 4, 2010

basically what im trying to do is create a jigsaw game, simple eh! i have nothing on the stage at compile time, only four items in the library. these are four different puzzle pieces with export names of "piece01" "piece02" "piece03" and "piece04". my AS goes like this:

ActionScript Code:
var puzzlePieces:Array = ["piece01","piece02","piece03","piece04"];
var len:int = puzzlePieces.length;
var pieceList:Array = [];

[Code]....

how do i or what name do i give the addEventListener to? (if that makes sense)
to be able to drag them.

View 5 Replies

ActionScript 3.0 :: Using Arrays / Loops To Control Sound Playback?

Jan 28, 2012

Attached I have a small .fla that basically does the following:

1. A button is clicked (calling the playSound function)
2. The sound is then played, also a small instance of the button is called from the AS library and placed within a sprite that is within a movie clip at the bottom. The event listener is also removed from the main button so it can only be called once.
3. When the small instance of the button is pressed (within the sprite) it stops the sound, removes the icon and re enables the buttons event listener.

It all works fine, and it is worth mentioning I am still new to Flash but getting to understand it more. I plan on having 20 buttons on the screen, and surely theres an easier way then having 20 functions, all more or less doing the same thing!

View 14 Replies

ActionScript 3.0 :: Adding Event Listeners To MovieClips - Arrays And For Loops

Jan 31, 2010

I'd like to add event listeners to movieclips (already on the stage), whose names are called from an array one by one, into a for loop.

Code:
// there are 4 movielcips on the stage with name a1 - a4.
// create array
var Bro:Array = ["a1","a2","a3","a4"];
// for loop
for ( var i:Number = 0; i < 4; i++) {
// Add event listener to array values to buttons.
Bro[i].addEventListener(MouseEvent.ROLL_OVER, roll, false, 0, true);
//execute this function on rollover
function roll() {
trace("why wont my arrays work in for loops");
}}

View 5 Replies

ActionScript 3.0 :: Arrays & Loops - Can't Get To Check The Rest Of The DataInputs And Toggle Their Circles

Oct 14, 2009

Inside each dataInput is a button that sets the var "varSumNum" to 1 or 2, retain or dismiss respectively. If I set varSumNum to 2 the retain button will hide the corresponding circleMC, but the circles need to toggle visible/invisible individually. This works fine on circleMC1, but I can't get it to check the rest of the dataInputs and toggle their circles. To clarify further, it needs to check each dataInput and if 2 & 4 are set to 1 circle 2 & 4 are removed.

[Code]....

View 21 Replies

ActionScript 3.0 :: Arrays And For Loops To Generate Multiple Buttons For Loading Images?

Sep 22, 2009

I have this array that contains the names of various images I want to load into Flash

var imageArray:Array=["image1","image2","image3","image4","image5","image 6","image7","image8","image9","image10"];

Now I want to create 10 different buttons with each button loading in an image. I know there's a way to do this with a for loop without having to make 10 different buttons and writing 10 different functions. Not sure how to correlate the members imageArray with the generated btns.

View 5 Replies

ActionScript 1/2 :: Arrays N Loops - Movieclips To Hide Except For The Movieclip Similar To The Clicked Button

May 30, 2011

[Code]....

I'm stucked here. I want the font type "BauhausMedium" to apply when ft_01 is clicked, font type "Haettenschweiler" to apply when ft_02 is clicked, etc... at the same time I want all" ft_01a", "ft_02a", "ft_03a" movieclips to hide except for the movieclip similar to the clicked button. E.g. if "ft_02" was clicked ft_02a to be visible =true and rest to be visible = false (ft_01a, ft_03a).

View 5 Replies

Professional :: URLRequest Lost - Error 1046: Type Was Not Found Or Was Not A Compile-time Constant: URLRequest

Aug 12, 2009

In my movie i have a link button with following, simple, function creating a link:

[Code]...

lately i've associated a class file (.as) to my movie and immediately after, when publishing the movie i got the following error message: 1046: Type was not found or was not a compile-time constant: URLRequest. as well as a couple of other related error messages: 1180: Call to a possibly undefined method URLRequest. 1180: Call to a possibly undefined method navigateToURL. when i remove the link to the class file, the problem goes away. also, i have checked the class file for mentioning of "URLRequest" and nothing is there.

View 9 Replies

Actionscript 3 :: Implementing IEventDispatcher?

Jun 3, 2011

I haven't used the implements keyword before, and I've been trying to use it to implement the IEventDispatcher class to see if this would allow me to use addEventListener() in a class that extends Object (this is my understanding of what it's for - correct me if I'm wrong).My class is like this:

package
{
import flash.events.Event;

[code].....

View 2 Replies

ActionScript 3.0 :: Making An Object That Implements IEventDispatcher?

Feb 2, 2010

I'm interested in making an object that implements IEventDispatcher.

Does anyone know what the goes in addEventListener(...) dispatchEvent(...) etc. ?

My goal is to create my own simple Button that listens to mouse events, not 100% sure about the entire process (probably use hitTest and a single invisible pixel to trigger mouse events), this object extends BitmapData (Not an IEventDispatcher) so i have the option to use pure pixel rendering + mouse control.

View 5 Replies

Flex :: Unable To Bind Warning: Class Is Not An IEventDispatcher?

Apr 7, 2011

I am getting the error: warning: unable to bind to property 'Description' on class 'Object' (class is not an IEventDispatcher)

this is only when the data is bound to a List as an ArrayList, though. I had it in a Datagrid before (just as an Array) and it did not cause any issue. I'm not expecting to be able to bind any data back to the class 'object' not even sure which object exactly it's referring to.

My list data-provider is an ArrayList.. populated by a result event from an SQL query contained in another class:

private function loadDayComplete():void
{
var Meals:Array = _day.MealResults;

[Code].....

The day class I have is a data holder to get all the data (from several tables) for a 24 hour span.. I have classes for each individual datatype for editing them. But I'm not sure do I even need to worry about the warning if I don't plan on editing the values? it completely spams the console though whenever I touch anything, so I really would like to get rid of it. I tried an object proxy as I saw described elsewhere but nothing changed. The text is in label fields right now anyway, which can't even be edited.

View 2 Replies

Flex :: Class Implementing IEventDispatcher Cannot Use Event Metadata Tag

May 4, 2011

we have following class

[Code]...

If you run these, you'll notice that the MXML-component can't hear the event. The question is simple, is there some way of getting the Event-metadata tag to work WITHOUT extending EventDispatcher? I would like to keep this class independent and use object composition as much as possible. And no, I don't want to use ActionScript addEventListener in the MXML-file. It doesn't tell the developer anything like good old Event metadata tag, and besides, that is not the point of this example. :)

View 2 Replies

Arrays :: Flash - Pushing Or Adding Arrays As Values Into A Multi-dimensional Array?

Jan 21, 2011

I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:

var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........


I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.

View 1 Replies

Flex :: Unable To Bind To Property 'xmlnode' On Class 'XML' (class Is Not An IEventDispatcher)

Mar 14, 2012

i am using xmllistcollection for displaying data in list. whenever i run my application data is display in list control, but this warning has displayed in console. How can i remove this warning warning: unable to bind to property 'xmlnode' on class 'XML' (class is not an IEventDispatcher)

View 1 Replies

Actionscript 3 :: Set Rel=noreferrer In A URLRequest In Flash

Feb 26, 2011

I'm using a URLRequest to get a resource. I need to clear the Referrer information in the request. Is there a way to do this?

Snippet:

sound = new Sound();
var req:URLRequest = new URLRequest(url);
req.method = "POST";

[Code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved