View Full Version : XML Actionscript CMS - 100% processor resource even after stop();
Perception
07-11-2005, 04:40 PM
Hi all,
I hope someone can help me, the attached files are part of a content management system via XML. The files are 2 XML files, one of which takes care of if the content has been updated via the CMS, the second is the list of files with their id and sub id, these are generated by the playlist manager in the CMS to show which order things are played in. The flash file (MX) is to firstly check if the update is active, as the content will be running almost permently, then if the content has been updated, read the list of files. These files are sorted into three arrays, file name, id, and subid.
I then need to identify which type of content it is id = 1 = screen content, id = 2 = News Content, Id = 3 = Interactive content.
If the content type is ID 1, I then sort the array into a new array called playlistArray, which gives me the order of play.
All of this is working correctly, however the processor goes to 100% on starting to sort the array, and even though a stop is processed my processor stays at 100% with the usual warnings from flash player, I expected the initial processing to use a lot of resource but it never dies.
Any and all assistance appreciated
Perception
Digital Signage
sleekdigital
07-11-2005, 05:41 PM
I didn't look at your code. But that error usually means you have an infinite loop in your code. That would be the first thing I would look for. Check the logic of all your loops and make sure they will get terminated at some point.
creynders
07-11-2005, 05:57 PM
sleekdigital is probably right. Try putting traces in the for loops to say if they run infinitely
pan69
07-11-2005, 06:05 PM
Just let it run in the IDE for a little while and the Flash IDE will popup a message asking if you want to continue running code...
Slowburn
07-11-2005, 06:15 PM
Ok, There are many inifnite loops being created in your code.
The howmany_items() is calling itself repeatedly with no effect.
stop(); is a timeline function call. This does not stop the process of code. For this you need to use 'break;' please look this up in the Flash help for it's functionality.
I have redone some of your code to make it more readable, however, I am quite stumped on what you are trying to do with the last 2 functions: howmany_items() and proccessPlay_order(). What is your goal with these?
Perception
07-11-2005, 06:19 PM
There is no infinate loop in the code, there is a trace action just prior to a stop, I see the trace action but the stop does not appear to process. At the same time with the script warning the trace action shows everything completed. But even if I then do a gotoAndStop to another frame, which I see, the processor is still running at 100%. It never comes down from 100% even though trace actions show that all loops are complete.
creynders
07-11-2005, 06:29 PM
There is definitely an infinite loop in the last "for" loop. I just put a trace in it and it keeps on tracing...
Once a script is running, going to another frame won't stop the script from running if it's in an infinite loop.
Perception
07-11-2005, 06:33 PM
Ok, There are many inifnite loops being created in your code.
The howmany_items() is calling itself repeatedly with no effect.
stop(); is a timeline function call. This does not stop the process of code. For this you need to use 'break;' please look this up in the Flash help for it's functionality.
I have redone some of your code to make it more readable, however, I am quite stumped on what you are trying to do with the last 2 functions: howmany_items() and proccessPlay_order(). What is your goal with these?
Howmany_items() runs until it has run once for each item in the array then it exits to the next function.
This was done because I need for the next function to determine the stop point for the function, so this counts the occurances of the number 1 in the array.
I have placed some wait functions between each function and this now points to the final function processPlay_order() as the culprit.
This function looks in the idArray for the value 1, if the value is 1 it then checks what the subidArray value is for the same index, if the subidArray value equals index value (Set to 0 for the start) then it places the filename into a new array at index value. This is done so I can process the content XML file in the correct order. The function exits once n > the value generated by the howmany_items function
The whole script completes but the processor never recovers.
Perception
Perception
07-11-2005, 06:43 PM
Thanks to all those who looked and suggested.
I placed a break in the final function where I had stop() and the processor never got above 3%, I tested it on an xml list with over 200 entrys and it never broke a sweat,
Thanks Slowburn, I thought a stop was a stop
:)
Perception
Digital Signage
Slowburn
07-11-2005, 06:51 PM
function update_load ()
{
update_xml = new XML ();
update_xml.ignoreWhite = true;
update_xml.onLoad = function (success)
{
if (success) {
trace ("Download success");
processUpdate (this);
} else {
trace ("Error Connecting to Update.xml");
_root.createTextField ("error_txt", 2, 130, 900, 1100, 20);
error_txt.autoSize = true;
error_txt.selectable = false;
error_txt.multiline = true;
error_txt.wordWrap = true;
error_txt.border = false;
error_txtformat = new TextFormat ();
error_txtformat.font = "arial";
error_txtformat.size = 25;
error_txtformat.color = 0xff0000;
error_txtformat.bullet = false;
error_txtformat.underline = false;
error_txt.text = "Error Connecting to external server. Please check your internet connection, if a problem still occurs following checking the internet connection, Please contact Perception Service";
error_txt.setTextFormat (error_txtformat);
}
};
update_xml.load ('update.xml');
}
function processUpdate (xml_update)
{
_global.update_value = xml_update.firstChild.firstChild.firstChild.nodeVa lue;
trace ("Old Update Value = " + _global.update);
trace ("New Update Value = " + _global.update_value);
if (_global.update_value > _global.update) {
trace ("do update");
_global.update = _global.update_value;
loadplaylist ();
}
}
function loadplaylist ()
{
playlist_xml = new XML ();
playlist_xml.ignoreWhite = true;
playlist_xml.onLoad = function (success)
{
if (success) {
trace ("Download success");
var children = this.firstChild.childNodes;
for (var i = 0; i < children.length; i++) {
var child = children[i].childNodes;
_global.linkArray[i] = child[0].firstChild.nodeValue;
_global.idArray[i] = child[1].firstChild.nodeValue;
_global.subidArray[i] = child[2].firstChild.nodeValue;
}
proccess_items ();
} else {
trace ("Error Connecting to RSS Feed");
_root.createTextField ("error_txt", 2, 130, 900, 1100, 20);
error_txt.autoSize = true;
error_txt.selectable = false;
error_txt.multiline = true;
error_txt.wordWrap = true;
error_txt.border = false;
error_txtformat = new TextFormat ();
error_txtformat.font = "arial";
error_txtformat.size = 25;
error_txtformat.color = 0xff0000;
error_txtformat.bullet = false;
error_txtformat.underline = false;
error_txt.text = "Error Connecting to external server. Please check your internet connection, if a problem still occurs following checking the internet connection, Please contact Perception Service";
error_txt.setTextFormat (error_txtformat);
}
};
playlist_xml.load ('play.xml');
}
function proccess_items ()
{
for (i = 0; i < _global.idArray.length; i++) {
var a = _global.idArray[i] == 1;
var b = _global.subidArray[i] == _global.index;
if (a && b) {
_global.max_items++;
_global.playlistArray[_global.index] = _global.linkArray[i];
_global.index++;
}
}
}
_global.update = 0;
_global.max_items = 0;
_global.index = 0;
_global.linkArray = new Array ();
_global.idArray = new Array ();
_global.subidArray = new Array ();
_global.playlistArray = new Array ();
update_load ();
Perception
07-13-2005, 11:40 PM
Hi Slowburn,
Thanks for the tidy code, there was on problem though, if the idArray arrived the last item before it had all the items then the other items were missing as an example try running this array through.
function proccess_items ()
{
for (i = 0; i < _global.idArray.length; i++) {
var a = _global.idArray[i] == 1;
var b = _global.subidArray[i] == _global.index;
if (a && b) {
_global.max_items++;
_global.playlistArray[_global.index] = _global.linkArray[i];
_global.index++;
}
}
}
_global.max_items = 0;
_global.index = 0;
_global.linkArray = new Array ();
_global.idArray = new Array (2,1,1,1,0,1,1,1,1,1);
_global.subidArray = new Array (-,0,-,1,-,2,3,5,6,4);
_global.playlistArray = new Array (1,2,3,4,5,6,7,8,9,10);
process_items ();
It will only return 6 items in the _global.linkArray as it looks at the end of the IdArray before finding the last two items. this was one of the reasons I seperated out finding the _global.max_items.
the code below works with any combination
function howmany_items() { // total items == 1 in idArray
if (_global.idArray[q] == 1) {
_global.max_items++ ;
q++ ;
howmany_items();
} else {
if (q < _global.linkArray.length) {
q++ ;
howmany_items();
} else {
trace("max items = " +_global.max_items)
set_index();
break;
}
}
}
function set_index() {
_global.index = 0 // reset its used elsewhere
limit = _global.max_items - 1 // adjust for root
process_items()
}
function process_items ()
{
trace(_global.playlistArray.length)
trace(limit)
for (i = 0; i < _global.idArray.length; i++) {
var a = _global.idArray[i] == 1;
var b = _global.subidArray[i] == _global.index;
if (a && b) {
_global.playlistArray[_global.index] = _global.linkArray[i];
increment_index();
}
}
}
function increment_index() {
if (_global.playlistArray.length == limit) {
trace(_global.playlistArray.length);
trace(limit);
trace("Go do it");
//gotoAndPlay("get_content");
}
else {
_global.index++;
process_items();
}
}
_global.max_items = 0;
_global.index = 0;
_global.linkArray = new Array ();
_global.idArray = new Array (2,1,1,1,0,1,1,1,1,1);
_global.subidArray = new Array (-,0,-,1,-,2,3,5,6,4);
_global.playlistArray = new Array (1,2,3,4,5,6,7,8,9,10);
howmany_items();
Again thanks for your assistance, I wanted to let you know about this slight problem should you ever need a similar index
Perception
Digital Signage
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.