First let me say that I am just starting out in AS3 so this may be a simple problem that I am having due to my lack of experience.
Goal: I have a mask over a mc that holds video being streamed in. This mask is set to show only a portion of the video and when the user mouses over the mask I want it to expand to show the whole movie. When the user mouses off the mask I want it to re-size back to its original size.
Problem: The second time the mouse is over the mask, it does get tweened to the larger size, but you do NOT see the animation occur. It just blinks in.
Code:
I have included everything but my video class and grid class. For this I have turned off my grid. BTW this my FLA file includes this class. I have this feeding from an xml file, i removed that code. I also have 2 other movies that will function the same as movie1 but I have removed that code. Once I get movie1 working it should be fine for movies 2 and 3.
import caurina.transitions.Tweener;
import flash.utils.Timer;
var imgSprite:Sprite=new Sprite();
var v:simpleFLV = new simpleFLV();
var movie1Mask:movieHolderMask_MC = new movieHolderMask_MC();
var movie2Mask:movieHolderMask_MC = new movieHolderMask_MC();
var movie3Mask:movieHolderMask_MC = new movieHolderMask_MC();
var movie1OrigW:int = movie1.width;
var movie1OrigH:int = movie1.height;
var movie1URL:String;
var movie2URL:String;
var movie3URL:String;
var movieIsShowing:Boolean = false;
//add our bg image to the very bottom
addChildAt(imgSprite,0);
//mask for movie1
addChild(movie1Mask);
movie1.mask = movie1Mask;
movie1Mask.buttonMode = true;
//event for movie1
movie1.mask.addEventListener(MouseEvent.MOUSE_OVER, movie1Over);
function movie1Over(e:MouseEvent):void {
if(!movieIsShowing) {
movieIsShowing = true;
movie1.removeEventListener(MouseEvent.MOUSE_OVER, movie1Over);
if(movie1.getChildByName('video1')) {
trace('existing v1');
v.Seek(0);
} else {
trace('new v1');
movie1.addChild(v);
v.name = 'video1';
}
trace(movie1.mask.width);
Tweener.addTween(movie1.mask, {width:220,height:160,time:1, onComplete:function(){
v._w = movie1OrigW;
v._h = movie1OrigH;
v.Play(movie1URL); //feed in from xml
//not sure why playing video will cause movie1 to increase in size...
movie1.width = movie1OrigW;
movie1.height = movie1OrigH;
movie1.mask.addEventListener(MouseEvent.MOUSE_OUT, movie1Out);
trace(movie1.mask.width);
}
})
}
}
function movie1Out(e:MouseEvent):void {
trace('out');
if(mouseX == 1 || mouseX > (movie1.width - 5) || mouseY > (movie1.height - 5)) {
v.Pause();
Tweener.addTween(movie1Mask, {width:110,height:80,time:1,onComplete:function(){
movie1.removeChild(movie1.getChildByName('video1'));
movie1.width = 110;
movie1.height = 80;
movie1.mask.addEventListener(MouseEvent.MOUSE_OVER, movie1Over);
//movie1Mask.removeEventListener(MouseEvent.MOUSE_OUT, movie1Out);
movieIsShowing = false;
v.Dispose();
//v.Seek(0);
//v._video.clear();
//v._video = null;
}});
}
}
If I am going about this the wrong way, please let me know what a better way of doing this is.
Thanks,
Albert