See Related Forum Messages: Follow the Links Below to View Complete Thread
Problem Interpreting Data
i have an xml that has image map information that i've imported into flash. i'm making flash draw the picture using the coordinates set in the <area> tag.
e.g. <AREA SHAPE="poly" ALT="" COORDS="324 ,494, 325, 494, 326, 494, 327, 494, 328, 494, 329, 495, 330, 495, 331, 496, 332, 496, 333, 496, 323, 495" HREF=""/>
getting all the data into flash from the xml file is no problem, what is a problem is the COORDS attribute comes through as a single string. I want to get as an array. I can't figure out a simple and programatically quick way of doing it.
What i have done is loop through each string and using the comma's as markers, i've extrated the values and put them into arrays. This works but, it's very slow on the image maps i have been using. To fill you in, each image map has about 100 regions, each region averages 60 coordinate points, each coodinate point has up to 3 digits, plus the commas i end up parsing 20,000 - 30,000 characters to make my arrays.
This takes far too much time & i want to be able to do this a simple way through xml and arrays without amending the original xml code. Can anyone point me in the right direction?
thanks
Xml Data Not Available After OnLoad
I am loading an XML file into a movieclip. The problem I am having is that the data is not immediately available after the onLoad function has completed. If I do a trace within the onLoad function, I can see my data just fine, but once I am out of the onLoad function, the data is not there. Here is sample code to illustrate:
pic_array = new array();
pic_xml = new XML();
pic_xml.parentObj = this;
pic_xml.ignoreWhite = true;
pic_xml.onLoad = function(success){
if(success){
root = pic_xml.firstChild;
for(var i = 0; i < root.childNodes.length; i++)
{
with(root.childNodes[i]){
this.parentObj.pic_array.push(new PicData(attributes.image,
attributes.bodycode,
attributes.description,
attributes.price,
attributes.count));
}
}
trace(this.parentObj.pic_array[0].image);
}
else
trace("Error opening xml file");
}
pic_xml.load("picdata.xml");
trace(pic_array[0].image);
XML Object In AS2 Disappears After OnLoad
I am trying to load an XML document in AS2, but after the onLoad event fires, it seems that xmlData is undefined, even though bSuccess == true. Any ideas?
ActionScript Code:
import vidRom.ErrorHandler;
class vidRom.DataLoader
{
private var xmlData:XML;
function DataLoader()
{
xmlData = new XML();
}
public function loadData()
{
xmlData.ignoreWhite = true;
xmlData.onLoad = function(bSuccess:Boolean)
{
try
{
if (bSuccess)
{
//XML object is 'undefined' at this point...why?
if (xmlData.status == 0)
{
}
else
{
switch (xmlData.status)
{
case -2:
throw new Error("A CDATA section was not properly terminated.");
break;
case -3:
throw new Error("The XML declaration was not properly terminated.");
break;
case -4:
throw new Error("The DOCTYPE declaration was not properly terminated.");
break;
case -5:
throw new Error("A comment was not properly terminated.");
break;
case -6:
throw new Error("An XML element was malformed.");
break;
case -7:
throw new Error("Out of memory.");
break;
case -8:
throw new Error("An attribute value was not properly terminated.");
break;
case -9:
throw new Error("A start-tag was not matched with an end-tag.");
break;
case -10:
throw new Error("An end-tag was encountered without a matching start-tag.");
break;
default:
throw new Error("An unknown error has occurred.");
break;
}
}
}
else
{
throw new Error("XML document not found.");
}
}
catch(ex:Error)
{
ErrorHandler.displayError(ex.message);
}
}
xmlData.load("vidrom.xml");
}
}
Can You Use OnLoad With Object Instances?
Is this possible with a custom made object?
myObject = new Object();
myObject.onLoad = someFunction;
where someFunction is defined as a prototype of the Object?
object.prototype.someFunction = function() {
do something;
}
Please assume that I am totally new to objects, classes, and prototypes because I am.
Can You Use OnLoad With Object Instances?
Is this possible with a custom made object?
myObject = new Object();
myObject.onLoad = someFunction;
where someFunction is defined as a prototype of the Object?
object.prototype.someFunction = function() {
do something;
}
Please assume that I am totally new to objects, classes, and prototypes because I am.
[F8] Passing In Object To OnLoad, Loading XML
I have a simple XML document that is laoded using the onLoad function, which then parses the XML when its loaded and dumps it into a combo box.
I have several XML documents that all load into Several Combo boxes, but each ComboBox needs a seperate function, when really, the only thing that changes is the comboBox name taht it loads into.
Is it possible (if it is, i haven't figured it out yet) to pass in a varible with the "onload" function?
It is setup like so..
PHP Code:
XMLFile = new XML();
XMLFile.ignoreWhite = true;
XMLFile.onLoad = roof;
XMLFile.load("xmlfilename.xml");
function roof(success)
{
// parse file...
}
I've tried things such as,...
PHP Code:
XMLFile = new XML();
XMLFile.ignoreWhite = true;
XMLFile.onLoad = roof("test");
XMLFile.load("xmlfilename.xml");
function roof(success,var)
{
trace(var); // hoping for "test"
// parse file...
}
But it doesn't work
Any advice would be greatly apprecaited
XML Object OnLoad Scope Problem
Hi All,
I've got a very frustrating scope issue here, probably quite simple, but it's got me stumped.
I have a class which loads up some XML into an XML object, on loading the XML I want to fire a function in the class.
I'm obviously doing something wrong because processXML is not happening. I have tried calling _root.instance.processXML(this) in the onLoad function, and that works, but I can't use _root because I don't necessarily know where this is going to be used.
Any thoughts?
Many thanks
Kevin
My code:
Attach Code
class classes.availability extends MovieClip {
var my_xml:XML;
var feedURL:String;
private function init(){
trace("Initialising office availability");
feedURL = "http://addressofmyxmlhere.xml";
my_xml = new XML();
my_xml.onLoad = function(success){
trace("loaded XML");
processXML(this);
};
my_xml.ignoreWhite = true;
my_xml.load(feedURL);
}
public function processXML(xml){
trace("processing XML");
}
}
XML Object OnLoad Scope Problem
Hi All,
I've got a very frustrating scope issue here, probably quite simple, but it's got me stumped.
I have a class which loads up some XML into an XML object, on loading the XML I want to fire a function in the class. Here is my code:
Code:
class classes.availability extends MovieClip {
var my_xml:XML;
var feedURL:String;
private function init(){
trace("Initialising office availability");
feedURL = "http://addressofmyxmlhere.xml";
my_xml = new XML();
my_xml.onLoad = function(success){
trace("loaded XML");
processXML(this);
};
my_xml.ignoreWhite = true;
my_xml.load(feedURL);
}
public function processXML(xml){
trace("processing XML");
}
}
I'm obviously doing something wrong because processXML is not happening. I have tried calling _root.instance.processXML(this) in the onLoad function, and that works, but I can't use _root because I don't necessarily know where this is going to be used.
Any thoughts?
Many thanks
Kevin
Sound Object's OnLoad Do Not Work Locally
Straight to the point: I have a strange problem with Sound object's onLoad event handler behaviour. I use such a code:
Code:
var bgSound:Sound = new Sound(bgSoundControllerMc);
bgSound.loadSound("sounds/background.mp3", false);
bgSound.onLoad = function(ok){
if(ok){
this.start(0, 999);
}
}
Then I tes it in authoring enviroment. It works. But when I run compiled .swf in the same directory I do not hear any sound and a text indicating that sound loading is completed do not appear... Seems like onLoad is not triggered at all.
If I use streaming sound loading it works with .swf file also, but streaming sound can't be looped this way.
And one more note: it doesn't matter what kind of sound loading is used, when I try to test it on server it works as it has to.
Does anybody have any ideas? Thanks a lot.
Sound Object Inside Class Onload...plz Help
i'm attempting to use a class to store a sound object. when i call the init function of the class i want the sound object to load a file and set the sound_loaded property of the class to true. i can't seem to access the sound_loaded property of the class inside the onLoad event of the sound object. i've tried this.sound_loaded and this._parent.sound_loaded but neither works. any help would be greatly appreciated.
i'm using flash 8 pro
Code:
BeatBar.prototype.init = function (new_id, new_sound_location, new_num_beats) {
this.current_beat = 0;
this.is_cut = false;
this.is_muted = false;
this.id = new_id;
this.sound_loaded = false;
this.sound_location = new_sound_location;
this.sound = new Sound ();
// notify beatbar when sound has loaded
this.sound.onLoad = function (success:Boolean) {
if (success) {
trace (this.sound_loaded);
this.sound_loaded = true;
// also tried this._parent.sound_loaded = true;
} else {
// could not load requested sound
}
};
this.sound.loadSound (this.sound_location, false);
};
i know that the sound succeeds in loaded because the trace output appears. but for some reason the sound_loaded always appears as undefined even though i define it as false at the beginning of the init function.
Xml OnLoad And Scope Delegating And Maybe Proxy Destroys The Xml Object
realy want to avoid using root but cant get to the parent. I cant get jessies proxy to work propery, cant even import it for some reason. Here is the code, this isnt easy, delegate destroys the xml and maybe proxy does as well.
Code:
var xmlOUT:XML = new XML("<root><node1></node1></root>");
var xmlRTN:XML = new XML();
xmlRTN.ignoreWhite = true;
//------------------------------------------------------------------------------
//xmlRTN.onLoad = Proxy.create(this, assignText, "arg1", "arg2");
xmlRTN.onLoad = myOnLoad;
//xmlRTN.onLoad = Delegate.create(this, myOnLoad);
//------------------------------------------------------------------------------
xmlOUT.sendAndLoad(this.path, xmlRTN);
//xmlOUT.sendAndLoad = Delegate.create(this, myOnLoad); //this breaks the xml-not good!!!!
function myOnLoad(success:Boolean) {
var xmlpath = "/abc/xyz";
var someXML = mx.xpath.XPathAPI.selectNodeList(this.firstChild, xmlpath);
if (success) {
if (String(someXML[0].firstChild.attributes.success) == "1") {
//assume this is the case
_root.errorBox.errorMessage.text = "GOOD LOGIN SPORT !";
//dont want to use _root here but have to
}
}
}
Help With Interpreting Some AS1.0 Codes
I want to use some of these AS1.0 codes for my game. But I dont really understand AS1.0. I would really appreciate it if somebody could help me convert them to AS2.0 or just explain how they work. Thanks in advance.
Code:
n = 1;
text = "Hello there.";
//----------------------------------------------
//clear out old text (NOTE: the first time you do this, there isn't any text to clear out! I just keep the code here because it doesn't do any harm.)
//----------------------------------------------
c = 1;
while (Number(c)<=100) {
removeMovieClip("../font" add c);
c = Number(c)+1;
}
Code:
length = length(text);
if (Number(n)<=Number(length)) {
//----------------------------------------------
//move cursor
//----------------------------------------------
setProperty("", _x, Number(fontx)+Number((fontwidth*(n))));
}
Code:
if (Number(n)<=Number(length)) {
//----------------------------------------------
//type new character
//----------------------------------------------
duplicateMovieClip("../original", "font" add n, n);
set("../font" add n add ":text", substring(text, n, 1));
setProperty("../font" add n, _x, Number(fontx)+Number((fontwidth*(n-1))));
setProperty("../font" add n, _x, getProperty("../cursor", _x)-fontwidth);
setProperty("../font" add n, _y, getProperty("../cursor", _y));
n = Number(n)+1;
gotoAndPlay(_currentframe-1);
}
You can download the fla file here
Interpreting String Inputs
Hello all, I'm new here, Slowly getting comfortable with Flash and actionscript. I'm creating an Air Traffic Control simulation and need to create a user-input text field.
Each aircraft is a duplicateMovieClip, with a randomly assigned 3-digit flight number. The basic commands will be altitude, heading and speed. I envision an input text field that would accept a string from the user, such as 516M310 meaning "flight 516, maintain flight level 310". Is there some actionscript that will decipher the input correctly?
I'd like each aircraft movieclip to be checking for user input, and compare the first three characters to it's flight number. If the input is directed at that aircraft, only that aircraft will respond to the instruction following the flight number.
Any ideas here would be greatly appreciated. One more thing, how can I make text inputs automatically appear capitalized (i think lowercase inputs would appear harder to read.
Ken
Interpreting Font Incorrectly
Last edited by sensored : 2006-06-23 at 15:14.
I could really use some help with this font problem. The site below has already launched, so I need to fix this bug asap, and I haven't seen this discussed ANYWHERE.
http://www.objexdesign.com/
Wait for the intro movie... when the captions for the playground equipment load, notice the letter 'R' in PORTFOLIO, Flash is making the 'R' solid instead of showing its 'eye'. This is also happening in the main navigation menu on each of the pages.
It is only doing it for this one letter. Looks fine in design view. Only does this following publishing. Publish settings are at 100. Have tried resizing and italicizing the font to no avail.
Any suggestions? Thanks.
Interpreting Java Or HTML In A Text Box
Is there anyway to have a dynamic text box display HTML or Java if and when it passes through the dynamic text box. If not could someone please tell me how to write a actionscript that would look everytime information passes through and if it contains HTML or Java open a new pop-up HTML window to interpret it.
I would prefer to be able to display HTML and Java in my text box if its possible. Any help or ideas would be greatly appreciated.
Thank You
MikeMadMan
Ideas For Interpreting Loaded Variables
hello everyone, i am making a flash quiz game that loads questions and answers from an external .txt file and i was wondering how can I interpret with as something like this (i use the split function to make an array from the file):
//pseudo txt file:
domestic animal?
canine
another one?
cat
//
instead of the usual:
//pseudo txt file:
domestic animal?:canine.another one?:cat
to make things more readable
Interpreting String As Function Name ActionScript 3.0
Hi
I want to know if there is any way a string can be interpreted as function name.I need this to call functions dynamically.Below is a code snippet which works fine if the function is in the same class as the function call.But what if i want to call a function present in another class or a different library.Any suggestions will be appreciated.
public var actionRef:String = "getit"
public function initApp():void
{
button.label="Click"
canvas.addChild(button);
button.addEventListener(MouseEvent.CLICK,callMe);
}
public function callMe(event:MouseEvent):void
{
//if (this.hasOwnProperty(actionRef))
this[actionRef]();
}
public function getit():void
{
trace("inside getit")
}
Cheers
mfsiddiq
Ideas For Interpreting Loaded Variables
hello everyone, i am making a flash quiz game that loads questions and answers from an external .txt file and i was wondering how can I interpret with as something like this (i use the split function to make an array from the file):
//pseudo txt file:
domestic animal?
canine
another one?
cat
//
instead of the usual:
//pseudo txt file:
domestic animal?:canine.another one?:cat
to make things more readable
"In(Object){...}" Function? Data Types For Object Variables?
I can create an object and use dot syntax to create, or reference, variables inside of it.
But how can I specify the data types of these variables?
Also, is there some way I can enter the namespace of the object over a number of lines via {}s instead of using repetitive dot syntax?
Thanks in advance.
Please Help Getting Data Out Of XML Object?
Hi,
I am very new to XML. Below is where I'm up to. I am struggling to trace out the data like. Can someone help me with my paths to the various parts? I'm not sure if it is due to Flash code or the XML structure that is causing the problem.
Many thanks
Ol
__________________________________________________
__________________
I have uploade the XML here:
http://www.araj21.dsl.pipex.com/dealers_RO.xml
__________________________________________________
__________________
// FLASH CODE
dealers_xml = new XML();
dealers_xml.onLoad = startMovie;
dealers_xml.load("dealers_RO.xml");
dealers_xml.ignoreWhite = true;
//
// Show the first slide and intialize variables
function startMovie(success) {
if (success == true) {
//trace(dealers_xml.firstChild.firstChild.firstChild );
//trace(dealers_xml.firstChild.firstChild)
trace(dealers_xml.firstChild.firstChild.firstChild )
}
}
Data From Shared Object - Using Elsewhere
Hi all,
I have a dynamic text field on the stage which loads the data from my shared object (a word). This works great but I'd like to get my movie to jump to a certain label depending on what that word is. For example if the shared obeject puts "Jump" into the dynamic text field I'd like the movie to jump to the label "Jump".
I have tried a number of ways to do this including using an "if" statement etc, but can'tget it to work.
Do I need to convert my data (which is a string) into a variable or something before I can make the jump or is there a easier way.
__________________
Thanks in advance
Sambora
Remove Data Object :s
if
Code:
var user = SharedObject.getLocal([_global.rqstid]);
//update!
user.data.y = user.data.y+3;
user.data.x = user.data.x+6;
user.flush();
comment est-ce que vous faisez le enlevez?
Object Data Type
I ve created a variable that contains an array. Each array element is a generic object that further contains an array n that array again contains a generic object whith .x and .y properties.. Now i wanted this to pass to the asp. the problem is that i cant extract the .x and .y values frm the variable passed in asp.. Please tell me what to do so that i can get the values ....thnx in advance
AS2 Unload XML Data From Object
Finally remembered my password for this wonderful forum to bother you with yet another (stupid) question...my 2nd already, lets hope it works...
AS2 XMLObject1 loads 15 pics. XMLDriven menu button (XMLObject2) triggers loading of new XML (10 pics) in XMLObject1. Works fine but last 5 pics stay in XML Object. In other words: I need to unload all the previous XML data on an onRelease event. Tried (thanks to this Forum) new XMLObject, delete (Old) XMLObject (Did not work...). There is no unload XML Method so what to use?
Thanks! Please let me know if you need more info..(which you probably do)
Flushing XML Data From Object
Actionscript 2.0 in Flash CS3
I downloaded a simple xml based photo gallery, but I want to categorize the content. Basically the data gets pushed into the object, and when i click a new category button I want it to begin showing the photos only in that category (which is a separate XML file).
The problem I am having is that when i click a new category it doesn't replace the XML data of the object, it appends to it. So it continues to show the original category and then shows the new category after it gets done and then eventually goes back to the original. For example, it starts playing CatOne01.jpg from CatOne.xml, CatOne02, 03 - 10... etc... at the end it goes back to CatOne01
If you click on category 2, it loads CatTwo.xml (I watched it all load up in firebug)and it finishes playing through CatOne CatOne10.jpg and then plays CatTwo01.jpg-CatTwo10.jpg and goes back to CatOne01. I need to find a way to clear out the data before it pushes the new data from the new XML file. I tried flush (as shown below) and nothing changes, i tried delete XML, and that just makes it go blank onclick. All I need is for the values from the first xml to be flushed out before the new values are pushed in each time the user clicks the category buttons, and the new category's images immediately begin playing.
Any suggestions?
Code:
on (release) {
gotoAndStop(1);
_root.techtype.flush();
_root.caps.flush();
_root.photos.flush();
var feed:XML = new XML();
feed.ignoreWhite = true;
feed.onLoad = function(){
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
_root.techtype.push(nodes[i].attributes.id);
_root.caps.push(nodes[i].attributes.desc);
_root.photos.push(nodes[i].attributes.url);
}
_root.mcl.loadClip(photos[0], _root.gallery.photo);
_root.textBar.t.text = caps[0];
_root.buttons.gotoAndStop(techtype[0]);
}
feed.load("images/CatOne.xml");
}
and
Code:
var photos:Array = new Array();
var caps:Array = new Array();
var techtype:Array = new Array();
var current:Number = 0;
this.createEmptyMovieClip("gallery", -99999);
this.gallery.createEmptyMovieClip("bmdc", 1);
this.gallery.createEmptyMovieClip("photo", 2);
var bmd:BitmapData = new BitmapData(500, 375,true,0x000000);
this.gallery.bmdc.createEmptyMovieClip("preload", 1);
this.gallery.bmdc.attachBitmap(bmd, 2);
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = Delegate.create(this, tranny);
mcl.addListener(mclL);
function loadPhoto():Void
{
trace("loading photo...");
bmd.draw(this.gallery.photo);
this.gallery.photo._alpha = 0;
if(current == photos.length-1) current = 0;
else current++;
textbar._rotation = rr;
textBar.t.text = caps[current];
mcl.loadClip(photos[current], this.gallery.photo);
_root.buttons.gotoAndStop(techtype[current]);
}
function preload():Void
{
if(current == photos.length-1) var num = 0;
else var num = current+1;
this.gallery.bmdc.preload.loadMovie(photos[num]);
}
function tranny():Void
{
trace("starting transition...");
var f:Fuse = new Fuse();
f.push([{target:this.gallery.photo, alpha:100, time:4},
{target:textBar, delay:0.5, start_x:-518, x:cx, time:0.5, ease:"easeOutExpo"},
{target:textBar.arrow, x:ca, time:0.5, ease:"easeOutQuad", delay:0.5}]);
f.push({func:preload, scope:this});
f.push({target:textBar,delay:5, x:-518, time:1, ease:"easeOutExpo", func:loadPhoto, scope:this});
f.start();
}
function cx():Number
{
var te:Number = textBar.t.textWidth;
var nx:Number = -518 + te + 60;
return nx;
}
function ca():Number
{
return textBar.t._x - cx()+27;
}
function rr():Number
{
if(Math.random() < 0.5) return Math.round(Math.random()*15);
else return Math.round(-Math.random()*15);
}
Data Tree Object
Is there any way to access the data in a data tree Object without knowing the names of the "branches"? or how many there are?
Displaying A3D Object With Its Z Data In CS4
Greetings all,
I have a problem, i set Z properties for a display object, but its ChildIndex wouldn't display based on its Z in Scene3D in Papervision3D. and if 2 display objects are over each other, only that object stands over the other one which its ChildIndex is higher not its Z. How can i solve this problem in CS4?
Thanks
Sending Object Data Through LocalConnection
has anybody had any dealings with sending objects through localConnection? i can't seen to manage it. does it only send no complex data such as strings, arrays, booleans and number values?
Shared Object, Parsing Data, XML
Hello,
Someone mentioned I should look into shared objects since I want to have data stored locally through a flash interface. I found one example and got it working. Now I want to take the next step.
1) Are there any useful Shared Object methods I should be aware of?
Is it possible to put a list of values within 1 variable and then have Flash parse these values into designated sub variables? For example, I am trying to find a way to organize names of stations. Let's use band names instead. The main variable could be "B", for bands starting with the letter B. If someone adds "Beatles", and then "Beach Boys", I would like to have those two in the B variable, but I also want to assign them to their own variable, B1 and B2. Furthermore, is it possible to alphabetize so that "Beach Boys" is assigned to B1, not B2, even if it is added second?
2) If possible, how can I best parse data?
This now leads me to XML. I hear a lot mentioned about it, but so far a regular .txt file and now .sol file is sufficient enough now to add and read data.
3) What advantages would there be to integrate XML into what I have mentioned above, and do you think it is worth it?
Looping Through Shared Object Data
Hello,
I'm trying to build an abstract shared object read function and I'm trying to treat the shared_object.data object as a regular array but it doesn't respond as such.
Here's what I'd like to see happen or something similar:
var shared_object = SharedObject.getLocal("user_data");
//--- read the contents of the shared object ----
for( var i:Number = 0; i < shared_object.length; i++ )
{
trace( shared_object[i] );
}
//-----------------------------------------------------
Thanks for your help,
Clem C
Shared Object Data Available For Others Swf In The Same Page?
Hello people,
sorry about the nooby question, but i wantted to know:
are flash cookies with a shared object available for others swf (not the original one who created it) liying on the same page?
if its posible, how can i retrive the data i stored from another flash?
thanks a lot.
Is Anybody Familiar With The BitmapData Data Object?
The maximum width and maximum height of a BitmapData object is 2880 pixels.
does anybody know if there is a way to increase this?
Can't properties to some built in classes be changed with the .prototype function or something?
AS2: Accessing A Shared Object's Data
I'm trying access the data in a shared object by using the following code. Unfortunately, it keeps giving me "undefined." TempSavedData() runs when the swf loads to set the data (which is really just a placeholder at this point).
PHP Code:
TempSavedData = function() {
savedata = SharedObject.getLocal("SavedData");
savedata.data.SavedData1 = "Hello World";
}
MyButton = function(xpos, ypos, layer, num) {
this.clip = attachMovie("MyButton_Load", "SavedData" + num, layer, {_x:xpos, _y:ypos});
this.clip.onPress = function() {
var t = this._name;
var dump = savedata.data.t;
trace(dump);
}
}
Appending Object Data To A Dataprovider
Hi all,
I'm a little stuck on adding items to a dataprovider for use in a TileList component.
What I want to know is how do I iterate through and add two different sets of data (ie one array of data for [source] and another for [label]) to the dataprovider? at the moment when I add them separately (using addItemAt()), i end up with double the amount of objects.
I'm doing this at the moment:
Code:
//iteration
_data.addItemAt({label:imageToAdd}, imageIndex);
_data.addItemAt({source:sourceToAdd}, sourceIndex);
//end iteration
and it's "not working" how I need it to: in this example, instead of having one item in the dataProvider, I now have two disconnected items.
Hope someone can shed some light on this subject, I'm struggling for inspiration at the moment...
Dan
Problem Storing Xml Data In Object
Hi there
i am trying to make a new section with news titles and news briefs and when you click on a title the full content is displayed. I have manged to read in the data from xml but am having great difficulty in storing the data in a n object not to mention the fact that the last record it the only onle that seems to be displayed on the screen. Am so disillusioned at the point and not sure how am gonna get myself outta this mess. Any help at all woul dbe great. Have attached a zip below.
Looping Through Shared Object Data
Hello,
I'm trying to build an abstract shared object read function and I'm trying to treat the shared_object.data object as a regular array but it doesn't respond as such.
Here's what I'd like to see happen or something similar:
var shared_object = SharedObject.getLocal("user_data");
//--- read the contents of the shared object ----
for( var i:Number = 0; i < shared_object.length; i++ )
{
trace( shared_object[i] );
}
//-----------------------------------------------------
Thanks for your help,
Clem C
Declare Data Types Within An Object?
Hi all. I am creating an object like this:
Code:
var myObject:Object = new Object();
When I add new properties to the object, some will be numbers and others strings.
Is this syntax correct, or do I need to declare the data type for each property?
Code:
myObject.userName = "Joe Smith";
myObject.passed = "yes";
myObject.previousUser = "no";
myObject.programScore = 78;
myObject.screenName = "0301";
Didn't know if I should declare string, boolean and numeric data types within an object or not.
Thank you.
MaryAnne
Loop To Add Data To Shared Object
Hi,
I'm working with a shared object, and I'm having trouble dynamically adding to it. I want to create a data variable for each list of names (ex: nameLists_so.data.list1, nameLists_so.data.list2, etc.), but do it through a loop.
Here's the code I tried, but didn't work....
ActionScript Code:
nameLists_so = SharedObject.getLocal("listOfNames");
for (i = 0; i < allLists.length; i++) {
nameLists_so.data.list[i] = allLists[i].names
trace (nameLists_so.data[i]);
}
allLists refers to an array with the names of the lists (ex: list1, list2, list3).
names refers to the array within each list, that has the actual names.
Any help would be great, thanks!
Share Object Data Is An Array
i have an array
that is
array[0]
[object]
product_description
product_id
product_version
array[1]
product_description
product_id
product_version
i can access them by array[0].product_description
my problem is i store my array to a shared object
var so:SharedObject;
so.data.product = array;
how do i access the product_description from the shared object;
Shared Object Data Usage
I am using the shared object to store data from one swf on a cd to hold it for the next one and so on to a total of 4 files on separate cds. It seems to be keeping the data as needed, but I also want the user to be able to print out the data at the end of the 4th file. I have set up the print function, but it is only capturing the data that was created in the 4th swf. How do I use the data from the shared object to enable printing those variables as well?
Strict Data Typing Within An Object
Hey. So - You've created an object. Now you want to have a property of the object - and you want that property to have strict data typing because you're picky. Here's the code you've written.
var oTest:Object = new Object();
oTest.nThing = new Number();
oTest.nThing = 1;
trace(oTest.nThing); // output = 1
oTest.nThing = "word";
trace(oTest.nThing); // output = word
And there you run into a problem. You want the output of the second trace statement to be NaN / undefined. The variable within the object is not strictly typed. How do you fix this silly mistake you've made??
:-p
thanks!!
Using Data From Combobox As A Property Of Object
Hello guys,
I have a combobox:
ActionScript Code:
search_cb.addItem({data:date, label:"Date"});search_cb.addItem({data:name, label:"Name"});search_cb.addItem({data:measures, label:"Measures"});var searchcbListener:Object = new Object();searchcbListener.change = function(evt_obj:Object) { var item_obj:Object = search_cb.selectedItem; var i:String; for (i in item_obj) { _root.searchin = item_obj[i].data; //this is not good }}search_cb.addEventListener("change", searchcbListener);
Now I have some objects like (all attributes are strings):
myObj1.date = ...
myObj1.name =...
my Obj1.measures =...
myObj2.date = ... and so on.
Now I have a function, which I would like to use for searching in the properties of objects. The user should type the request into input field, choose the property from dropdown and press "go". Just that I can't pass the data from dropdown to the search function. Any ideas?
This is the search function:
ActionScript Code:
function search(string:String, where):Void{ for (var i=0; i<objectArray.length; i++){ trace("in for"+i); if (objectArray[i].measures.indexOf(string) > -1) trace(objectArray[i].measures+" - "+objectArray[i].name); }}
just that now the property set is "measures", I need to change this dynamically (name, measures, date).
Thanks for advices!
Poco
PS: _root.searchin should be the variable in root holding "where to search".
Pull Data From LoadVars Object
This is my first post so let me begin by greeting you all
Hi all!
My question is:
How can I access all loadVars data returned back from a server?
After sending some bogus data I can see in the debug variable window:
Variable _level0.myVars = [object #230, class 'LoadVars'] {
nick:undefined,
pds:"request.forms",
password:undefined,
onLoad:[function 'onLoad'],
<html> <head> <title>Form2pds result</title> <basefont face:""Arial"> </head> <body><h1>Request stored</h1> <hr> <p>The request has been successfully stored as <b>RQ000022</b>. <p><hr></body></html>"
}
What I want to achieve is to access the part after "onLoad:[function 'onLoad'],"
So I would like everything between the <html> and </html> tags
Is this possible?
Removing Data From A Shared Object
Does anyone know if it's possible to remove an array property and its values from a Shared Object?
For example, if the SO contains the following:
elemArray_1: 56-02-136,136Ba,Barium,93.0
elemArray_2: 18-03-40,40Ar,Argon,>99.999
elemArray_3: 51-02-123,123Sb,Antimony,98.2
How can I delete "elemArray_2" entirely? - Rather than just set the individual values to undefined? (I would then refresh the display by reading the updated cookie props)
Loading Data From Shared Object-Doh
Hi guys,
I'm trying (and failing) to save and reload data from a shared object. I can create the object and save data to it so long as I keep the file open. My problem is accessing the data again when I re-open the program. I created the shared object using:
var DataStore:SharedObject = SharedObject.getLocal("DataStore");
write an array to its data property using:
DataStore.data.PlayerStore=PlayerStore//saves my array
and use DataStore.flush(); to save data persistently.
My problem comes in reloading the data. I guess I don't want to do:
var DataStore:SharedObject = SharedObject.getLocal("DataStore"); again
because that would overwrite the original data ,so I check to see if DataStore still exists and holds data by making the creation of the shared object conditional upon its prior existence:
if(DataStore.data.PlayerStore==undefined) {
var DataStore:SharedObject = SharedObject.getLocal("DataStore");
}
else{
PlayerStore=DataStore.data.PlayerStore;
}
This fails to load any data. Any ideas out there? I've checked out all the tutorials and they are a little vague on how to load data once you've closed the program down. This has stopped me in my tracks for a week and its doing my head in!
Associative Array Vs Data Object
Lately I have been getting into associative arrays and quickly found out that there doesn't seem to be a way to loop through one, for example:
ActionScript Code:
var myArray:Array = new Array();myArray['constructor_stage'] = new Array(0xFFFF00,100,200,"Level1");myArray['engineering_stage'] = new Array(0xFF0000,440,550,"Level3");
normaly you would do something like this, of course it doesn't work:
ActionScript Code:
for(var i:int = 0; i < myArray.length; i++){}
I went to live docs and they said to use the object class, so is there a way to loop through an object data properties:
ActionScript Code:
var dataObject:Object = {player1:{userName:"theUserName",password:"thePassword"},player2:{"theUserName",password:"thePassword"}}
|