Grabbing Php Data Into Weird Array
Hey guys,
Basically, I'm trying to loop through the msgx variables where msg0, msg1 come up. Problem is ev.target.data doesnt read my var msg as msg+k but just as msg
I tried it with static msg0's and msg1 and it works.
btw ars traces out null
ActionScript Code: var prek:Array = new Array(); for(var k:Number = 0; k < b +1; k++) { var msg:String = "msg"+k; trace(msg); var ars:String = ev.target.data.msg; trace(ars); prek.push(ars); }
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 05-05-2008, 06:55 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Grabbing URL Encoded Data
I need my flash movie to grab data from it's own URL much like a server script would (i.e. http://www.domain.com/flash.swf?data=value). I thought I remember reading once that there's an action script to do this automatically but I can't find any information on how to do this.
Is there a way or do I have to write an actionscript to parse the data?
Grabbing Data From A Component
Hello, I have a form with components. The info from the form is sent to a PHP script and processed. Everything works except I can not grab the data from the components. The only thing I need to know, which I've spent hours trying to figure out, is how to grab the info from the components and send them to the PHP processing script. My code works for all form fields except the components.
Here's my code:
Code:
stop();
var LV_out:LoadVars = new LoadVars();
var LV_in:LoadVars = new LoadVars();
LV_in.onLoad = function(success) {
if (success) {
gotoAndPlay("Display");
} else {
trace ("Error loading data into flash");
gotoAndPlay("Error");
}
}
//----------
submit_mc.onRelease = function() {
var custname:String = t1.text;
LV_out.billing = Fbilling.selectedItem.data;
LV_out.apptype = Fapptype.ComboBox.selectedItem.data;
LV_out.loantype = Floantype.selectedItem.data;
LV_out.purpose = Fpurpose.selectedItem.data;
etc . . .
LV_out.sendAndLoad("register4.php", LV_in, "POST");
gotoAndStop("Loading");
mySO.data.voted = "yes";
mySO.flush();
};
I also tried:
Code:
Fapptype_a= Fapptype.getSelectedItem().data;
But when I try to send the variable Fapptype_a to the php script, there is no data.
Can anyone help?
thanks
Grabbing HTML Form Data/embedding Flash
Is there a way of grabbing text from a form field in HTML and then sending as a variable to Flash?
I can get Flash into HTML/Javascript but I have never done it the other way.
Thanks
Grabbing The Position Of A Value In An Array
Okay, what I want is kinda hard to explain, so bear with me.
If I have an array:
ActionScript Code:
myPets = ["cat", "dog", "bird", "fish"];
Now, is there any AS that can use the value of say "dog", and return the position that "dog" is in the array, I know this seems a bit stupid and dog is obviously myPets[1], but when I'm creating arrays on the fly it becomes slightly harder.
Grabbing Correct Array And Placing Adding To String
Hey yall I am trying to grab a movie clip instance which is amongst an array and attach it to a string.
I am trying this:
Code:
stateArray = new Array(AL,AK,AZ, ect....);//names of mc instances
for (var i = 0; i<stateArray.length; i++) {
stateArray[i].onRelease = function() {
getURL("/pagoso/browsestate.aspx?cat="+cat+"&state="+stateArray[i], "_self");
};//each mc onRelease will grab "cat" from string and add its respective state Array to String
}
Results in state being undefined state;
Have tried this:
Code:
stateArray[i].onRelease = function() {
getURL("/pagoso/browsestate.aspx?cat="+cat+"&state="+stateArray[0], "_self");
};
}
Resulting in:
/pagoso/browsestate.aspx?cat=8&state=_level0.AL
and if I do just stateArray it adds all the states with _level0.AL, _level0.AK ect....
How come I cant get it to just grab MC instance?
Is There Anyway To Read Data In From A Text File And Populate An Array With The Data?
hello,
i'm new to flash, and i'm trying to create a photo gallery. however, the photos may not always be the same, and i need to have a way to easily change the pictures without having to go back into flash to change the code everytime. i thought a good way to do this would be to read the names of the pictures in from a text file and then use those names to populate an array, similar to the tutorial on creating a photo gallery on kirupa.com. the problem is, i have no idea how to do this. anyone have any ideas?
thanks
Converting Internal Array Data Into External XML Data [renamed]
I have this code inside my flash to name my navigation menu. Now I want to put this outside flash and load it via XML. How do save my different arrays into a variable for later use in my code?
In my nav fla (what i want to load from XML):
Code:
// MAIN MENU ARRAY
var mm_array:Array = ["MAIN1", "MAIN2", "MAIN3", "MAIN4"];
// SUB MENU ARRAY
var sm1_array:Array = ["sub1", "sub2"];
var sm2_array:Array = ["sub1", "sub2", "sub3"];
var sm3_array:Array = ["sub1", "sub2", "sub3"];
var sm4_array:Array = ["sub1", "sub2", "sub3", "sub4"];
var submenu_array:Array = [];
XML loading code
Code:
// LOAD MY XML
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
if (success) {
// what goes here to define: mm_array, sm1_array, sm2_array etc
myXML.load("myXML.xml")
XML file something like this:
PHP Code:
<navigation>
<menu>
<mm_array>main1</mm_array>
<sm_array>sub1</sm_array>
<sm_array>sub2</sm_array>
</menu>
<menu>
<mm_array>main2</mm_array>
<sm_array>sub1</sm_array>
<sm_array>sub2</sm_array>
<sm_array>sub2</sm_array>
</menu>
</navigation>
Is There Anyway To Read Data In From A Text File And Populate An Array With The Data?
hello,
i'm new to flash, and i'm trying to create a photo gallery. however, the photos may not always be the same, and i need to have a way to easily change the pictures without having to go back into flash to change the code everytime. i thought a good way to do this would be to read the names of the pictures in from a text file and then use those names to populate an array, similar to the tutorial on creating a photo gallery on kirupa.com. the problem is, i have no idea how to do this. anyone have any ideas?
thanks
Bitmap Data... Weird
Hi there.
I hope someone will be able to answer me.
Could you check this swf or fla (those are sample to show you what's weird)
What happen so.
I'm drawing on a MC (line) a black line, 5px thick, using lineTo(0, 100);
I'm copying this image on the BitmapData object (myBMP.draw(line));
I'm clearing the MC (line).
I'm redrawing on the MC (line) a white line, 5px thick, using lineTo(0, 100);
I'm copying this image on the BitmapData object (myBMP.draw(line));
I'm clearing the MC (line).
the result?
I can still see the black line underneath. I mean just the border of it... How come ?
If you're zooming and clicking several time on the draw second line you will see something more weird... Anyway for me...
Any help appreciated
C ya mates
Weird Problem Loading Data From Database
initially when i want to load data from database, it will output all the elements from a table
now i create a timer to make sure it will query from the database every interval to keep track of the updated content, however, the problem comes in...
when i delete a data from there, the data was somehow 'cached' into flash, meaning, it wasn't updated at all.
weird thing is, if i port the data over to xml and update the file, the flash would show the updated data correctly
can anyone tell me why is this happening?
So Weird Why Doesnt My Spending Data To Php Work?
okay so php is
PHP Code:
<?php
$abc = $_POST['abc'];
echo "$abc";
?>
flash is
Code:
// frame one <---
var abc = "HELLO";
loadVariablesNum("http://localhost/abc.php",0,"POST");
^ its so weird it doesnt work now, i made a register user name script and it works and now i try this simple test and it doent any ideas? whats the scope of loadVariablesNum
So Weird Why Doesnt My Spending Data To Php Work?
okay so php is
PHP Code:
<?php
$abc = $_POST['abc'];
echo "$abc";
?>
flash is
Code:
// frame one <---
var abc = "HELLO";
loadVariablesNum("http://localhost/abc.php",0,"POST");
^ its so weird it doesnt work now, i made a register user name script and it works and now i try this simple test and it doent any ideas? whats the scope of loadVariablesNum
Weird Array Issue
im having a very strange array issue right now. any help on this would rock...
i am creating new movieclips, and then trying to store a reference to each one within an array called "openWin_array"
Here is that code...
Code:
cw_mc = windows_mc.attachMovie("contentWindow_mc", "contentWindow" + content_loc + "_mc", contentLoc + 1);
addToArray(openWin_array, cw_mc);
I pass the array and what needs to be added within the array to a function i setup called "addToArray"...here is that function
Code:
_global.addToArray = function(array, obj) {
// just keep adding stuff to array
r = array.push(obj);
trace(array);
};
now, it seems like this should work fine, but it doesn't? It will add the mc to the array, but it will delete the previous entry within the array....
for instance, the first time an mc is created...it will push the value into the array, and then the second or third time, it will push the new value into the array at the end, but all previous entries are deleted? What the crap is that? What am i doing wrong?
please help...
String From Array Is Being Weird :S
Hi all, I'm trying to get my simple tickerbox to work. It should tick out the message that was found in an array. This is my code:
PHP Code:
function TextScroll(Val) { for(i=0; i<MyArray.length; i++) { if (MyArray[i][0] == Val) { rollScroll(MyArray[i][0],MyArray[i][1]); // Name, text } }}function RollScroll(NAME,TEXT) { var a:Number = 0; var thisText:String = TEXT; _root.scroll.name.text = NAME; onEnterFrame = function() { _root.scroll.input.text = thisText.substr(0,a); a++; }}
Well, all seems to work UNTILL i get to
PHP Code:
onEnterFrame = function() { _root.scroll.input.text = thisText.substr(0,a); a++;}
Because I use substr() on my variable (which was defined as a string) I get the message "Undefined". When I leave the substr() away it goes well, but then I won't have my ticker effect.
Any thoughts? Thanks A LOT in advance!
Weird Array Issue
im having a very strange array issue right now. any help on this would rock...
i am creating new movieclips, and then trying to store a reference to each one within an array called "openWin_array"
Here is that code...
Code:
cw_mc = windows_mc.attachMovie("contentWindow_mc", "contentWindow" + content_loc + "_mc", contentLoc + 1);
addToArray(openWin_array, cw_mc);
I pass the array and what needs to be added within the array to a function i setup called "addToArray"...here is that function
Code:
_global.addToArray = function(array, obj) {
// just keep adding stuff to array
r = array.push(obj);
trace(array);
};
now, it seems like this should work fine, but it doesn't? It will add the mc to the array, but it will delete the previous entry within the array....
for instance, the first time an mc is created...it will push the value into the array, and then the second or third time, it will push the new value into the array at the end, but all previous entries are deleted? What the crap is that? What am i doing wrong?
please help...
Weird Array Problem.
actionscript Code:
Original
- actionscript Code
num = 0;
picsArr = new Array(6);
picArr[0] = "-";
picArr[1] = "-";
picArr[2] = "-";
picArr[3] = "-";
picArr[4] = "-";
picArr[5] = "-";
trace(picsArr[num]);
num = 0;picsArr = new Array(6);picArr[0] = "-";picArr[1] = "-";picArr[2] = "-";picArr[3] = "-";picArr[4] = "-";picArr[5] = "-";trace(picsArr[num]);
that traces undefined but I have no idea why
Weird Bug In ActionScript Envolving Array. Please Help.
I'm using Flash MX 6.0 and Flash MX 2004 Professional
Try this:
Code:
normal = new Array(01,02,03,04,05,06,07,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
Now check syntax.
It should appear "This script contains no errors".
Now try this:
Code:
normal = new Array(01,02,03,04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
Now check syntax. It says ERROR.
Code:
Scene=Scene 1, Layer=ac, Frame=1: Line 3: ')' or ',' expected
normal = new Array("01","02","03",04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
Scene=Scene 1, Layer=ac, Frame=1: Line 15: Unexpected '}' encountered
}
The only diference is that I have a "08" instead of "8" in the Array. Is that a Flash bug or an error in my code?
Thanks.
Weird Switch/Array Problem
Hello, I have a switch statement that dumps into an Object, wich dumps into an Array. Inside the switch everything works fine but when I return the Array of objects outside the switch, the only object that gets sent is the last object repeated throughout the array. I hope this is clear, I will send my code.
var deckSize:Number = 50;
var Card:Object = new Object();
var Deck:Array = Array();
//
function simulationDeck() {
//
for (i=0; i<deckSize; i++) {
randomCard = random(5);
switch (randomCard) {
case 0 :
Card.type = "Tank";
Card.weight = "Heavy";
Card.Image = "Heavy_Tank.jpg";
break;
case 1 :
Card.type = "Tank";
Card.weight = "Medium";
Card.Image = "Medium_Tank.jpg";
break;
case 2 :
Card.type = "Tank";
Card.weight = "Light";
Card.Image = "Light_Tank.jpg";
break;
case 3 :
Card.type = "Mine";
Card.weight = "NA";
Card.Image = "Mine.jpg";
break;
case 4 :
Card.type = "Range Rocket";
Card.weight = "NA";
Card.Image = "Range_Rocket.jpg";
break;
}
Deck[i] = Card;
trace("Card "+Deck[i].type);
}
for (i=0; i<deckSize; i++) {
trace("Card 2 "+Deck[i].type);
}
return Deck;
}
The first trace works fine, but then I check it outside the Switch and the deck Array gets rewritten with the last item in the list. Any Thoughts? Thanks for you applies!
Weird Prob With Array + Grid
Hi,
I am having a small problem which is best explained with the code :
PHP Code:
/*in the library is a linked mc.letBox, within the mc is a standard dynamic txt box, code on frame1 of letBox is:*/
label.text = _name;
/*on fr1 of the fla is this code:*/
myLVs = new LoadVars();
myLVs.load("myAlphabet.txt");
myLVs.onLoad = function(success)
{
if (success)
{
myArr = new Array();
myArr = this.myLets.split(",");
trace(myArr)
cols = 9;
rows = 3;
butHeight = 30;
butWidth = 30;
for (var r = 0; r<=rows; r++)
{
for (var c = 0; c<=cols; c++)
{
if (i<myArr.length)
{
attachMovie("letBox", myArr[i],i,{_y:r * butWidth, _x:c * butHeight});
}
i++;
}
}
}
};
myAlphabet.txt looks like this:
&myLets=A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U, V,W,X,Y,Z
Everything works as it should except for one small thing, the first element of myArr is not being assigned to the first mc, it is just empty!!!
I have run all the relevant traces, the txt file loads in OK, the split function works and myArr() is created and the grid is created, but the first element ( letter A ) is just not there and a cannot figure out why !!
I have posted an fla for those with the time to take look
Cheers
Vosgien
[AS 2.0] Weird Array Push Problem
here's a weird problem: in the second loop, the trace shows that i'm accessing the right element, put the array isn't populated with the push!!! what am i doing wrong?
Code:
prodXML.onLoad = function(success:Boolean)
{
var prod:Array = prodXML.firstChild.childNodes;
var path:Array = new Array();
var image:Array = new Array();
if (success)
{
for (i=0; i<prod.length; i++)
{
path.push(prod[i].attributes.path);
trace ("path[" + i + "]: " + path[i]);
// this returns correctly: parts/ and fruits/ respectively
var prodItem:Array = prod[i].childNodes;
for (j=9; j<prodItem.length; j++)
{
image[i].push(prodItem[j].attributes.image);
trace ("image[" + i + "][" + j + "]: " + image[i]);
// this returns "undefined": WTF?!
trace ("image: " + prodItems[j].attributes.image);
// this returns correctly: cc-22.png, cc-29.png, cc-21.png and cc-28.png
}
}
}
}
XML FILE:
<stuff color1="0xC1272D" color2="0x971B1E">
<frog_wrenches path="datacore/parts/">
<item image="cc-22.png"/>
<item image="cc-29.png"/>
</frog_wrenches>
<robot_berries path="datacore/fruits/">
<item image="cc-21.png"/>
<item image="cc-28.png"/>
</robot_berries>
</stuff>
i am totally stumped here! i'm sure it's some dumb little thing (isn't it always?).
thanks in advance.
WR!
Array.shuffle() Weird When Elements Are Objects
I asked this question on ultrashock, but I'll ask it here too, great answers here.
I have this method which shuffles an array:
Code:
// returns an array with elements shuffled in a random order
Array.prototype.shuffle = function() {
var shuffled_arr = []; // create an empty array
var copy_arr = this.slice(); // make a copy of the array
for (var i=0; i < this.length; i++) { // loop through each element of the array
shuffled_arr[i] = copy_arr.splice(Math.floor(Math.random() * copy_arr.length), 1);
} // end looping through each array element
return shuffled_arr;
} // end shuffle() method
This works great when the elements of the array are numbers or strings.
However, if each element is an object, e.g.
Code:
var my_arr = new Array();
for (var i=0; i < 10; i++) {
my_arr.push({x: i * 15, y: 0});
} // end loop
// return a shuffled array
var new_arr = my_arr.shuffle();
the object properties of each element get all messed up. new_arr[0].x and new_arr[0].y are no longer defined.
Instead, if you trace the properties of each element,
Code:
for (var i=0; i < 10; i++) {
var thisItem = this.ran_arr[i];
for (var prop in thisItem) {
trace("thisItem has property " + prop);
} // end
trace("shuffle: " + thisItem.shuffle);
}
you see the properties are "0" and "shuffle". Further, the last trace tells me that "shuffle" is a function (as it should be).
I'm not exactly sure what's going wrong here. I reckon it has something to do with my shuffle() method, but I can't seem to see what's wrong with it. Anybody have any ideas?
Copy A Multi-dimensional Weird Array
Hey Fk, I have got a big weird array and I need a copy of it but I can't use the = because then I can modify one of the two array without modifying the other one. Please...help ^^
Array Data Is Set Then Lost... But Just One Array
Hi,
I have 3 arrays, 2 hold different information which will be combined into the third one.
The creation/population of each array is done with in each own function as results are sent back to the flash from remoting.
I have attached a mock up of the code below.
Code:
array1 = new Array();
array2 = new Array();
array3 = new Array();
combineArrays = function () {
for (j=0; j< array2.length; j++) {
array3.push({something:array1[j].something, something:array2[j].something, ....});
}
this.myGrid.setDataProvider(array3);
};
query2_Result = function (result) {
array2.push({something:result[0].something, ....});
};
query1_Result = function (result) {
aMatrix = result;
for (i=0; i<aMatrix.length; i++) {
array1.push({something:aMatrix[i].something, ....});
remoting.query2(int(aMatrix[i].something), "");
}
combineArrays();
};
array1 and array3 keep the data that was populated into it. But by the time we reach the combine function array2 has no data.
I'm not sure why its losing the information, if you trace with in query2_Result() you get all the information that was populated into the array2.
Any help would be greatly appreciated.
Ty,
alex
XML Data 2 AS Array
How load XML data in array of AS????
XML data:
010010100100010111100100010101.....
Data To Array
Hi i know this sounds like a subject widely discussed before but i dont find this particular example...
I have a txt file that looks like this:
"Date""Time""Temperature""Pressure_depth_N""Pressure_speed_N""depth__m_""speed___""light_N""pitch""rol""comp1_N""comp2_N""comp3_N""back_belly_N"
30-10-20040:00:0010.861046.521062.520.3816.006.22-78.8034.35-75.54-7.62137.653.00
30-10-20040:00:0510.891046.341062.930.3816.586.13-80.4728.41-54.14-17.42118.923.00
30-10-20040:00:1010.891042.811059.560.3416.746.18-81.6034.75-32.27-35.15155.723.00
This database export is diving data from a seal sent via satelite. It gives a range of info every 5 seconds and I want to animate a seal to visualize this information.
I will need to make a timeline with a slider sliding this would show a number of characteristics for every particular time.
I thought making a 2 dimentional array and linking the play head to the first dimention and read the second dimention array for the characteristics.
the 1st question: how would i "read this data into a multidimentional array, since i dont have the possibility to get the data in any other format using (& or | ...).
thanks for having a look at this
XML Data To ARRAY
hey guys,
im brand new to the XML game and ive been fiddling for a long time trying to get this to work.
The code im trying to write needs to, load the titles of each "slide" into an array for that page. Can i get some help, im SO stuck.
The XML is shown below.
Code:
<?xml version="1.0"?>
<page name="page1">
<slide>
<title>Personnel Industry</title>
<body> - Body Goes here<br><br>hello</body>
</slide>
<slide>
<title>Business Advice</title>
<body>All the business advice in the world goes here</body>
</slide>
</page>
<page name="page2">
<slide>
<title>Personnel Industry</title>
<body> - Body Goes here<br><br>hello</body>
</slide>
<slide>
<title>Business Advice</title>
<body>All the business advice in the world goes here</body>
</slide>
</page>
Thanks for the help, in advance.
[F8] Array From An XML Data
Hi,
i have a problem. I would like to retrive xml data from an external file. An than i would collect data from that xml to be compared with some id buttons.
ex. IF (xml output atributte) == (id of button), than dissplay button red, else dissplay blue.
I have no problems till here. This is the array and its conntent.
var dataValues = new Array();
dataValues[0] = "100";
dataValues[1] = "131";
if i do it manualy, like you see above, it all works fine. The buttons respond to it just fine and have the correct color. But if i try to implement it to a load from the xml file all the buttons stay blue.
I dont know how to set an array in this:
function loadXML(loaded) {
if (loaded) {
dataValues[42] = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
// EVEN IF I TRY dataValues[1] = "200" or something. It just doesent work in that function
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("buttons.xml");
Please help. Ive been trying all day and no success.
[F8] Set An Array From An XML Data
Hi,
i have a problem. I would like to retrive xml data from an external file. An than i would collect data from that xml to be compared with some id buttons.
ex. IF (xml output atributte) == (id of button), than dissplay button red, else dissplay blue.
I have no problems till here. This is the array and its conntent.
var dataValues = new Array();
dataValues[0] = "100";
dataValues[1] = "131";
if i do it manualy, like you see above, it all works fine. The buttons respond to it just fine and have the correct color. But if i try to implement it to a load from the xml file all the buttons stay blue.
I dont know how to set an array in this:
function loadXML(loaded) {
if (loaded) {
dataValues[42] = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
// EVEN IF I TRY dataValues[1] = "200" or something. It just doesent work in that function
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("buttons.xml");
Please help. Ive been trying all day and no success.
Xml Data With An Array
I have created a photo gallery with help from a tutorial and a small amout of knowledge with OOP. The doc class imports the xml data and puts it into an array to be placed in a holder on the stage. The xml data is also taken into the menu holder to perform movement between the different images loaded. What I want is for the top buttons to be placed on the outer edges, right and left, of the stage and be able to jump to next and previous images. The class is using the "text" from the xml to communicate which image it will display and I can not replace this function with the next previous function I have tried.
thanks
Brian
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.SharedObject;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Bitmap;
import flash.external.ExternalInterface;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.net.LocalConnection;
import flash.events.StatusEvent;
import flash.geom.*;
import flash.text.TextField;
import flash.system.System;
import flash.text.TextFormat;
import flash.utils.*;
public class PhotoViewer extends MovieClip {
private var xmlLoader:URLLoader;
private var xml:XML;
private var xmlList:XMLList;
private var holder:MovieClip;
private var menuHolder:Sprite;
private var imgHolder:MovieClip;
private var pos:Number;
private var loader:Loader;
private var urlRequest:URLRequest;
private var fakeHolder:Sprite;
private var black:Sprite;
private var myBitmapData:BitmapData;
private var imageContainer:ImageContainer;
private var imgPos:Number;
private var imgTotal:Number;
private var stageW:Number;
private var stageH:Number;
private var finalX:Number;
private var diffX:Number;
private var xi:Number;
private var cX;
private var _percentage;
private var item_array:Array;
public function PhotoViewer() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
init();
}
private function init():void {
item_array=[];
this._percentage=0
diffX=1;
finalX=0;
cX=0;
stageW=stage.stageWidth;
stageH=stage.stageHeight;
menuHolder=new Sprite();
black=new Sprite();
addChild(black);
drawColorRect(black,0xffffff,stageW,stageW);
holder=new MovieClip();
imgHolder=new MovieClip();
holder.addChild(imgHolder);
holder.addEventListener(Event.ENTER_FRAME,dispatch OnEnterFrame);
addChild(holder);
loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.IN IT, onImageLoaded);
fakeHolder=new Sprite();
fakeHolder.addChild(loader);
resizeHandler(null);
xmlLoader=new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,parseXML );
xmlLoader.load(new URLRequest("dataill.xml"));
urlRequest=new URLRequest();
}
private function dispatchOnEnterFrame(e){
if(diffX==0)return;
imgHolder.x+=(finalX-imgHolder.x)/6;
cX+=(finalX-cX)/6;
var per=100*(1-(finalX-cX)/diffX);
percentage+=(per-percentage)/12;
holder.scaleX=1-(.5)*Math.sin(Math.PI*percentage/100);
holder.scaleY=1-(.5)*Math.sin(Math.PI*percentage/100);
}
private function parseXML(event){
xml=new XML(event.target.data);
xml.ignoreWhitespace=true;
xmlList=xml.img;
imgPos=0;
imgTotal=xmlList.length();
addChild(menuHolder);
var menuItem:Sprite;
var menuText:TextField;
var format:TextFormat = new TextFormat();
format.font = "_sans";
format.color = 0xffff00;
format.align='center';
font size
format.size = 8;
for(var i=0;i<xmlList.length();i++){
menuText=new TextField();
menuText.width=16;
menuText.height=28;
menuText.defaultTextFormat=format;
menuText.text=i;//
menuText.selectable=false
menuText.border=true;
menuText.borderColor=0x000000;
menuText.name="text";
menuItem=new Sprite();
menuItem.addChildAt(menuText,0);
menuItem.x=i*(menuItem.width+8);
menuItem.graphics.beginFill(0xffff00,1);
menuItem.graphics.drawRect(0,0,menuItem.width,menu Item.height);
menuItem.graphics.endFill()
menuItem.mouseChildren=false
menuItem.useHandCursor=true;
menuItem.buttonMode=true;
menuItem.addEventListener(MouseEvent.CLICK,handleI temClick);
menuHolder.addChild(menuItem);
}
resizeHandler(null);
loadNextImage();
}
private function handleItemClick(e:Event){
var item:Sprite=e.target as Sprite;
var _text:TextField=item.getChildByName("text") as TextField;
showImageAt(parseInt(_text.text));
}
private function loadNextImage(){
if(imgPos==imgTotal){
return;
}
var url:String=xmlList[imgPos].toString();
urlRequest.url=url;
loader.load(urlRequest)
}
public function set percentage(value:Number){
this._percentage=value;
}
public function get percentage():Number{
return this._percentage;
}
private function showImageAt(pos:Number){
cX=xi=imgHolder.x;
finalX=-(item_array[pos].x);
diffX=finalX-xi;
}
private function drawColorRect(_in:Sprite,color:Number,nW:Number,nH :Number) {
_in.graphics.beginFill(color);
_in.graphics.drawRect(0, 0, 800,200);
_in.graphics.endFill();
}
private function onImageLoaded(event:Event) {
fixSize(loader);
myBitmapData= new BitmapData(loader.width, loader.height);
myBitmapData.draw(fakeHolder);
var imgContainer:ImageContainer=new ImageContainer();
imgContainer.imageData=myBitmapData;
imgContainer.x=stageW*(imgPos)+imgPos*stageW/2;
imgHolder.addChild(imgContainer);
item_array.push(imgContainer);
imgPos++;
if(imgPos>=imgTotal){
onAllImagesLoaded();
return;
}else{
loadNextImage();
}
}
private function onAllImagesLoaded(){
}
private function fixSize(loader:Loader) {
var sw:Number=1;
var sh:Number=1;
loader.scaleX=1;
loader.scaleY=1;
if (loader.width>stageW) {
sw=stageW/loader.width;
}
if (loader.height>stageH) {
sh=stageH/loader.height;
}
var s:Number=Math.min(sw,sh);
loader.width*=s;
loader.height*=s;
}
private function resizeHandler(event:Event):void {
drawColorRect(black,0xffff00,stage.stageWidth,stag e.stageHeight);
stageW=stage.stageWidth-30;
stageH=stage.stageHeight-30;
holder.x=400;
holder.y=260;
menuHolder.x=(stage.stageWidth-menuHolder.width)/2
}
}
}
Array Data
I have an array:
ActionScript Code:
var unloadedButtons:Array = new Array();
In this array, I store buttons:
ActionScript Code:
_root.attachMovie("btn_myButton", "myButton", _root.getNextHighestDepth());
unloadedButtons.push(myButton);
unloadMovie(myButton);
I then attempt to retrieve those buttons in that array:
ActionScript Code:
var newButton = unloadedButton.shift();
When I trace that out I get: _level0.myButton. Is this write or am I missing something?
Essentially I want to be able to put buttons on the stage that could not fit when the movie was initially loaded (this is for a Stage.onResize event).
Is the problem where I attach the button, then if it doesn't fit, I put it in the unloadedButtons array and then do:
unloadMovie(mybutton);
XML Data Into An Array
Hey,
I have successfully loaded an external XML data file into my movie. Now I would like to save the node values into an array so i can manipulate and call as required...Is this possible or is there a better way to go about this?
Array Data
I have an embedded object that has properties, and i am unsure how to get the property values....
Variable _level0.ctDir = [object #200, class 'Array'] [
173:[object #382, class 'lineData'] {
num:"153",
filename:"file.swf",
page:"174"
}
]
I need to get the value of "num" so i can compare it to another value.
Array Data To Textfield In Mc
I'm trying to get part of the information stored in an array to a textfields in a movie clip.
The array looks like this:-
userData = [[1,the text for field 1,the text for field 2],
[2,the text for field 1,the text for field 2],
[1,the text for field 1,the text for field 2]];
the first variable is setting the frame [1 or 2] of the movieclip but I can't figure out how to get the text across.
2-D Array Data To Function
2-D Array Data to Function ------------------------------------
Looking for some clarification here. I have a 2-D array that I am using to declare 3 variables that I will pass to the function. I know I could generate this straight on with a foor loop but I would like to create a global function I can pass this all to. (Better
obviously for reusability purposes) I would imagine it would be a funciton.apply and .call but again ot sure how I really declare it and then process within the function.
Here is what I have so far:
// ================================================== ==============
// NAVIGATION
// ================================================== ==============
// Total this frame -----------------------------------------------
totalFly = 6;
// Declare array of content to be assigned to button---------------
myArray = new Array();
// 0's must be declared to start array (use this as frame of reference ) -----
myArray[0][0] = ""; // direction of fly-out
myArray[0][1] = ""; // content
myArray[0][2] = ""; // pic fly-out name (may not be used at all)
// Actual navigation information ---------------------------------
myArray[1][0] = "";
myArray[1][1] = "";
myArray[1][2] = "";
// Generate navigation based on array data -------------------------
function navGeneration (totalFly,???????) {
for(i=1; i<=totalFly; i++) {
this["nav"+i].id = i;
this["nav"+i].onPress = function () {
// Assign content variables -------------
contentDir = myArray[this.id][0];
content = myArray[this.id][1];
_root.picflyout = myArray[this.id][2];
// Activate content fly-out box ----------
this["content"+contentdir].gotoAndPlay(2);
};
this["nav"+i].onRelease,onRollOut = function () {
// close content box
this["Content"+contentdir].gotoAndPlay ("reverse");
// clear fly-out name
_root.picflyout = "";
};
//this["nav"+i].onRollOut = function () { _root.rolloutButton(this.id); };
//trace(this["nav"+i].id);
}
}
// Call function for nav generation and send variable and array --
navGeneration(totalFly);
navGeneration.apply(navGenArray, myArray)
I Cant Do Math On Array Data, Why?
I need to subtract the value of a piece of array data from another piece of data in the same array, but for the life of me it isn't working.
_root.tracktimes[laps] = _root.goTime;
takes the working time and shoves it into position 1 say (position zero always has a value of 0)
then, because I am recording lap times, I want to take the previous value and subtract it from the one just recorded thus.
(I know that for the first lap taking zero away from a value wont change it, but as the laps progress, it still wont do it... although, I can reduce it by say "10" - but not if the data is stored in an array.)
_root.tracktimes[laps] -= _root.tracktimes[laps-1];
The thing is, it just doesn't change the value.
I know you can access the array identifier with: [laps-1] as it works with the trace action. I have tried using parsefloat and swapping out to another variable... it just does not want to do the maths.
Is there something I should know? any help would be appreciated:
You try subtracting on array value from another!
If it means anything to anyone "I am I said" by neil diamond is on the stereo. Thats how bad it is.
Code:
//cross the finish line??
if(anim, hittest(_root.finishline) && halfway == true && _root.racebegun == true){
laps += 1;
trace("remaining laps = " + laps);
_root.lapmessage = "player has " + laps + " left";
_root.lapcompleted._x = this._x;
_root.lapcompleted._y = this._y;
_root.playerlap = laps + " of 5";
_root.lapcompleted.gotoAndPlay(1);
_root.lastlap = _root.minutes + ":" +_root.seconds + ":" +_root.milli;
_root.tracktimes[laps] = _root.goTime;
_root.tracktimes[laps] -= _root.tracktimes[laps-1];
trace(_root.tracktimes[laps] + " lap");
trace(_root.tracktimes[laps-1] + " lap -");
trace(_root.tracktimes + " the lot");
halfway = false;
}
[code]
Lost Array Data
i've created a new array which gets built by a flash function performed on an xml object. when i put a trace at the end of the function, all the data has been added properly, but when I trace it after the function is called, the array comes up as empty. help.
i put the pertinent code <a href="http://home.earthlink.net/~benjoya/data/array.html">here</a>.
thanks,
dave
Adding Data To An Array
If you have an Array that looks like this for example:
Code:
name_of_array = ["value1","value2","value3"];
What kind of code would you use to add another value. I'm kind of aware of the "push" but lets say I want to add this value somewhere on the timeline. What would the code be on the timeline so that when that instance happens it puts it into my Array? Any thoughts?
Covert XML Data To Array. Can U Help Me Please? Thank You.
Hello,
i loaded a XML file into my flash movie. I have 3 questions:
1. How can i convert the data in XML to an array in flash so i can use it in my movie?
2. Do u know any component, prototype or function for this?
3. Is there a better way to use the XML data in my flash movie?
Thanks,
Miguel
Saving Data From An 2-D Array
I'm making tennis a video game in flash where the computer gets better by learning from its mistakes. The mistake data is stored in a 2-d array. But every time I close the projector the computer has to learn all over again (and that takes too much time). Is there a way that I can save the data from the array in a file and then read that data every time I open the projector? Also why does my game slow down after it has been running for a while, is there a way to clear the memory or something?
Saving Data From A 2-D Array
I'm making tennis a video game in flash where the computer gets better by learning from its mistakes. The mistake data is stored in a 2-d array. But every time I close the projector the computer has to learn all over again (and that takes too much time). Is there a way that I can save the data from the array in a file and then read that data every time I open the projector? Also why does my game slow down after it has been running for a while, is there a way to clear the memory or something?
How Do I Take My XML Data, Put It Into An Array, And Then Shuffle It?
I've seen a few examples that pertain to my situation, but none of them seem to directly provide a solution.
I am populating a grid of 18 squares with data from an xml document (logo, company name, description text, and a URL) and would like content of the squares to be in a different order each time the page loads.
I assume I need to push my xml data into a new array, then run that data through some sort of randomizer function, and then populate my boxes by accessing the new array.
I need to know *how* to do this however. Any help would be so very much appreciated. I'm stumped.
Many thanks in advance.
Below I've included some code and a sample of my xml doc:
Code:
var snapshot_xml = new XML()
snapshot_xml.ignoreWhite = true;
snapshot_xml.onLoad = function (success) {
test(this);
}
snapshot_xml.load("snapshot.xml");
function test (node_xml) {
rootElement_xml = node_xml.firstChild; // get document's root node
}
//accessing elements like this
//_root.rootElement_xml.childNodes[0].childNodes[1].firstChild.nodeValue
Code:
[myNode]
[company]
[name]co_amd[/name]
[description]lorem ipsum dolor sit amet[/description]
theLink
[/company]
[/myNode]
Storing Data In A Array
Does anybody know about a site that explains how to store data in array sent from check boxes, button, lists?
I really appreciate the help.
Loading Data Into An Array
Hi..
I'm using loadvars to load data and then I populate and array that I use to build some dynamic navigation. Everything works fine if I click on my navigation link twice. The first time I click on the navigation link my dynamic navigation doesn't even get built. I think it has to do with with making sure the data is loaded. But I thought that what the if success == true part is all about. Do I need to double check to see if the data is loaded. I'm kinda frustrated so I'm willing a to pay a pro actionscripter to work with me remotely a bit.
Thanks,
Dan
if (success == true) {
for (i in myVars) {
var pushed = content.push([i]);
}
for (n=0; n<content.length-2; ++n) {
set("item" add n, content[n]);
}
set("ti", n);
[F8] XML Data Into A Multidimensional Array
This multidimenisonal array is going to contain a site's navigation.
The XML loads, then calls the "linkAdder" function to parse the XML node values. It checks to see if there are child nodes of the XML data it's reading, and if so, creates another array within the value it's populating and calls itself. What I'm going for is a structure like this:
PHP Code:
var mainNav:Array = Array('A', 'B', 'C', 'D', 'E', 'F', 'G');
mainNav[4] = Array('D', 'D-A', 'D-B', 'D-C', 'D-D', 'D-E');
mainNav[4][1] = Array('D-A', 'D-A-A', 'D-A-B', 'D-A-C');
trace(mainNav);
I'm running into problems though. Instead of mainNav[4] being 'D', it's always replaced with 'D-A'. In other words, the value from xml_data.childNodes[4].childNodes[0] is replacing the value in xml_data.childNodes[4].
I've been looking at this too long, and my brain's turning to mush. I know my XML is formated properly. Can anyone help in any way?
PHP Code:
function loadLinkXML() {
var link_xml:XML = new XML();
link_xml.ignoreWhite = true;
link_xml.onLoad = function(success) {
if (success) {
_global.mainLinks = Array();
linkAdder(link_xml.firstChild, _global.mainLinks);
trace(_global.mainLinks);
}
};
link_xml.load("nav.xml");
}
function linkAdder(xml_data:XMLNode, container:Array) {
for (var i:Number = 0; i < xml_data.childNodes.length; i++) {
if (xml_data.childNodes[i].firstChild != undefined) {
container[i] = Array();
container[i].push(xml_data.childNodes[i].attributes.display_name);
linkAdder(xml_data.childNodes[i], container[i]);
} else {
container.push(xml_data.childNodes[i].attributes.display_name);
}
}
}
loadLinkXML();
Storing Data In An Array
Hey,
K im new to all this actionscript stuff so ill try and explain this as best as i can.
Im trying to generate a random number between 1-52(deck of cards)
So when a number is displayed it will call the name of the card which is stored in and array.
This is what i came up with
Quote:
on (release) {
myDisplay = deck[random (13)];
}
deck = new Array();
deck[0] = "Ace of spades";
deck[1] = "Two of spades";
deck[2] = "Three of spades";
deck[3] = "Four of spades";
deck[4] = "Five of spades";
deck[5] = "six of spades";
deck[6] = "seven of spades";
deck[7] = "Eight of spades";
deck[8] = "Nine of spades";
deck[9] = "Ten of spades";
deck[10] = "Jack of spades";
deck[11] = "Queen of spades";
deck[12] = "King of spades";
the next thing I want the data that is generated to be stored in another array so I can gather how many times each card was generated (PROBABILITY) for all use maths people
Please help ive tried everything i just cant seem to get my head around it
Thanks
Barry
Extracting Data From Array
Hi,
I am using the loadVars class (Flash 8) to load key/value pairs from a mySQL database through php (example &pic1=pic1.jpg&pic2=pic2.jpg&...).
The ultimate goal is to create a dynamic slideshow with a variable length, depending on how many pics were submitted by the user. Since the associative array object returned by loadVars does not share the "length" property of indexed arrays, my guess is that the values need to be converted into a new indexed array before being able to use them in the slideshow. If this is correct, what would be the most efficient method? If this assumption is not correct, any other suggestions?
Thanks,
MPLeeds
Creating Array W/ XML Data
Hi,
I'm having troubles creating an array with data retrieved from an XML document. If I trace filename[i] from within the loadXML function it traces the appropriate data but if I try to loop through the filename array outside the loadXML function, it appears to be empty. If anyone can help I would appreciate it. Thanks!
Code:
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("Flash-MainList.xml");
filename = [];
function loadXML(loaded) {
if (loaded) {
var compNodes = this.firstChild.childNodes[1].childNodes[0].childNodes[0].childNodes;
for (i=1; i<compNodes.length; i++) {
filename[i] = compNodes[i].childNodes[0].childNodes[0].nodeValue;
trace(filename[i]);
}
}
}
Assigning XML Data Into An Array
Hello,
I'm building a portfolio website in Flash and want to dynamically load projects from an XML file. I have the following XML data that I am trying to bring into an array -
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<projects>
<project desc="Hello World!" url="http://www.google.com" body="Lorum ipsum dolor sit amet" thumb="images/portfolio1.jpg">
<images>images/portfolio1_1.jpg</images>
<images>images/portfolio1_2.jpg</images>
<images>images/portfolio1_3.jpg</images>
</project>
<project desc="Hello World!" url="http://www.google.com" body="Lorum ipsum dolor sit amet" thumb="images/portfolio2.jpg">
<images>images/portfolio2_1.jpg</images>
<images>images/portfolio2_2.jpg</images>
<images>images/portfolio2_3.jpg</images>
</project>
<project desc="Hello World!" url="http://www.google.com" body="Lorum ipsum dolor sit amet" thumb="images/portfolio3.jpg">
<images>images/portfolio3_1.jpg</images>
<images>images/portfolio3_2.jpg</images>
<images>images/portfolio3_3.jpg</images>
</project>
</projects>
I can bring the main project data into an array (desc, url, body, thumb), but the <images> nodes are causing issues. The idea is there will be any number of <images> nodes and I'll set up a loop in Flash to extract each one.
Should I set this up as a multidimensional array or do I not need to bother? How do I extract the data in the images nodes?
Here's the actionscript I'm using -
Code:
var plist:XML = new XML();
plist.ignoreWhite = true;
plist.onLoad = function() {
projects = this.firstChild.childNodes;
for (i=0; i<projects.length; i++) {
mc.portfolioItem_mc.duplicateMovieClip("portfolioItem_mc"+i, i);
mc["portfolioItem_mc" + i]._y = 48 + (i*17);
mc["portfolioItem_mc" + i].portfolioTitle_txt.text = (projects[i].attributes.desc);
// add extra images code here
}
}
plist.load("portfolio.xml");
It would be useful if someone could modify the above code to display each image in the <images> nodes somewhere on the screen. This should be enough for me to go on to modify the code so it works the way I want it to!
Thanks for your help,
Matt
Load Data Into Array
Hi..
I'm using loadvars to load data and then I populate and array that I use to build some dynamic navigation. Everything works fine if I click on my navigation link twice. The first time I click on the navigation link my dynamic navigation doesn't even get built. I think it has to do with with making sure the data is loaded. But I thought that what the if success == true part is all about. Do I need to double check to see if the data is loaded. I'm kinda frustrated so I'm willing a to pay a pro actionscripter to work with me remotely a bit.
Thanks,
Dan
if (success == true) {
for (i in myVars) {
var pushed = content.push([i]);
}
for (n=0; n<content.length-2; ++n) {
set("item" add n, content[n]);
}
set("ti", n);
|