Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-06-2003, 05:12 PM   #1
Jessica lucidiastudios
Registered User
 
Join Date: May 2001
Location: Ontario, Canada
Posts: 211
Default test for string split into an array = done?

HI,

I'm having major issues with a movie I'm doing that relies 100% on loaded data for it's menu generation, display, interface layout, etc. There's a ton going on. Basically, all of my data comes from various php files. This data is called using LoadVars() and I test for "success" to ensure the string has loaded from the php file. Once it has, I split it into an array.

MY QUESTION IS:
I heard it takes awhile for Flash to split an array. So, even though my string has fully loaded (LoadVars success), is it possible for the array to still be splitting when I call an item in the brand new array?

I'm wondering this because about 2% of the time, calling an item in the array will fail, but doing textfield.text outputs to the screen proves to me that the string has loaded. So if it has loaded, but I still can't get the data (very occassionally), could it be it's still splitting?

A SOLUTION:
How can I test to make sure the split function has finished? I did a test to make sure array.length != "". I'm not sure if that is a good enough test though, to make sure I can get any of the data in that array when I ask for it.

I can't seem to find any information about this in searches besides "Splitting takes awhile, beware.".

Thanks very much!
I appreciate any expert opinions!
*It's been a frustrating past 3 days trying to troubleshoot why my calls fail 2% of the time! Grrr!!*

Jessica
Jessica lucidiastudios is offline   Reply With Quote
Old 03-06-2003, 05:40 PM   #2
isdito
Registered User
 
Join Date: Mar 2003
Posts: 12
Default HELP

I think that this is good for you, perdon because my bad english
Attached Files
File Type: zip kk.zip (7.9 KB, 287 views)
isdito is offline   Reply With Quote
Old 03-07-2003, 12:35 AM   #3
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

Just out of curiosity... How big is your input data??? That's the only reason why you are having problem... Big data takes big time to split within the for loop, I believe???

I am not quite sure if I remember correctly, but according to the ASDG, you should use frame loop rather than the for loop if you see the abnormal loop behavior... (Don't ask me to flip through ASDG... ASDG doesn't contain 'Search' capability... )

I'd love to know how big your input data is and how frame loop takes care of the problem...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 03-07-2003, 01:13 AM   #4
Jessica lucidiastudios
Registered User
 
Join Date: May 2001
Location: Ontario, Canada
Posts: 211
Default

Hi, thank you both for your replies.

Thank you for posting the file Isdito. I have looked over it but so far, I haven't been able to find a solution to the array problem I'm having.

CyanBlue, you've replied to my threads before! Thanks again. I was worried about the data being rather large. Right now, one array I know of is 80 items (array.length I mean). That could be double the size or triple once all the content is inputted to the site.

So I am right that it does take a long time to split a string of that size then... the tip about asdg is good. I always fall back on frame loops but in this example, it would be preferable to let LoadVars do it. If I take the code outside of the loop, it doesn't work for some reason (a whole other issue).

So here's the code in a nutshell:
I have a base movie, level0 into which I load all data, create the arrays, and load secondary movies into. As each secondary movie loads, it calls for new data to re-create the array sitting in level0.

Here's the code from the secondary movie:
ActionScript Code:
_level0.oTheDots = new loadVars(); _level0.oTheDots.load("http://domain.com/script.php?CityID="+_level0.mapID); _level0.oTheDots.onLoad = function(success) {     if (success) {         _level0.theDotsArray = this.itemNumArray.split("|");                 if (_level0.theDotsArray.length != "") {                                                 // [0] = how many "dots" there are to be plotted             for (var i = 1; i<=_level0.theDotsArray[0]; i++) { // plots dots into a _level0.maptarget movieclip by attaching dot movieclip                 thedotpointer = _level0.maptarget.mapzoom.mappan.ptsofinterest["mc"+_level0.theDotsArray[(6*i)-4]].attachMovie("dot_pt_"+_level0.theDotsArray[(6*i)-4], "dotpt"+i, i);                 thedotpointer._x = _level0.theDotsArray[(6*i)-3];                                 thedotpointer._y = _level0.theDotsArray[(6*i)-2];                                 if (_level0.theDotsArray[(6*i)-1] == "Large") {                 // simply resizes size depending on array specifications                     thedotpointer._xscale = 200;                     thedotpointer._yscale = 200;                 } else if (_level0.theDotsArray[(6*i)-1] == "Medium") {                     thedotpointer._xscale = 150;                     thedotpointer._yscale = 150;                 }             }         }     } else {                                 // tell user it's still loading, and re-loop to check success         preloader.perc = "loading data";     } }

I suppose that is too soon in the loop to call the array items? Unfortunately, I need to very closely track "i" to make this work.

I did the test for array length in there to make sure it was not empty (hoping that would mean it was done splitting). I don't think that's enough to make me comfortable that it really is done though.

Thanks for having a peek at this. Basically, the code pulls in a long string into a single dimensional array. It provides coordinates to plot dots onto the movie along with thier info. I'm just concerned that an array with 80 or 280 items will not split fast enough, so I was hoping there was a way to test for it's finishing the split function.

I'm hoping to avoid a frame loop here, I tried and failed already for whatever unknown reason!

Thanks a lot! I appreciate the feedback.
Jessica
Jessica lucidiastudios is offline   Reply With Quote
Old 03-07-2003, 04:53 AM   #5
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Hm... I think your code is some sort of dynamic map stuff by any chance??? I was going to pull the dynamic data and place the icon in the given location on the map in my next project and it looks fairly similar...

I don't think your condition in if statement is really catching the end of the split() function...
ActionScript Code:
if (_level0.theDotsArray.length != "")
Maybe you can modify the PHP code so that it could send you the exact number of items along with other data and use that to check if the split() function has finished???
ActionScript Code:
if (_level0.theDotsArray.length == Number(_level0.oTheDots.totalData))
something like this???

Or...

I don't know why you cannot access this _level0.theDotsArray array outside of the onLoad handler... I think you should be able to reference that array maybe next frame... and have it run the frame loop???

Sounds like I didn't help you much this time either...

If you could have your PHP code save the data to the text file and show me how it looks like, then I could try your code on my machine... Or simple sample would be great too...

Let me know...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 03-07-2003, 12:34 PM   #6
Jessica lucidiastudios
Registered User
 
Join Date: May 2001
Location: Ontario, Canada
Posts: 211
Default

good morning

Thank you for the reply. Those are both good suggestions I am going to try out today. I have big pressure on me by the bosses to have this done yesterday, so that's probably more my problem than my code!

I appreciate your looking over it and giving ideas. I'll let you know later this morning how they worked out for me and if they don't, I will send you some files. Thanks for the help!

Jessica
Jessica lucidiastudios is offline   Reply With Quote
Old 03-07-2003, 05:44 PM   #7
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Sure... I hope you figured it out already though...
PM me if you want to send me some files... I'll give you my email address where you can send them to...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 03-07-2003, 06:08 PM   #8
Jessica lucidiastudios
Registered User
 
Join Date: May 2001
Location: Ontario, Canada
Posts: 211
Default

Hi again,

Thanks for offering to look at the files. I *MAY* not have to bother because I *MAY* have fixed it with your help.

I'm still testing it, but when you test and test and you start getting bored because nothing abnormal happens, that's a good sign!

Here's the code for those files. I guess it's a combination:

// myLength at the end of the PHP data gives the length of the array.

Code from secondary (file to be loaded) file, to load the data holding dot coordinates and their info:
ActionScript Code:
_level0.oTheDots = new loadVars(); _level0.oTheDots.load("http://domain/file.php?CityID="+_level0.mapID); _level0.oTheDots.onLoad = function(success) {     if (success) {         _level0.theDotsArray = this.itemNumArray.split("|");     } else {         preloader.perc = "loading data";     } }


...on the next frame:

ActionScript Code:
// put dots onto map if (_level0.theDotsArray.length == Number(_level0.oTheDots.myLength)) {     for (var i = 1; i<=_level0.theDotsArray[0]; i++) {         thedotpointer = _level0.maptarget.mapzoom.mappan.ptsofinterest["mc"+_level0.theDotsArray[(6*i)-4]].attachMovie("dot_pt_"+_level0.theDotsArray[(6*i)-4], "dotpt"+i, i);         thedotpointer._x = _level0.theDotsArray[(6*i)-3];         thedotpointer._y = _level0.theDotsArray[(6*i)-2];         if (_level0.theDotsArray[(6*i)-1] == "Large") {             thedotpointer._xscale = 200;             thedotpointer._yscale = 200;         } else if (_level0.theDotsArray[(6*i)-1] == "Medium") {             thedotpointer._xscale = 150;             thedotpointer._yscale = 150;         }     }     gotoAndPlay(8)// 8, all tests are done, show the display }

...with a loopback on next frame sending it backward to re-test the array's length.


It's looking good. I owe you! I will PM you when it's done and show you the result.

Thanks a bunch, I will post again once it's all working good (or not working and I'm stuck again -- hopefully not the latter!).

Jessica
Jessica lucidiastudios is offline   Reply With Quote
Old 03-07-2003, 07:11 PM   #9
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Hm... You really are doing the map... Coincidence??? Hm...

Just by looking the code, it sure look right... You have no problem getting the value from _level0.oTheDots.myLength either, right???

Let me know how it goes and I'd love to see what the project is about...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-07-2003, 01:35 PM   #10
Jessica lucidiastudios
Registered User
 
Join Date: May 2001
Location: Ontario, Canada
Posts: 211
Default

CyanBlue, your mention of the maps in the other thread the other day reminded me I'd PMed you. I didn't get a message saying I had new messages so I never bothered to check my inbox. I went and checked today and found two you had sent ages ago! I'm so sorry, I apologise profusely.

Thanks for the critique on my project (www.newfoundland.com). It's down today, the database bombed or something. I have to check with the php guy. (<edit>Problem has been fixed...all's well again.</edit>) I read your suggestions and they're good to consider. I am going to see if I can get some time to work them in. I appreciate the comments. =)

I tried to reply, but your inbox is too full. It wouldn't go through.

Haha yes, I'm from Canada (eh). It's actually blistering hot here in the summer, but winters are nasty. I'm right on the MI border though, so it's not as bad as further north. I don't blame you for heading south, I think about it every winter! I will one of these days.

Well, I will make a point to check my PM box from now on and hopefully keep in touch. I appreciate the help you gave me and I'll do the same for you whenever possible. Let me know if I can help when you're doing your map project (or any), my email's in my profile.

Take care
Jessica

Last edited by Jessica lucidiastudios; 05-07-2003 at 05:13 PM.
Jessica lucidiastudios is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:00 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.