Posted by intromo in SWF Studio V3 on May 07 2008, 11:52 am

I've been working on a news ticker exe - built in flash. The SWF seems to work well, however when I convert the program with SWF Studio, the EXE reads my external XML just fine - but when I update and save the XML, nothing changes in the EXE! Amy I missing something? Anyone?

Here's the AS code:

_root.box_mc.container_mc.news_mc._lockroot = true;

//import classes
import mx.transitions.Tween;
import mx.transitions.easing.*;

//loadXML function
function loadXML(loaded) {
   if (loaded) {
      xmlNode = this.firstChild;
      //varibles for storing data from the xml file
      titles = [];
      url = [];
      //variable for the total number of childNodes
      total = xmlNode.childNodes.length;
      //add all the values to my arrays
      for (i=0; i<total; i++) {
         titles[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
         url[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
      }
      //call animateText function
      animateText();
   } else {
      content = "XML not loaded";
   }
}
//function for adding news to the textfield
function displayText() {
   box_mc.container_mc.news_mc.news_txt.text = titles[p];
}
//function for changing the news
function changeText() {
   p++;
   if (p == total) {
      p = 0;
   }
}

//function used for attaching the button events 
function setEvents(mc:MovieClip) {
   mc.container_mc.onRollOver = function() {
      colorText.setRGB(0xFFFFFF); //change text color on RollOver
   };
   mc.container_mc.onRollOut = function() {
      colorText.setRGB(0xFFFFFF); //change text color on RollOut
   };
   mc.container_mc.onRelease = function() {
      getURL(url[p]); //open the url on Release
   };
}

//animate the text from right to left, pause when it is centered...
function animateText() {
   displayText();
   setEvents(box_mc);
   pauseTime = 2;
   startX = w2+w1/2;
   endX = 0-w1/2;
   centerX = w2/2;
   var myTweenX:Tween = new Tween(box_mc.container_mc.news_mc, "_x", Strong.easeOut, startX, centerX, 2, true);
   var myTweenAlpha = new Tween(box_mc.container_mc.news_mc, "_alpha", Strong.easeOut, 0, 100, 2, true);
   myTweenX.onMotionFinished = function() {
      myTweenX = new Tween(box_mc.news_mc, "_x", Strong.easeOut, centerX, centerX, pauseTime, true);
      myTweenX.onMotionFinished = function() {
         myTweenX = new Tween(box_mc.container_mc.news_mc, "_x", Strong.easeIn, centerX, endX, 2, true);
         myTweenAlpha = new Tween(box_mc.container_mc.news_mc, "_alpha", Strong.easeIn, 100, 0, 2, true);
         //repeat the animateText function and change the text
         myTweenX.onMotionFinished = function(){
            changeText();
            animateText();
         }
      };
   };
}
//initialize objects and variables...
var p:Number = 0;//news counter
var w1:Number = box_mc.container_mc.news_mc._width;
var w2:Number = box_mc.container_mc.display_mc._width;

var colorText:Color = new Color(box_mc.container_mc.news_mc.news_txt);
var containerState:String = "down";
//create variable for storing the months
var mon:Array = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept",  "Oct", "Nov", "Dec"];
///create a new empty XML Object
var myXML:XML = new XML();
myXML.ignoreWhite = true;
////////////////////////////////

// text-align property
box_mc.container_mc.news_mc.news_txt.autoSize = "center";
box_mc.time_txt.autoSize = "right";

//if the XML file has successfully loaded in, then call the loadXML function
myXML.onLoad = loadXML;
///load in the xml file
myXML.load("http://tabletrac/tv/text/L.xml");



And the XML:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!--<main>-->

<newsticker>
    <item>
        <news>User 1 was here! 1</news>
        <url></url>
    </item>
    <item>
        <news>User 1was here! 2</news>
        <url></url>
    </item>
    <item>
        <news>User 1 was here! 3</news>
        <url></url>
    </item>
    <item>
        <news>User 1 was here! 4</news>
        <url></url>
    </item>
    <item>
        <news>User 1 was here! 5</news>
        <url></url>
    </item>
    <item>
        <news>User 1 was here! 6</news>
        <url></url>
    </item>
</newsticker>


Posted by pompeyd in SWF Studio V3 on May 07 2008, 12:01 pm

Hi,

How are you saving and updating your XML? Your code only shows what happens when you load your XML.

If your XML file, or data changes, then, from a quick scan of your AS, it looks like you need to reset the values in your Arrays from inside your loadXML function.

Can you explain a bit further?

Paul


Posted by intromo in SWF Studio V3 on May 07 2008, 12:21 pm


QUOTE: from pompeyd;44178
Hi,

How are you saving and updating your XML? Your code only shows what happens when you load your XML.

If your XML file, or data changes, then, from a quick scan of your AS, it looks like you need to reset the values in your Arrays from inside your loadXML function.

Can you explain a bit further?

Paul


Hi Paul - thanks for the response!

I'm saving the and updating the XML - locally on a server. Currently, I have the code running on one frame of the timeline, however when I add about 15sec. to the time frame, with an "unload MC" fucntion at the end, it goes black and never reloads the MC. When I don't have the unload funtion at the end, the SWF creates another XML which "meshes" with the first XML.

I've searched hi and low for a solution for this problem - with no luck. Is there an easy way to reset that i'm missing?


Posted by pompeyd in SWF Studio V3 on May 07 2008, 12:36 pm

It really depends on the the functionality you want.

When do you want to reload your XML?

You don't need to add any more frames, just organise your code a little better. One way would be to declare all your variables first, then place as much code as you can into as many functions as you can so that you can call the required function whenever you need to.

Using frames to create programming logic can get messy - especially if you need to change things later on.

All you should need to do is something along the lines of the following:

var resetXML:Function = function( Void ):Void
{
    // Add any other variables that need to be reset here along with the following
    myXML = new XML();
    myXML.load("http://tabletrac/tv/text/L.xml");
};


Then all you need to do is to call the resetXML() function whenever you want to reload your data from your XML file.

I'm off for the night now, so will check back tomorrow to see if you need any more help, otherwise....

HTH

Paul


Posted by pompeyd in SWF Studio V3 on May 07 2008, 12:41 pm

One final thought which you may or may not know:

Declare your variables outside of the functions, then reset them inside. Don't declare them in a function or they become scoped to that function alone. When you reset them inside a function don't add var in front of the variable or this will scope it to the function too - just use the variable name and value.

Don't mean to teach you to suck eggs if you already know this, ;), but if you don't you could be goiong round in circles all day/night ;)

Regards

Paul


Posted by intromo in SWF Studio V3 on May 07 2008, 12:54 pm


QUOTE: from pompeyd;44181
One final thought which you may or may not know:

Declare your variables outside of the functions, then reset them inside. Don't declare them in a function or they become scoped to that function alone. When you reset them inside a function don't add var in front of the variable or this will scope it to the function too - just use the variable name and value.

Don't mean to teach you to suck eggs if you already know this, ;), but if you don't you could be goiong round in circles all day/night ;)

Regards

Paul


Hi Paul - Thanks for the heads up. I will try adding the variable to see if that's what I need. Declarcing variables outside the function is a good tip!! One of which I didn't know! I haven't used variables so far in my life of a Actionscripter. I'll let you know how it goes. Thanks again for the help!


Posted by AGo in SWF Studio V3 on May 07 2008, 04:46 pm

you might also run into an caching issue, try this instead, this enforces the re-GET-ing the file from the server

myXML.load("http://tabletrac/tv/text/L.xml?noCache="+new Date().getTime());


Posted by intromo in SWF Studio V3 on May 07 2008, 06:22 pm


QUOTE: from AGo;44202
you might also run into an caching issue, try this instead, this enforces the re-GET-ing the file from the server

myXML.load("http://tabletrac/tv/text/L.xml?noCache="+new Date().getTime());


AGo - I tried this once before - with no luck. The SWF's are being converted to EXE's which are run locally. The XML is being called from an internal server through http. Would that make any difference?


Posted by intromo in SWF Studio V3 on May 08 2008, 05:31 pm


QUOTE: from pompeyd;44180
It really depends on the the functionality you want.

When do you want to reload your XML?

You don't need to add any more frames, just organise your code a little better. One way would be to declare all your variables first, then place as much code as you can into as many functions as you can so that you can call the required function whenever you need to.

Using frames to create programming logic can get messy - especially if you need to change things later on.

All you should need to do is something along the lines of the following:

var resetXML:Function = function( Void ):Void
{
    // Add any other variables that need to be reset here along with the following
    myXML = new XML();
    myXML.load("http://tabletrac/tv/text/L.xml");
};


Then all you need to do is to call the resetXML() function whenever you want to reload your data from your XML file.

I'm off for the night now, so will check back tomorrow to see if you need any more help, otherwise....

HTH

Paul


Hi Paul,

This didn't seem to work for me.


Posted by intromo in SWF Studio V3 on May 08 2008, 05:39 pm

Paul - I may be just easier for you to take a look at my file:

http://www.intromotion.com/tv/promo/l_shape_OFFICE.fla

Changed the paths in the code to new XML.

XML file:

  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <main>
- <newsticker>
- <item>
  <news>User BEEEEEEE was here! 1</news> 
  <url /> 
  </item>
- <item>
  <news>User BEEEEEEE was here! 2</news> 
  <url /> 
  </item>
  </newsticker>
- <news>
- <item>
  <news>Welcome to 7 Clans Casino | Thief River Falls</news> 
  <url /> 
  </item>
- <item>
  <news /> 
  <url /> 
  </item>
- <item>
  <news>....................................</news> 
  <url /> 
  </item>
  </news>
  </main>


For some reason or another (and believe me - I've tried everything) - I can't seem to get the content to refresh after I change and save the XML file.

Ya know?


Posted by pompeyd in SWF Studio V3 on May 09 2008, 05:13 am

Hi Intromo,

First off, you are defining myXML twice, on two different layers - and telling it to load twice etc.

Secondly, think about what is happening on the timeline. Your framerate is set to 40fps, over 200 frames. Then the playhead will loop back to the first frame, where your XML is redefined and loaded again.

Thirdly, just placing the reset function on frame 1 will not do anything, you need to call the reset function when you want to reset your XML and any other variables. Although this is pointless with the way it is set up over the timeline with all your variables being redefined every 5 secs (approx) on frame 1.

You have to decide when it is, exactly, that you want to reload your XML file. Then set your FLA up accordingly - either over frames as you have, but extend the number of frames to match the timeline for re-loading your XML, or just use one frame, with everything coded and use the reset function to reload your XML.

It just takes a bit of planning beforehand after you have decided when exactly you want to reload your XML.

HTH

Paul

p.s. I'm always available to do some freelance work ;)


Posted by intromo in SWF Studio V3 on May 14 2008, 04:33 pm


QUOTE: from pompeyd;44238


p.s. I'm always available to do some freelance work ;)


After about a week of tinkering with this, I now have NO timeline - which works.... however, I'm still having the same issues with the text wiggin out everytime I udpate the XML file.

How much would you charge to help me get this working..?


Posted by pompeyd in SWF Studio V3 on May 15 2008, 05:30 am

Hi Intromo,

If you e-mail your fla to 'paul at hollyer dot me dot uk', I will have a look at where you are now with it, and let you know.

Regards

Paul


Posted by intromo in SWF Studio V3 on May 15 2008, 05:23 pm


QUOTE: from pompeyd;44299
Hi Intromo,

If you e-mail your fla to 'paul at hollyer dot me dot uk', I will have a look at where you are now with it, and let you know.

Regards

Paul


Hi Paul,

I actually have this all figured out. There was a tweening issue that I was overlooking. Thank you for your help with this. Could you send me your contact information for future reference anyway?

Thanks.


Posted by pompeyd in SWF Studio V3 on May 16 2008, 07:45 am

I've PM'd you with details :)

Paul