This content has been marked as final. Show 11 replies
I ran into the same problem. It might be a bug but my solution was to include an empty string first. Like this:
Hope that work for you as well.
you shouldn't need to do that, I've done this tons of times. Please zip up your FLA any any needed files, post a link for download. I'll take a look.
wow this post was a while ago
Since then, I've learned a lot about xml, php and how to use them together with flash.
I ended up constructing the .xml file differently in php
then used attributes.url for the path.
Its funny looking at this code now... I can't believe it works.
Anyway, here is part of the very sloppy code.
I only answered this because I find the flash behavior strange and would like to see if there is a logical answer to this?
·elitemµsician·: I'm glad you've worked it out. Perhaps this error doesn't show when using attributes. Haven't tested that.
dzedward: Publishing it to FP version 8 will create an error when loading the image, but in FP version 9 it works. By using the workaround I posted earlier it works when publishing to version 8 as well.
Here is my complete code:
This line doesn't look right to me. I suggest you change it as follows:
It seems like the XML isn't completely parsed even though a trace cmd gives the correct image name string.
That tricked me. Using it without the nodeValue at the end was causing my problems.
This probably also solves ·elitemµsician· original post. It sure did in my case and I live and learn :)
You're welcome. Yes, sometimes tracing out XML nodes can be deceiving. I believe the reason is that when you use trace on something, trace calls its toString method and this probably gives you something that looks identical to the nodeValue for a text node. But the correct way to get the text out of a text node is via the nodeValue property of the node... I hadn't looked at the history because I saw it was answered. But yes it is the same problem as in the first post. ·elitemµsician· avoided the use of text nodes for the urls in a subsequent post by storing the url in an attribute.
Originally posted by: GWD
But the correct way to get the text out of a text node is via the nodeValue property of the node... But yes it is the same problem as in the first post. ·elitemµsician· avoided the use of text nodes for the urls in a subsequent post by storing the url in an attribute.
I just seems logical to me to do it this way... why store urls in a text node when its a url?
I am still new to this... so maybe there is a reason why it appears that I "avoided text nodes"... when, I thought I was approaching it the "correct way".
I've done other projects that are set up the same way:
I use php to create an .xml file with all the urls for the .jpgs in a specified folder.
To get those images into flash I use nodes.attributes.url.
Theres also dynamic text that can be changed by the user.
For that I use php to create an .xml file with text nodes.
To get that text into flash I use nodes.firstChild.nodeValue.
Seems logical to me.
Is this not the proper way to approach this?
Because although this works... I've never gone to school or anything for this so I really don't know the "correct way" to do it.
Heres an example of how php constructs the .xml files.
Hey that wasn't a criticism of you using attributes for the url.
You can store your urls in attributes for sure. I do the same things - sometimes one way, sometimes the other in text nodes, it just depends on the data and sometimes on my mood, lol.
I was just commenting that the "correct way to get the text out of a text node is via the nodeValue property of the node". Not suggesting it was the best way to store a url. I actually think using an attribute is slightly faster in terms of code execution than using a text node - which is a theoretical advantage.
I noted that it seemed that the textnode access was similar in terms of the problem in your first post. My other comment was more to say that perhaps you didn't have to 'solve' that problem specifically. You used an attribute - which is an entirely valid approach - and one way of solving the problem (by avoiding it) because you got it working another way. It wasn't intended to be judgemental about the approach you chose at all.
I was afraid you would think that I thought you were criticizing.
I should have worded it differently.
Literally, I wanted to know (from a Senior Member) if that is the proper (correct) way to approach this.
I haven't taken any classes on this stuff yet. I just see an objective, and then figure out how to make it work.
You see, I would write the code that is in the first post differently now, as I have in other projects.
So I'm sure that the stuff I'm working on now, I would do differently in the future.
I just want to accelerate that process as much as possible.
Thanks GWD, I think you've been more help then you realize.
So I guess the real answer to this post is:
To get the text out of a text node, use nodeValue
And for the loadClip url, you could use attributes.url
"I should have worded it differently."
No, it was fine. I figured it was better for me to interpret it that way though in case you did think I was criticising your approach.
"I haven't taken any classes on this stuff yet. I just see an objective, and then figure out how to make it work."
Neither have I. I learnt from the help files and trying stuff too. Your learning approach is exactly the same as mine. Couple of things I'd encourage you to do to 'accelerate the process' are
a) continue to do that (what you're doing) -its great - and
b) become active in forums like these. There's another one just started up by dzedward - flashgods.org which has live chat support as well so for anything urgent you can even get realtime help. So that's great for getting help. But also I recommend spending some time helping out by answering others with what you've already learnt. I can say with certainty that's the approach that worked best for me. There's a saying that the best way to learn something is to try and teach it. Plus you get a lot of posts on your forum profile and get to be called 'senior' ....lol.