View Full Version : [Q] How do I extend the functionality of the Custom UI Components???
CyanBlue
05-31-2006, 06:45 PM
Finally got the F8 at work... :D
I am trying to add a custom Play/Pause button for the FLV Playback component based upon this DevNet document and it seems to be working fine...
http://www.adobe.com/devnet/flash/articles/custom_flvcomp_03.html
My question is... I don't know how this is acutally working... I mean, I went through the FLVPlayback.as and UIManager.as to see how it is using AS to control all the buttons... But how do I extend the functionality???
As a simple example, I basically want to display 'Mute : On' and 'Mute : Off' when I click on the custom mute button...
I'd appreciate it if anybody can help me on this... :)
just a shot in the dark
but lookup
"VideoPlayer.stateChange"
sleekdigital
06-01-2006, 03:13 PM
Can you clarify your queastion a bit for me? What exactly is it you want to do? If its just a display change, why don't you just add that mute on/off text to the skin as part of the button?
CyanBlue
06-01-2006, 04:34 PM
I am more interested on how that whole stuff works... Mute On/Off is just an example that tells me how I can extend(?) the currecnt code... ;)
sleekdigital
06-01-2006, 05:12 PM
That's a very general question... I still don't know exactly what you are asking for, but i'll give it a shot...
When UIManager is initialized it has a reference to the player .. property name is _vc. if you look at the dispatchMessage method of the UIManager, that is where the buttons are wired up to control the player.
CyanBlue
06-01-2006, 06:18 PM
Hm... Yeah... UIManager.as file contains following code...
case MUTE_ON_BUTTON:
case MUTE_OFF_BUTTON:
if (!_isMuted) {
_isMuted = true;
cachedSoundLevel = _vc.volume;
_vc.volume = 0;
} else {
_isMuted = false;
_vc.volume = cachedSoundLevel;
}
trace("_vc.volume : " + _vc.volume);I was looking for something that says on_mc.onPress = blah blah but I was not able to find that...
I added this trace() line at the bottom of that if statement to see what the actual value is and somehow I do not see the trace() output even if I restart the Flash 8...
I have edited this C:\Program Files\Macromedia\Flash 8\en\First Run\Classes\mx\video\UIManager.as file... Am I not allowed to edit this file??? Why is the change not effective??? :(
WRONG path !!!
the right one :
C:\Documents and Settings\CyanBlue\Local Settings\Application Data\Macromedia\Flash 8\en\Configuration\Classes\
sleekdigital
06-01-2006, 06:24 PM
The UIManager's dispatchMessage catches all the button events and handles them. Not all button UI code has to use onPress ya know :)
If i'm not mistaken, the reason you don't see your trace is because the code for components is compiled in the swc files... the code in that folder is there just for reference.
I was just talking to someone about extending components in another thread... In this case what you could do is extend FLVPlayback, and make it use your own UIManager class .. that class could extend macromedia's UIManager class and you could just override the methods you want to behave differently. To extend a component...
Make a class that extends the component class
In that class you need the following properties...
static var symbolName:String = "yourSymbol";
static var symbolOwner:Object = yourSymbol;
public var className:String = "yourClassName";
Then in your FLA include teh component and a blank movieclip with the appropriate linkage/as 2 classs to wire it up to the extension class.
CyanBlue
06-01-2006, 06:29 PM
Macromedia keeps both directories the same, Xeef... In other words, if I edit the file in the Program Files directory, the change automatically is reflective in the Documents and Settings directory... It's like a shortcut directory in a sense...
Compiled data in the SWC file... That makes more sense... So, there is NO way to extend(?) that??? If that's the case, there is no way I can add the change that I have put up there as an example or even add the trace() line??? Geez... This whole class stuff is really confusing to me... :(
sleekdigital
06-01-2006, 06:30 PM
See my edited post above
_mc.onPress
:D
link your self in here :
public function handleEvent(e:Object):Void {
this is the part where UIManager.as handles recived events
wich is probably coming from 10 functions away
something like :
MuteControlButton Class
onPress --> AllControlls.buttonPress --> FucusHandler.onPress --> FucusHandler.setFocus --> UIManager.handleEvent
this for example is in FLVPlayback.as
// sending extra bogus events to UIManager so UI is updated propertly for new vp
_uiMgr.handleEvent({type: "stateChange", state: _vp[_visibleVP].state, vp:_visibleVP});
_uiMgr.handleEvent({type: "playheadUpdate", playheadTime: _vp[_visibleVP].playheadTime, vp:_visibleVP});
if (_vp[_visibleVP].isRTMP) {
_uiMgr.handleEvent({type: "ready", vp:_visibleVP});
} else {
_uiMgr.handleEvent({type: "progress", bytesLoaded: _vp[_visibleVP].bytesLoaded, bytesTotal: _vp[_visibleVP].bytesTotal, vp:_visibleVP});
}
others i coudnt find in there
searching for files in (classes) give me over 15 hits (all whit a couple of 1000's lines)
you trying to hach it too much att the roots !!!
you will go nuts till you find it !
It's like a shortcut directory in a sense...
more like abase directory
if there are multiple users on the same machine it woudn't by nice to debug
a couple of days just to find out cyan has eltered the button comp
a newly created user also needs a fresh untached set
i use an extended "windows" component in the moment puting the altered code in the abowe named dir works fine for me
Hmmmm
if i think on it
it coud by done to the fact that i never drag and drop to the stage but use createClassObject ;)
CyanBlue
06-01-2006, 06:48 PM
Hm... I automatically go to the cRaZyAnDpAnIc mode when somebody talks about the 'Class' and the 'Object', so go figure... :(
Okay... I think this will simplify my question...
If I create a class that extends the UIManager class, my class will be actually nullify the Macromedia's class and redefine it with my words if the same function exists, for example... Or am I adding mine to the Macromedia's function???
2 ways
1. wich i woud prefer !
alter the *.AS in the directori named
do NOT use drag drop to create your components !
if you do so the components script (wich is the original one by MM) will by used
BUT use createClassObject (an instance of the class still needs to by in the lib for image asets)
the object will by created whit the instructions in the named dir and file
2 option
create an AS file
class MyIU extends
Puh this is complicated ! use way one :p
other vise
open up :
C:\Program Files\Macromedia\Flash 8\en\Configuration\ComponentFLA\FLVPlayback.fla
check the components set up in the library
see wich class it use
see wich class this class extends (it's easy as long it's extended BUT there are also things injected and this can become stressi !!!)
go up as long needed to find the class wich extend the class you wana extend
change this extend to your class wich extends the original extended class
create your additional methodes
recompile the component
put it to the components directory
restart falsh
taht's all :D
hope i make sense :p
sleekdigital
06-01-2006, 07:13 PM
You would have to alter the existing code, but I don't like the idea of changing macromedia's existing code... lots of potential problems there. Did you understand my breif instructions of extending the component? If you extend, you don't alter any existing code, you just use it as a starting point, and all code changes are encapsulated in your own classes. If the words Class and Object make you panic then you just need to learn some new things to do this. Once you learn a little about classes you won't need to panic anymore :)
sleekdigital
06-01-2006, 07:36 PM
Xeef's suggestion of recompiling the component might be the way to go here, but I would say instead of replacing the existing component, make it a new component. I'm going to try this myself. I'll open the FLVPlayback FLA and save it as a new file with my own name. In the FLA I'll set the components linkage to my own name and its AS 2 class to my own class... that class will just extend the original FLVPlayback class and I'll just override any methods i want to.
make it a new component.
i was meant this
but the steps are the same
it's just a question as what you save it in the end
herean other way (not REALY extending)
//a button needs to by in the lib
class ButtonWrap {
function ButtonWrap() {
MovieClip.prototype.Xeefs_Button = createButton;
}
function createButton(Name, Depth) {
var _btn = this["createClassObject"](mx.controls.Button, Name, Depth);
_btn.onPress = function() {
trace("hallo there her is Xeef's Button :D ");
};
_btn.label = "Press Me";
return _btn;
}
}
//FLA
new ButtonWrap();
_root.Xeefs_Button("abc", 1);
why do you wana extend it ?
do you wana use it in multiple projects ?
CyanBlue
06-01-2006, 07:55 PM
I GIVE UP!!! :(
No, I do not think it is a good idea to 'edit' the base class file especially when I am not the creator... Extending the class would be better way of handling it... I was just adding the trace() line to see if it does the job or not and it did not, hence why does it not work question came up...
I am not currently using any external AS file for the project that I am working on... I only use F8 because I am too lazy to create my own FLV player and so that my boss can buy me F8 that I can use for the FL project...
But I've got to learn how to use the Class at some point... Hopefully it will be soon... ;)
I was just adding the trace() line to see if it does the job or not and it did not, hence why does it not work question came up...
as sad
whit draging the component on the stage it will not work (in this case you need to recompile the component before)
BUT
whit createClassObject
if you need aditional functions in it and you are on to create a NEW component version because you will need this 100's of time in 1000's of projects you will need to recompile
if it's just that you need some fancy thing in this particular project
you simpli can overWrite the function from the timeline
wich shudn't by to complicated
sleekdigital
06-01-2006, 08:28 PM
I was able to get it to work with the steps I described. However for some reason flash will sometimes crash when I drag the new component to the stage, but sometimes it doesn't .. strange. my new class does nothing except a trace and a call to super() in the constructor.
CyanBlue
06-01-2006, 09:00 PM
Yeah... createClassObject() does the job... Weird... Hm...
Would you mind zipping that files and uploading it to the forum so that I can check on that later on, sleekdigital??? ;)
sleekdigital
06-01-2006, 09:16 PM
I sent an email to your FlashVacuum address.
CyanBlue
06-01-2006, 09:21 PM
Hey, much appreciate it... :)
It sure will take some time for me to get my hands on this whole Class stuff, but I'll get there sooner or later... Hopefully sooner cuz I want to check on the AS3 and see how it is... :D
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.