320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Hello ya’ll!

I need some help because i’m totally new to AS3 and I’m not liking it so far lol

I’m messing around and trying to build a custom YouTube player, but what I want is to have the YouTube ID inside a .xml file and have AS3 to pull in that ID. Easy right?.

I have that working and I see it with the trace statement, but the issue i’m having is if you take a look at my code on line 30 you will see what I’m trying to attempt lol.

So Instead of using:
 player.loadVideoById("uZSobH1wiiM"); // Loads the youtube id

I want to have the “uZSobH1wiiM” be brought in via xml and you can see that I’m almost there. I just need a few more steps. Right?

I’m getting an error. The error is: 120: Access of undefined property youtubeID.

Here is my .xml structure:
<site>
<video_list><video>uZSobH1wiiM</video></video_list>
</site>

Here is my code for the YouTube player http://pastie.org/4174267

So if someone could please explain to me what I’m doing wrong and what I should be doing right.

Thanks
Tim

3671 posts Community Moderator
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Netherlands
  • Community Moderator
  • Envato Studio (Microlancer) Beta Tester
  • Sold between 10 000 and 50 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
+4 more
Joost Volunteer moderator says

That’s weird! When I recreate the files (and cut out everything but the XML -loading) it worksed just fine! Can you perhaps add a trace(xmlData) before the youtubeID assignment, to figure out if the XML file is read correctly, or what xmlData contains at least? Perhaps even trace e.target.data before assigning it to xmlData.

1676 posts Envato Elite Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Europe
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
+1 more
Tean says

This needs to be defined on global level to be accessible outside the function:

var youtubeID:String

3671 posts Community Moderator
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Netherlands
  • Community Moderator
  • Envato Studio (Microlancer) Beta Tester
  • Sold between 10 000 and 50 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
+4 more
Joost Volunteer moderator says

This needs to be defined on global level to be accessible outside the function:

He’s not accessing it outside the function, though, right?

EDIT : Nevermind, you’re right. I thought the trace was throwing the error, but it is in fact the player.loadVideoById(youtubeID); line. Tean has the solution!

320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Thanks allot guys.

@Tean I learned alittle last-night and I got to that point, but now i’m getting a trace of “null”

Whats the deal?

Thanks for your time guys. I appreciate it allot.

320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Nevermind doh!

Got it! Thanks again!

by
by
by
by
by
by