views:

1207

answers:

1

I'm trying to write a very simple/minimal custom video player in Flash CS3

I have a .fla file with 2 MovieClips in my library, Player and PlayButton. The PlayButton movieclip is found on the first frame inside the Player movieclip. Player is exported to actionscript and linked to a Player.as class which dynamically creates a video object.

My document class is MPlayer.as and it adds an instance of Player to the stage. This works well, and the video will play automatically. However, the PlayButton movieclip that is inside my library item Player does not show up...and I have no idea how to access it or get it to show. it is not in the same position as the video, so it shouldn't be under it...I tried addChild(playbutton_instance_name) from Player.as but I get errors. The Player movieclip is exported for actionscript, but the PlayButton movieclip is not since it's inside Player.

Am I setting this up correctly?

+1  A: 

Sounds about right. If it's in your Player MovieClip, it will be exported inside of that. Are you sure it's in the Player clip? You can access it like you would a variable of your Player.as class, i.e. if the PlayButton has an instance name of "playBtn" you could (in the constructor function) try

public function Play()
{
    trace(this.playBtn);
}

And if the clip is in the class properly, it should trace something like [PlayButton]. If you want, post your code in your question or I can take a look at your files if you like.

Typeoneerror
Also make sure your button is not on a GUIDE layer in Flash.
TandemAdam
Hey thanks! I've been troubled with upgrading a custom AS2 player to AS3, and it's quite a task since I haven't touched ActionScript since v1. I know OOP well (I think) so I am loving AS3, but I'm a bit out of practice. Here are all the files, the player is a Flash CS3 file: http://www.lifeisartphoto.com/flashplayer.zip
Kim L
It looks as though it may not be my actual code that is the problem, but the placement of my class files in packages. I started from scratch and created a new very basic setup like I have now...when my Player and MPlayer classes are at the same level of the .swf file, it works as I expect it to. When I put them into packages, it compiles fine and runs, but the stage items are not ever shown.
Kim L
Both class files at same level as swf = works greatMove both classes to packages = compiles, timeline items inside Player movieclip show on stage, but dynamically generated items do not.If I stick a copy of Player.as at the same level as the swf file, it will start working again (even though I don't reference that file in any classes)...any ideas?
Kim L
Having a look now, Kim. :D
Typeoneerror
Ok, first thing is that you've got a "class" called Player which does the video stuff, but you have to associate that MovieClip in your library with that class. So right click "Player" in your library and say "export for actionscript" ...your internal assets should then show up.
Typeoneerror
You'll then get an error that "loadVideo" isn't a function. So again, open the "export" dialog and change the "Class" textfield to "com.mvu.Player" which basically tells this MovieClip item that the class file it should use is the Player class. Then you've just got some layering issues to deal with, but you should be on your way. Let me know ;)
Typeoneerror
Nice job on this though - coming to AS3 from AS1 is not an easy task :D
Typeoneerror
...getting you started on the layering...change line 42 of Player.as to something like addChildAt(_video, 0); ... that will place the video instance *behind* your manually created stage assets.
Typeoneerror
lol wow, I had the Player linked and somehow it got unlinked (maybe because at one point I changed the package structure)...I can't believe I didn't double-check that hahaha. AddChildAt(_video,0) works great. I think moving from AS1 to AS3 might be easier than AS2 to AS3 from what I've seen. I'm loving AS3, as frustrating as it can be at times!
Kim L
Thank you for all your help TypeOneError! :)
Kim L