Hi
I have a presentation with various embedded and external videos linked to it. I need them to be positioned in the center of the screen no matter what resolution the user is running, therefore I need to position them dynamically and not with specific co-ordinates. I have found a link and some code that does this, but its a big chunk of code and I would like to put this code in my main .as file, as a function, and then in my main timeline when I have a video - just use one line of code to call the function and apply it to a movieclip with the video inside.
Here is the link : http://scriptplayground.com/tutorials/as/Center-a-movieclip-on-stage-resize-in-AS3/
and here is the code :
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
function resizeHandler(e:Event):void
{
mySampleMC.x = (mySampleMC.stage.stageWidth / 2) - (mySampleMC.width / 2);
mySampleMC.y = (mySampleMC.stage.stageHeight / 2) - (mySampleMC.height / 2);
}
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE));
As you can see, the function has the reference to a specific movieclip instance variable inside it. I need to change this so that its generalized, does the same thing but instead I pass a movieclip as a parameter ? So this block of code would be in my main.as file just once, then on my main timeline when I need to link to a video I call this function somehow with one line of code but apply it to a certain movieclip. ie: so I dont need to write out this whole block of code for every movieclip with a video inside.
Any help is greatly appreciated, thanks in advanceā¦