all groups > flash actionscript > september 2005 >
You're in the

flash actionscript

group:

Odd Problem


Odd Problem kjohnson1981
9/23/2005 9:05:07 PM
flash actionscript:
I am trying to get my site to display some XML based text to my website. The
odd thing is it will do it when I run the option to test the file in the flash
editing enviroment, but when outside that enviroment it won't load the XML.
Heres the code I am using to load all the data. Any ideas?


var news_xom = new com.tinlion.XOMClass();
news_xom.addListener(xomListener);
news_xom.load("http://www.designsbyjohnson.com/xml/newsfeed.xml");

var xomListener2 = new Object();
news_xom.onLoad = function() {

_root.NewsFrame_mc.news_mc.newsContent_mc.newDate1_mc.text =
news_xom.docRoot.featurenews.link[0].news_header;
_root.NewsFrame_mc.news_mc.newsContent_mc.newDate2_mc.text =
news_xom.docRoot.featurenews.link[1].news_header;
_root.NewsFrame_mc.news_mc.newsContent_mc.blurb1_mc.text =
news_xom.docRoot.featurenews.link[0].text_blurb;
_root.NewsFrame_mc.news_mc.newsContent_mc.blurb2_mc.text =
news_xom.docRoot.featurenews.link[1].text_blurb;

trace("test");

};


// News Drag Function
this.newsBG_mc.onPress = function() {
startDrag(_root.NewsFrame_mc,false,20,94,436,20);
}
this.newsBG_mc.onRelease = function() {
stopDrag();
}
this.closer_mc.onRelease = function() {
unloadMovie(_root.NewsFrame_mc);
}
Re: Odd Problem Joshua Hansen
9/23/2005 9:23:42 PM
If the code is working in the test environment, make sure the swf is in the
same domain as the xml feed otherwise, because of the flash security model,
it won't allow the swf to download the data.

May be the problem.




[quoted text, click to view]

Re: Odd Problem NSurveyor
9/23/2005 9:26:06 PM
Look up XML.load in the help reference:

In SWF files running in a version of the player earlier than Flash Player 7,
the url parameter must be in the same superdomain as the SWF file that issues
this call. A superdomain is derived by removing the leftmost component of a
file?s URL. For example, a SWF file at www.someDomain.com can load data from
sources at store.someDomain.com, because both files are in the same superdomain
of someDomain.com.

In SWF files of any version running in Flash Player 7 or later, the url
parameter must be in exactly the same domain (see
http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001097.html in Using
ActionScript in Flash.

When the load() method is executed, the XML object property loaded is set to
false. When the XML data finishes downloading, the loaded property is set to
true, and the onLoad event handler is invoked. The XML data is not parsed until
it is completely downloaded. If the XML object previously contained any XML
trees, they are discarded.

You can define a custom function that executes when the onLoad event handler
of the XML object is invoked.

Alternatively, I think you can use PHP to read the XML feed, and then have
flash read the PHP file... not sure how you go about doing this, though.
Re: Odd Problem kjohnson1981
9/23/2005 9:31:05 PM
Originally posted by: NSurveyor
Look up XML.load in the help reference:

In SWF files running in a version of the player earlier than Flash Player 7,
the url parameter must be in the same superdomain as the SWF file that issues
this call. A superdomain is derived by removing the leftmost component of a
file?s URL. For example, a SWF file at www.someDomain.com can load data from
sources at store.someDomain.com, because both files are in the same superdomain
of someDomain.com.

In SWF files of any version running in Flash Player 7 or later, the url
parameter must be in exactly the same domain (see
http://www.designsbyjohnson.com

Let me know if you have any other ideas.
Re: Odd Problem NSurveyor
9/23/2005 9:35:43 PM
Oh, didn't realize the file was in the same domain.. (and didn't realize you
weren't using the XML class)

I haven't heard of the XOMClass, but you might wanna try the XML class:

var news_xom = new XML();

Re: Odd Problem kjohnson1981
9/23/2005 9:53:07 PM
Re: Odd Problem Hero Protagonist
9/23/2005 11:06:15 PM
When you say ?outside the environment? do you mean hosted on a web server or
just opening the SWF on your computer?

If you are opening the SWF locally you want to make sure you are not making a
call outside the Local File Security Sandbox.

In the Publish Settings Dialog there is a Local Playback security setting.
You can load data locally from the system, or from the network but not both
without some additional configuration.

See: http://www.macromedia.com/devnet/flash/articles/fplayer8_security.html

Hope that helps,

-Ken

Re: Odd Problem kjohnson1981
9/26/2005 4:06:14 PM
If what I am understanding from you is true, then it makes no sense to me. Let
me explain a bit.

When I run the SWF through the Flash testing enviroment inside the Flash
application, it goes out and gets the XML everytime, loads correctly everything
works well.

Then I publish the site, run the SWF from my local drive and it no longer
works. Ok, fine. So I upload the file to the same domain where the XML is
located, the swf is in the root of the domain and the XML is in a subfolder on
the domain, however it still doesn't work there either.

Anymore ideas? Or am I misunderstanding your post? Let me know. Thanks.
Re: Odd Problem kjohnson1981
9/26/2005 6:47:57 PM
Re: Odd Problem kjohnson1981
9/26/2005 7:09:58 PM
Its totally possible I guess, anything is possible, although, I keep coming
back to this, why can it load the images, which is using a far more complex set
of code, and it cannot load some simple text?
Re: Odd Problem kjohnson1981
9/26/2005 8:10:12 PM
ok, tried that...you can view the result here.....
http://designsbyjohnson.com/

Now, I used both methods there, I tried yours first using Flash's native XML
engine, then the same using the XOM Class. Both failed to load on the server
side and local machine site, but worked great in the testing enviroment. The
main reason I am baffled here is that it is able to get and display one XML,
but not the other that makes no sense to me. Here is the code from the two XML
displays I have going on.....





// NEWS XML DISPLAY
--------------------------------------------------------------------------------
-----------------------------
/*
var news_xom = new com.tinlion.XOMClass();
news_xom.addListener(xomListener);
news_xom.load("http://www.designsbyjohnson.com/xml/newsfeed.xml");

var xomListener2 = new Object();
news_xom.onLoad = function() {

_root.NewsFrame_mc.news_mc.tester123_mc.text = "Loaded";
_root.NewsFrame_mc.news_mc.newsContent_mc.newDate1_mc.text =
news_xom.docRoot.featurenews.link[0].news_header;
_root.NewsFrame_mc.news_mc.newsContent_mc.newDate2_mc.text =
news_xom.docRoot.featurenews.link[1].news_header;
_root.NewsFrame_mc.news_mc.newsContent_mc.blurb1_mc.text =
news_xom.docRoot.featurenews.link[0].text_blurb;
_root.NewsFrame_mc.news_mc.newsContent_mc.blurb2_mc.text =
news_xom.docRoot.featurenews.link[1].text_blurb;

};
*/
// OLD METHOD



var xml:XML = new XML();
xml.onLoad = function(success){
if (success){
_root.NewsFrame_mc.news_mc.tester123_mc.text = "Loaded";
}else {
_root.NewsFrame_mc.news_mc.tester123_mc.text = "Failed";
}
}
xml.load("http://www.designsbyjohnson.com/xml/newsfeed.xml");



// News Drag Function
this.newsBG_mc.onPress = function() {
startDrag(_root.NewsFrame_mc,false,20,94,436,20);
_root.NewsFrame_mc.swapDepths(50);
_root.FlickrFrame_mc.swapDepths(1);

}
this.newsBG_mc.onRelease = function() {
stopDrag();
}
this.closer_mc.onRelease = function() {
unloadMovie(_root.NewsFrame_mc);
}







// PHOTOS XML DISPLAY
--------------------------------------------------------------------------------
-----------------------------
#include "includes/XOMClass/XOMClass.as"

var presentation_xom = new com.tinlion.XOMClass();
presentation_xom.addListener(xomListener);

presentation_xom.load("http://www.flickr.com/services/feeds/photos_public.gne?id
=37488314@N00&format=rss_200");

var xomListener = new Object();
preloadIA = [];
presentation_xom.onLoad = function() {
i = 0;
do {
rclip = _root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto" + i +
"_mc"].mask.createEmptyMovieClip("newLoad_mc"+i, 10);

rclip.loadMovie(presentation_xom.docRoot.rss.channel.item[i]["media:content"].at
tributes.url);
rclip._y = -28;
rclip._x = -80;

rclip._xscale = 38;
rclip._yscale = 38;
rclip.ivar = i;
preloadIA[ i ] = setInterval(preloadF, 100, rclip);

function preloadF(mc) {
if (mc.getBytesLoaded()>0 && mc.getBytesLoaded()>=mc.getBytesTotal()) {
clearInterval(preloadIA[mc.ivar]);
mc.setMask(_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto" + mc.ivar +
"_mc"]); // or even simpler mc.setMask(mc)
}
}

i++;
} while (i<9);
};

// Flickr Drag Function
this.flickrBack_mc.onPress = function() {
startDrag(_root.FlickrFrame_mc,false,20,94,436,20);
//_root.FlickrFrame_mc.swapDepths(_root.NewsFrame_mc);
_root.NewsFrame_mc.swapDepths(1);
_root.FlickrFrame_mc.swapDepths(50);
}
this.flickrBack_mc.onRelease = function() {
stopDrag();
}
this.flickCloser_mc.onRelease = function() {
unloadMovie(_root.FlickrFrame_mc);
}


_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto0_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[0].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto1_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[1].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto2_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[2].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto3_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[3].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto4_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[4].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto5_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[5].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto6_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[6].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto7_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[7].link,"_blank");
}

_root.FlickrFrame_mc.flickrViewerHome_mc["flickrPhoto8_mc"].onRelease =
function() {
getURL(presentation_xom.docRoot.rss.channel.item[8].link,"_blank");
}
Re: Odd Problem kjohnson1981
9/26/2005 8:59:01 PM
Alright, I finally figured this one out. Apparently Flash cannot load from a
full qualified path. Only a relative on. This makes no sense to me once again
becasue the other XML is loading, but the fact is its now working.

Thanks to all who helped, I very much appretiate it.
Re: Odd Problem Blade al'Slayer
9/26/2005 9:56:49 PM
Are you sure that this class you like so much hasn't got bugs? Cos this
sounds like it does...
--
Re: Odd Problem Blade al'Slayer
9/26/2005 10:17:40 PM
[quoted text, click to view]
Try the following code just to make sure:

var xml:XML = new XML();
xml.onLoad = function(success){
if (success){
// make some indication - trace won't
// do the job outside flash authoring environment
}else {
// indication
}
}
xml.load("http://www.designsbyjohnson.com/xml/newsfeed.xml");


--
Re: Odd Problem Blade al'Slayer
9/26/2005 11:21:49 PM
Server rejects connection, so I cannot view the results...
Are you sure this is not a matter of connection problems, such as
firewall, security settings or something like that?
I cannot think of a reason why code should work in Authoring env. and
not outside - unless you use some code to detect the player, but I don't
see any here...
Search through the sources for this string:
System.capabilities.playerType
If you find it - this would be the cause - code depending on player type.

Oh - I came with another idea - are you sure you are using the lates
players for your browser and stand-alone player?

--
AddThis Social Bookmark Button