开发者

AS3 beginners: How to put these simple codes together?

开发者 https://www.devze.com 2023-04-03 05:35 出处:网络
I\'m new to AS3 and I need some help putting something w开发者_如何学Goith the FLVPlayBack component together.

I'm new to AS3 and I need some help putting something w开发者_如何学Goith the FLVPlayBack component together.

When I put this in the first frame of my timeline:

player.volume = 0;
player._uiMgr._isMuted = true;

I get an error:

Error Scene=3A - Intro, layer=Actions, frame=1:Line 27: The member is private and cannot be accessed. videoplayer._uiMgr._isMuted = true;

Someone said "create a setter method to do it and the compiler error should disappear!"

But even after googling setter methods, I have no idea how to resolve this issue.

Is anyone able to help me?


It seems that _uiMgr and _isMuted are private attributes (hence the _). Do they have getters assigned to them? If they do you should be able to use player.uiMgr.isMuted = true;

EDIT: You have to assign a muteButton to FLVPlayer and then dispatch clickevent on it. Like this http://www.kirupa.com/forum/showthread.php?193603-FLVPlayback-actionscript-Mute&p=2412841&viewfull=1#post2412841


If you have a variable "player", you want to work with, here is what you should do.

(1) First determine the type of the variable: Run:

  trace( typeof player );    

In your case, it would output "FLVPlayback"

(2) Now go to flash reference on Adobe's site, and look for that class:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/FLVPlayback.html

(3) In the reference you can find the following: (a) Public properties: These are the class variables you may set values to. There are some more variables in this class, that are not listed here, as you have no access to them - because they are not public - they exist only for classes (or package) internal usage. (Example: _uiMgr)

(b) Public methods - these are functions you may run. Here also there are more functions, that are for internal use and not listed.

(c) Events - very important part of AS3. Used for sending messages, or trigerring behaviour between different classes, and for interaction with the user. Read this: http://www.adobe.com/devnet/actionscript/articles/event_handling_as3.html

(d) Public Constants

Now, In your case, looks like you are trying to mute the player. Looking for "mute" in the above list, will give you only one result: muteButton : Sprite Mute button control. We would expect something better, but we will have to work with that. This is a button, and we will make flash think that a user clicked on it - and mute. The following line will do the trick:

 player.muteButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); 

P.S.

When a variable is defined this way:Object player = new FLVPlayback();, running trace(typeof player) will return "Object". You will need to run trace(player.constructor) to see the runtime type of the variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消