Mask multiple MovieClip
Hi !
Is it possible to mask more than one movieclip in action
script.
I see that's possible in the gaphical author environment.
_root.attachMovie("mask_mc","mask_mc",10);
_root.attachMovie("a_mc","a_mc",0);
_root.attachMovie("another_mc","another_mc",1);
_root.a_mc.setMask(_root.mask_mc);
_root.another_mc.setMask(_root.mask_mc);
This simple code don't work...
Thanks a lot.
Tivins.
Tivins,
> Is it possible to mask more than one movieclip in
> action script. I see that's possible in the gaphical
> author environment.
Yes. Make sure to include all the movie clips you want to
mask inside
of a single movie clip, then mask that "container" movie
clip.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design."
Similar Messages
-
Mask multiple movieclips from single mask
Hi,
h have big movieclip 450X350 and there are many small thumbnails i need to mask those from big movieclip, I need to animate those so that i can't put those in a single movieclip, Is it possible to mask multiple movieclips from single movieclip...?If you want to mask them using Actionscript then you should be able to place them inside a movieclip/sprite as separate animations/movieclips and then assign the mask to the container.
You can mask multiple layers under one layer if you use the timeline -
Mask multiple movieclips from single movieclip
Hi i am trying to mask 3 thumbnails from 1 movieclips
mc.samsungchamp.mask=mc.msk
mc.samsungduos.mask=mc.msk
mc.samsungace.mask=mc.msk
but these thumbs are is not showing masked.Is this not possible to mask all movieclips through one movieclip, without putting movieclips into single movieclip.??
-
Mask multiple movieclips by single movieclip
Hi, I have make many thumbnails(t1,t2,t3....) on homepage of my website now i req. to mask all thmbnails by one movieclip(mskMC).
Thanks for your support.I cn't do that because my app structure will be change and many functionalites will be affect from it
-
Scroll Bar Controlling multiple movieclips?
Instead of a scroll bar just controlling one movieclip..How could we get it to control multiple movieclips?
public class MainScroll extends Sprite
//private var mc_content:Sprite;
private var content_mc:MovieClip;
private var content2_mc:MovieClip;
private var _scrollBar:FullScreenScrollBar;
//============================================================================================================================
public function MainScroll()
//============================================================================================================================
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
//============================================================================================================================
private function init():void
//============================================================================================================================
SWFWheel.initialize(stage);
//_copy = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quam leo semper non sollicitudin in eleifend sit amet diam. ";
content_mc = new mc_content();
content2_mc = new mc_content2();
content_mc.x = 110;
content_mc.y = 29;
content2_mc.x = 10
content2_mc.y = 29
addChild(content_mc);
addChild(content2_mc);
// Scrollbar code
// Arguments: Content to scroll, track color, grabber color, grabber press color, grip color, track thickness, grabber thickness, ease amount, whether grabber is "shiny"
_scrollBar = new FullScreenScrollBar(content_mc, 0x000000, 0x408740, 0x73C35B, 0xffffff, 15, 15, 4, true);
addChild(_scrollBar);
//============================================================================================================================
private function onAddedToStage(e:Event):void
//============================================================================================================================
init();
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);Ok,
Here is that code:
import flash.display.*
import flash.events.*;
import flash.geom.Rectangle;
import gs.OverwriteManager;
import gs.TweenFilterLite;
public class FullScreenScrollBar extends Sprite
private var _content:DisplayObjectContainer;
private var _trackColor:uint;
private var _grabberColor:uint;
private var _grabberPressColor:uint;
private var _gripColor:uint;
private var _trackThickness:int;
private var _grabberThickness:int;
private var _easeAmount:int;
private var _hasShine:Boolean;
private var _track:Sprite;
private var _grabber:Sprite;
private var _grabberGrip:Sprite;
private var _grabberArrow1:Sprite;
private var _grabberArrow2:Sprite;
private var _tH:Number; // Track height
private var _cH:Number; // Content height
private var _scrollValue:Number;
private var _defaultPosition:Number;
private var _stageW:Number;
private var _stageH:Number;
private var _pressed:Boolean = false;
//============================================================================================================================
public function FullScreenScrollBar(c:DisplayObjectContainer, tc:uint, gc:uint, gpc:uint, grip:uint, tt:int, gt:int, ea:int, hs:Boolean)
//============================================================================================================================
_content = c;
_trackColor = tc;
_grabberColor = gc;
_grabberPressColor = gpc;
_gripColor = grip;
_trackThickness = tt;
_grabberThickness = gt;
_easeAmount = ea;
_hasShine = hs;
init();
OverwriteManager.init();
//============================================================================================================================
private function init():void
//============================================================================================================================
createTrack();
createGrabber();
createGrips();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
_defaultPosition = Math.round(_content.y);
_grabber.y = 0;
//============================================================================================================================
public function kill():void
//============================================================================================================================
stage.removeEventListener(Event.RESIZE, onStageResize);
//============================================================================================================================
private function stopScroll(e:Event):void
//============================================================================================================================
onUpListener();
//============================================================================================================================
private function scrollContent(e:Event):void
//============================================================================================================================
var ty:Number;
var dist:Number;
var moveAmount:Number;
ty = -((_cH - _tH) * (_grabber.y / _scrollValue));
dist = ty - _content.y + _defaultPosition;
moveAmount = dist / _easeAmount;
_content.y += Math.round(moveAmount);
if (Math.abs(_content.y - ty - _defaultPosition) < 1.5)
_grabber.removeEventListener(Event.ENTER_FRAME, scrollContent);
_content.y = Math.round(ty) + _defaultPosition;
positionGrips();
//============================================================================================================================
public function adjustSize():void
//============================================================================================================================
this.x = _stageW - _trackThickness;
_track.height = _stageH;
_track.y = 0;
_tH = _track.height;
_cH = _content.height + _defaultPosition;
// Set height of grabber relative to how much content
_grabber.getChildByName("bg").height = Math.ceil((_tH / _cH) * _tH);
// Set minimum size for grabber
if(_grabber.getChildByName("bg").height < 35) _grabber.getChildByName("bg").height = 35;
if(_hasShine) _grabber.getChildByName("shine").height = _grabber.getChildByName("bg").height;
// If scroller is taller than stage height, set its y position to the very bottom
if ((_grabber.y + _grabber.getChildByName("bg").height) > _tH) _grabber.y = _tH - _grabber.getChildByName("bg").height;
// If content height is less than stage height, set the scroller y position to 0, otherwise keep it the same
_grabber.y = (_cH < _tH) ? 0 : _grabber.y;
// If content height is greater than the stage height, show it, otherwise hide it
this.visible = (_cH + 8 > _tH);
// Distance left to scroll
_scrollValue = _tH - _grabber.getChildByName("bg").height;
_content.y = Math.round(-((_cH - _tH) * (_grabber.y / _scrollValue)) + _defaultPosition);
positionGrips();
if(_content.height < stage.stageHeight) { stage.removeEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelListener); } else { stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelListener); }
//============================================================================================================================
private function positionGrips():void
//============================================================================================================================
_grabberGrip.y = Math.ceil(_grabber.getChildByName("bg").y + (_grabber.getChildByName("bg").height / 2) - (_grabberGrip.height / 2));
_grabberArrow1.y = _grabber.getChildByName("bg").y + 8;
_grabberArrow2.y = _grabber.getChildByName("bg").height - 8;
//============================================================================================================================
// CREATORS
//============================================================================================================================
//============================================================================================================================
private function createTrack():void
//============================================================================================================================
_track = new Sprite();
var t:Sprite = new Sprite();
t.graphics.beginFill(_trackColor);
t.graphics.drawRect(0, 0, _trackThickness, _trackThickness);
t.graphics.endFill();
_track.addChild(t);
addChild(_track);
//============================================================================================================================
private function createGrabber():void
//============================================================================================================================
_grabber = new Sprite();
var t:Sprite = new Sprite();
t.graphics.beginFill(_grabberColor);
t.graphics.drawRect(0, 0, _grabberThickness, _grabberThickness);
t.graphics.endFill();
t.name = "bg";
_grabber.addChild(t);
if(_hasShine)
var shine:Sprite = new Sprite();
var sg:Graphics = shine.graphics;
sg.beginFill(0xffffff, 0.15);
sg.drawRect(0, 0, Math.ceil(_trackThickness/2), _trackThickness);
sg.endFill();
shine.x = Math.floor(_trackThickness/2);
shine.name = "shine";
_grabber.addChild(shine);
addChild(_grabber);
//============================================================================================================================
private function createGrips():void
//============================================================================================================================
_grabberGrip = createGrabberGrip();
_grabber.addChild(_grabberGrip);
_grabberArrow1 = createPixelArrow();
_grabber.addChild(_grabberArrow1);
_grabberArrow2 = createPixelArrow();
_grabber.addChild(_grabberArrow2);
_grabberArrow1.rotation = -90;
_grabberArrow1.x = ((_grabberThickness - 7) / 2) + 1;
_grabberArrow2.rotation = 90;
_grabberArrow2.x = ((_grabberThickness - 7) / 2) + 6;
//============================================================================================================================
private function createGrabberGrip():Sprite
//============================================================================================================================
var w:int = 7;
var xp:int = (_grabberThickness - w) / 2;
var t:Sprite = new Sprite();
t.graphics.beginFill(_gripColor, 1);
t.graphics.drawRect(xp, 0, w, 1);
t.graphics.drawRect(xp, 0 + 2, w, 1);
t.graphics.drawRect(xp, 0 + 4, w, 1);
t.graphics.drawRect(xp, 0 + 6, w, 1);
t.graphics.drawRect(xp, 0 + 8, w, 1);
t.graphics.endFill();
return t;
//============================================================================================================================
private function createPixelArrow():Sprite
//============================================================================================================================
var t:Sprite = new Sprite();
t.graphics.beginFill(_gripColor, 1);
t.graphics.drawRect(0, 0, 1, 1);
t.graphics.drawRect(1, 1, 1, 1);
t.graphics.drawRect(2, 2, 1, 1);
t.graphics.drawRect(1, 3, 1, 1);
t.graphics.drawRect(0, 4, 1, 1);
t.graphics.endFill();
return t;
//============================================================================================================================
// LISTENERS
//============================================================================================================================
//============================================================================================================================
private function mouseWheelListener(me:MouseEvent):void
//============================================================================================================================
var d:Number = me.delta;
if (d > 0)
if ((_grabber.y - (d * 4)) >= 0)
_grabber.y -= d * 4;
else
_grabber.y = 0;
if (!_grabber.willTrigger(Event.ENTER_FRAME)) _grabber.addEventListener(Event.ENTER_FRAME, scrollContent);
else
if (((_grabber.y + _grabber.height) + (Math.abs(d) * 4)) <= stage.stageHeight)
_grabber.y += Math.abs(d) * 4;
else
_grabber.y = stage.stageHeight - _grabber.height;
if (!_grabber.willTrigger(Event.ENTER_FRAME)) _grabber.addEventListener(Event.ENTER_FRAME, scrollContent);
//============================================================================================================================
private function onDownListener(e:MouseEvent):void
//============================================================================================================================
_pressed = true;
_grabber.startDrag(false, new Rectangle(0, 0, 0, _stageH - _grabber.getChildByName("bg").height));
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveListener, false, 0, true);
TweenFilterLite.to(_grabber.getChildByName("bg"), 0.5, { tint:_grabberPressColor } );
//============================================================================================================================
private function onUpListener(e:MouseEvent = null):void
//============================================================================================================================
if (_pressed)
_pressed = false;
_grabber.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveListener);
TweenFilterLite.to(_grabber.getChildByName("bg"), 0.5, { tint:null } );
//============================================================================================================================
private function onMouseMoveListener(e:MouseEvent):void
//============================================================================================================================
e.updateAfterEvent();
if (!_grabber.willTrigger(Event.ENTER_FRAME)) _grabber.addEventListener(Event.ENTER_FRAME, scrollContent, false, 0, true);
//============================================================================================================================
private function onTrackClick(e:MouseEvent):void
//============================================================================================================================
var p:int;
var s:int = 150;
p = Math.ceil(e.stageY);
if(p < _grabber.y)
if(_grabber.y < _grabber.height)
TweenFilterLite.to(_grabber, 0.5, {y:0, onComplete:reset, overwrite:1});
else
TweenFilterLite.to(_grabber, 0.5, {y:"-150", onComplete:reset});
if(_grabber.y < 0) _grabber.y = 0;
else
if((_grabber.y + _grabber.height) > (_stageH - _grabber.height))
TweenFilterLite.to(_grabber, 0.5, {y:_stageH - _grabber.height, onComplete:reset, overwrite:1});
else
TweenFilterLite.to(_grabber, 0.5, {y:"150", onComplete:reset});
if(_grabber.y + _grabber.getChildByName("bg").height > _track.height) _grabber.y = stage.stageHeight - _grabber.getChildByName("bg").height;
function reset():void
if(_grabber.y < 0) _grabber.y = 0;
if(_grabber.y + _grabber.getChildByName("bg").height > _track.height) _grabber.y = stage.stageHeight - _grabber.getChildByName("bg").height;
_grabber.addEventListener(Event.ENTER_FRAME, scrollContent, false, 0, true);
//============================================================================================================================
private function onAddedToStage(e:Event):void
//============================================================================================================================
stage.addEventListener(Event.MOUSE_LEAVE, stopScroll);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelListener);
stage.addEventListener(Event.RESIZE, onStageResize, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, onUpListener, false, 0, true);
_grabber.addEventListener(MouseEvent.MOUSE_DOWN, onDownListener, false, 0, true);
_grabber.buttonMode = true;
_track.addEventListener(MouseEvent.CLICK, onTrackClick, false, 0, true);
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
_stageW = stage.stageWidth;
_stageH = stage.stageHeight;
adjustSize();
//============================================================================================================================
private function onStageResize(e:Event):void
//============================================================================================================================
_stageW = stage.stageWidth;
_stageH = stage.stageHeight;
adjustSize(); -
Multiple movieclips and mutiple event handling.
Hi All,
I have multiple movieclips(images sequence), which I want to add mouseevent (click and drag), keyboard event(left and right arrows) and zoom event(mouse wheel).
I have this function for only one mc(one image sequence).
Now if I use this function, I am having problem with calling the function from the same frame.
That is,
If click another mc from say frame 3, and click on another function, it should continue from frame 3 only, not start from first frame again.
Please help.
Thanks in advance.I assume that shows the part where you rotete the house view in a 360degree fashion?
if so, make a global var on your root timeline:
var rotationframe:int = 1; //in the beginning of the app all the dirffernt images are sitting on frame 1
you can access this var from anywehere inside any function of your app by calling:
root.rotationframe
now in the function that handles the rotation (lets say its your keyboard function) in the end (after you moved the playhead) you make sure to always set
root.rotationframe = garage.currentFrame;
and in the function that handles the switching between images you write sth. like
gotoAndStop(root.rotationframe);
Be aware, you can`t simply use that code without adapting it to your special needs. -
Masking multiple layers to achieve some effects
Hi,
I understand (at least a little) about how masking works. As far as I see it reveals layer underneath it.
What I am wondering if there is some ways to reveals different(multiple layers) layers or masking is done only on one layer.
I have searched and some pages suggest it is possible to mask multiple layers but it doesnt actually show any examples or step by step tutorials.
Any help would be appreciated,http://lmgtfy.com/?q=flash+masking+multiple+layers
The Help on masking has a heading "Mask additional layers after creating a mask layer" that might point you in the right direction. -
Exclusion mask - multiple exclusions
Hello Experts,
I've a folder where 4 types of CSV files will be put in:
REC.5499740508504.541448800xxxx.<timestamp>.csv
REC.5499740508504.541448900xxxx.<timestamp>.csv
REC.5499740508504.54144969999xx.<timestamp>.csv
REC.5499740508504.541449000xxxx.<timestamp>.csv
2 of those types must be picked up by the sender adapter:
REC.5499740508504.541448900xxxx.<timestamp>.csv & REC.5499740508504.54144969999xx.<timestamp>.csv
So, I filled in my Unix source directory and File Name: REC*
Afterwards, I filled in the Exclusion Mask: REC.5499740508504.541448800*
And I added a line:
Directory: same as source directory
File Name Mask: same as File Name: REC*
Exclusion Mask: REC.5499740508504.541449000xxxx.<timestamp>.csv (the other one I filled in with the Exclusion Mask above)
This does not work. Can I add multiple exclusion masks without explicitly add directory lines?
Thanks a lot
DimitriHi,
Try this config.
Give *.txt in filename. and Directory as <YourDir>
In exclusion mask give 111ACC.txt
Below this there will be a table. Add two Entries
Dont add anything to FilenameMask.
Directory ->FileNameMask--->ExclusionMask
<yourDir>->--->111INV.txt
<YourDir>->--->111PUR.txt
Try this and get back.
Regards,
Sudharshan
Message was edited by:
Sudharshan Aravamudan -
Play multiple MovieClips videos in sequence
Hi,
I've multiple videos stored as MovieClip objects and would like to merge them into a single MovieClip video object in order to play all of them in sequence (so that a user thinks it's a single longer video). Is it possible?
Thanks a lot!yes very possible.
there are a few ways to do this, but this is the route i would go.
if you are good with OOP let me know and i will create the class's for you otherwise, also is there sound involved?
var index:int=0
var getTo:int=0
var currentClipInPlay:MovieClip
var clipsToPlay[LoaderA,LoaderB,LoaderC,LoaderD] //assuming these are your loaders of the movieCLips
function beginPlaying(start:,finish:int){
var startPlayingMovie:MovieClip=turnInToMc(start)
index=start
getTo=endValue
assumePlay( startPlayingMovie)
protected function assumePlay(starting:MovieClip){
if(index<getTo){
addChild(starting)
resume()
}else{
pause()
function turnInToMc(index):MovieCLip{
Loader(clipsToPlay[index]).content as MovieClip
function pause(){
mc:MovieCLip= turnInToMc(index).stop()
removeEventListener(Event.ENTER_FRAME,onFrame)
currentClipInPlay=null
function resume(){
currentClipInPlay=turnInToMc(index)
if(!hasEventListener(Event.ENTER_FRAME)){
addEventListener(Event.ENTER_FRAME,onFrame)
function onFrame(e:Event){
var tFrames=currentClipInPlay.totalFrames
if((currentClipInPlay.currentFrames==tFrames){
stopAndPlayNext(currentClipInPlay)
}else{
currentClipInPlay.nextFrame()
function stopAndPlayNext(mc:MovieClip){
pause()
index++
assumePlay(turnInToMc(index))
removeChild(mc)
mc.gotoAndStop(0)
I'll explain when i get to work what this is -
Multiple MovieClips Loading SWF From Same Array (Posted Code)
Hey there,
I'm currently working on a project that has eight separate movieclips (for loading content) on separate layers. I have placed code in these mc's to randomly draw from the same array of 61 different swf's. Each mc randomizes the array just fine, but here's the problem. The code works great for one instance, but as soon as I add the code (including renaming) to the other mc's, the swf won't load/play. I am not getting an compiler errors, and am kinda stuck as to what the problem may be. Here's an example of the code I'm using. It is the same for each mc, except I'm renaming the variables as well as the instances for each mc. Thanks for any suggestions.
Mike
//filename = new Array("screen1.swf","screen2.swf","screen3.swf","screen4.swf","screen5.swf","screen6.swf" ,"screen7.swf","screen8.swf","screen9.swf","screen10.swf","screen11.swf","screen12.swf","s creen13.swf","screen14.swf","screen15.swf","screen16.swf","screen17.swf","screen18.swf","s creen19.swf","screen20.swf","screen21.swf","screen22.swf","screen23.swf","screen24.swf","s creen25.swf","screen26.swf","screen27.swf","screen28.swf","screen29.swf","screen30.swf","s creen31.swf","screen32.swf","screen33.swf","screen34.swf","screen35.swf","screen36.swf","s creen37.swf","screen38.swf","screen39.swf","screen40.swf","screen41.swf","screen42.swf","s creen43.swf","screen44.swf","screen45.swf","screen46.swf","screen47.swf","screen48.swf","s creen49.swf","screen50.swf","screen51.swf","screen52.swf","screen53.swf","screen54.swf","s creen55.swf","screen56.swf","screen57.swf","screen58.swf","screen59.swf","screen60.swf","s creen61.swf");
//i = filename.length;
//k=random(i)
//_root.movieTarget.loadMovie(filename[k]);
//movieTarget._xscale=80;
//movieTarget._yscale=80;
var fileNames:Array = ["screen1.swf","screen2.swf","screen3.swf","screen4.swf","screen5.swf","screen6.swf","scr een7.swf","screen8.swf","screen9.swf","screen10.swf","screen11.swf","screen12.swf","screen 13.swf","screen14.swf","screen15.swf","screen16.swf","screen17.swf","screen18.swf","screen 19.swf","screen20.swf","screen21.swf","screen22.swf","screen23.swf","screen24.swf","screen 25.swf","screen26.swf","screen27.swf","screen28.swf","screen29.swf","screen30.swf","screen 31.swf","screen32.swf","screen33.swf","screen34.swf","screen35.swf","screen36.swf","screen 37.swf","screen38.swf","screen39.swf","screen40.swf","screen41.swf","screen42.swf","screen 43.swf","screen44.swf","screen45.swf","screen46.swf","screen47.swf","screen48.swf","screen 49.swf","screen50.swf","screen51.swf","screen52.swf","screen53.swf","screen54.swf","screen 55.swf","screen56.swf","screen57.swf","screen58.swf","screen59.swf","screen60.swf","screen 61.swf"]
fileNames.sort(function () {
return Math.round(Math.random());
trace("Random array: " + fileNames);
var currentMovieNum:Number = 0 ;
this.createEmptyMovieClip("container", _root.getNextHighestDepth());
var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mcl.addListener(mclListener);
mclListener.onLoadInit = function(movieTarget:MovieClip) {
trace("Preparing to play: " + fileNames[currentMovieNum]);
movieTarget.loadClip(fileNames[currentMovieNum], container);
movieTarget._xscale=80;
movieTarget._yscale=80;
this.onEnterFrame = function() {
if (currentMovieNum == fileNames.length) {
currentMovieNum = 0;
} else {
if (movieTarget._currentframe == movieTarget._totalframes) {
mcl.loadClip(fileNames[currentMovieNum], movieTarget);
currentMovieNum++;Thanks for taking a look at this. The randomizer seems to work just fine, as here is a sample output from the trace:
Random array: screen47.swf,screen2.swf,screen57.swf,screen21.swf,screen9.swf,screen49.swf,screen36.swf, screen17.swf,screen6.swf,screen59.swf,screen15.swf,screen12.swf,screen33.swf,screen25.swf, screen42.swf,screen22.swf,screen24.swf,screen40.swf,screen11.swf,screen19.swf,screen32.swf ,screen35.swf,screen7.swf,screen39.swf,screen23.swf,screen4.swf,screen1.swf,screen48.swf,s creen31.swf,screen45.swf,screen29.swf,screen18.swf,screen51.swf,screen14.swf,screen34.swf, screen10.swf,screen38.swf,screen26.swf,screen16.swf,screen13.swf,screen55.swf,screen37.swf ,screen44.swf,screen61.swf,screen43.swf,screen20.swf,screen28.swf,screen30.swf,screen56.sw f,screen50.swf,screen54.swf,screen53.swf,screen46.swf,screen58.swf,screen41.swf,screen8.sw f,screen5.swf,screen52.swf,screen3.swf,screen60.swf,screen27.swf
Might you be able to lead me down a better path? I'm currently unable to get this to function for multiple symbols. The previous is the code that I've placed on the first keyframe of a movieclip with an instance name of movieTarget. Works swimmingly for one, but once the code is placed on the other symbols on different layers, it seems to only work on the lowest layer in the project.
M -
Apply bounce to multiple movieclips
Hello there,
I'm having a bit of a problem with a basic game I'm making where I want to have a number of animals which bounce around the stage.. I can't seem to get the code to apply to more than one of my movieclips using a loop.. if I try to apply vx and vy to the individual movieclips then nothing happens.. for now I have the ten movieclips on the stage but only one whichbounces around.. I have managed to get all of them to move but they each stay in their own area of the stage, but I'd like each to bounce around the stage and not interfere which the others movement..
Thanks in advance
public function Bounce()
crosshairs = new Target();
addChild(crosshairs);
init();
private function init():void
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
for(var i = 0; i < 10; i++) {
horse = new Horse();
horse.x = Math.random() * stage.stageWidth;
horse.y = Math.random() * stage.stageHeight;
addChild(horse);
animals.push(horse);
horse.addEventListener(MouseEvent.CLICK, onHorseClick);
vx = Math.random() * 40 - 20;
vy = 10;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
private function onEnterFrame(event:Event):void
crosshairs.x = stage.mouseX;
crosshairs.y = stage.mouseY;
vy += gravity;
horse.x += vx;
horse.y += vy;
var left:Number = 0;
var right:Number = stage.stageWidth;
var top:Number = 0;
var bottom:Number = stage.stageHeight;
if(horse.x + horse.width > right)
horse.x = right - horse.width;
vx *= bounce;
else if(horse.x - horse.width < left)
horse.x = left + horse.width;
vx *= bounce;
if(horse.y + horse.height > bottom)
horse.y = bottom - horse.height;
vy *= bounce;
else if(horse.y - horse.height < top)
horse.y = top + horse.height;
vy *= bounce;
private function onHorseClick(event:MouseEvent):void {
var animal = event.currentTarget;
removeChild(animal);I've slightly changed the code and I think I can see a little better now what is happening with multiple item..
I created a function which I call onEnterFrame, which loops through an array of movieclips and adds the bounce..
The problem is that when ANY of the movieclips hit ANY of the boundaries, ALL of the movieclips react accordingly instead of just the movieclip which has collided with the side of the stage.
Here is my updated code, can anyone see an answer to this ?
private function onEnterFrame(event:Event):void {
startBounce();
private function startBounce():void {
for(var i:uint = 0; i < animals.length; i ++) {
var animal = animals[i];
animal.vy += gravity;
animal.x += vx;
animal.y += vy;
if(animal.x + animal.width > right) {
animal.x = right - animal.width;
vx *= bounce;
else if(animal.x - animal.width < left) {
animal.x = left + animal.width;
vx *= bounce;
if(animal.y + animal.height > bottom) {
animal.y = bottom - animal.height;
vy *= bounce;
else if(animal.y - animal.height < top) {
animal.y = top + animal.height;
vy *= bounce; -
Clip Mask and MovieClip pivot questions
Two more beginner questions:
1) What's the easiest way to invert a clipping mask for a
MovieClip in ActionScript? I tried using a ColorTransformMatrix to
invert the alpha of the mask MovieClip, but it didn't work (looks
like the clip mask simply does nothing where there are no filled
shapes). I would like to add a graphic everywhere EXCEPT within the
area of an animated MovieClip, and due to various requirements I
cannot simply place it behind that MovieClip.
2) Is there a way to set the pivot of a MovieClip in relation
to the animated drawings/frames? It looks like the "origin" of a
movieclip is the lower left-most corner of all the bounding boxes
of all the frames of animation in my MovieClip. So if I set the _x
and _y of a MovieClip in ActionScript to 150,150 it places the
lowerleft-hand corner there instead of what I would like to be
logical center of the MovieClip (say, center of a wheelbase of a
car, or center of the feet of a person, or center of mass of a
rock). I am fine with dialing in an offset, but just wondering if
there is a cleaner way to do it (esp. if I happen to add more
animation frames or replace drawings and the bounding box changes
size).
Thanks,
KenAh, I figured everything out.
1) Actually, the ColorTransformMatrix does work, but I didn't
realize that alpha was 0-255, not 0-1 (you'd think after being
bitten by MovieClip scales being 100 = 100% instead of 1 = 100%,
I'd have guessed, but...). So a ColorTransformMatrix of
(1 0 0 0 0)
(0 1 0 0 0)
(0 0 1 0 0)
(0 0 0 -1 255)
applied to the mask will successfully invert it. Nice.
2) Apparently I had previously messed up grabbing all the
images and dragging them - I had forgotten to turn onion skinning
to "onion all" so that I could actually see everything (all my
images are all on top of each other so it wasn't obvious I didn't
have everything visible). I had been selecting all the frames and
dragging the images around in relation to the registration point,
but only the last 3 frames were actually moving, and they happened
to be a part of the animation I didn't bother triggering while
testing. Oops.
Thanks much for your help.
Ken -
Multiple movieclips with same export for AS names? Possible?
Ls,
Im working on an app for mobile devices.
Since the demensions of some of them, i.e. phones as opposed to tablets, have a much smaller screen, wanted to use different sets of mc's depending on screen size (device dimension wise, not resolution).
So a smaller device would use the mc's with larger gfx so they would still be decipherable and the larger devices could use smaller gfx so to be abale to get a larger part on the screen at the same time
- I could just scale the entire screen clip all the time, but this will slow it down too much i think
- I could create multiple instances and use different names and then sort them out run time in AS, but this would also steal processor time. Im not really for that.
- I could publish multiple versions, depending on device its for. But this would require me to maintain multiple sources on upgrades. I can feel the hurt already.
I was hoping it is possible somehow to export the movieclips as .swf's or something and then sorting out run time wich one to import/use/load.
Then, hopefully i can refer to them in my code with the same name's but they will be different sizes depending on wich i had chosen to include/load.
Makes any sense?
Any info on what's the best way to proceed is highly appreaciated.
Regards,
MacKglad,
I'm not sure I understand what you mean.
I meant: if I use as object creation with as like
mc:movieclip = new someclip();
It had the dimensions it has in the library.
If I then do a
mc.scaleX = mc.scaleY = .75;
It wil change size yes.
But wont this require flash to internally resize it each time it has to paste it onto the screen/ into the canvasbitmap?
Or does it take a snapshot from the Library and use that until te next scale operation?
The reason i ask is because a: i dont know ****, b: if i resize it really small, then resize it large, it seems unaffected by the first resize to small.
So i''m thinking it still uses the same mc source, and rescales it from that all the time.
Wich would afcourse affect performance.
Highest regards,
Mac -
How to Mask Multiple Paths?
I need to apply a single gradient mask to two or more path
layers (which are filled with a color) but I don't see an easy way.
In Photoshop you can apply a layer mask to a folder but that
doesn't work in FW.
I tried grouping the two path layers and applying the mask.
That works but if I want to edit the paths later I have to ungroup
everything and then I lose my mask. How to put it all back together
again without actually redoing the mask eludes me.
Is there an easy way to apply a gradient mask to two or more
path/vector layers?
DaveDaveCon wrote:
> I need to apply a single gradient mask to two or more
path layers (which are
> filled with a color) but I don't see an easy way. In
Photoshop you can apply a
> layer mask to a folder but that doesn't work in FW.
>
> I tried grouping the two path layers and applying the
mask. That works but if
> I want to edit the paths later I have to ungroup
everything and then I lose my
> mask. How to put it all back together again without
actually redoing the mask
> eludes me.
>
> Is there an easy way to apply a gradient mask to two or
more path/vector
> layers?
>
> Dave
>
What might help is Aaron Beall's Object panel:
http://fireworks.abeall.com/extensions/panels/
Jim Babbage - .:Community MX:. & .:Adobe Community
Expert:.
http://www.communityMX.com/
CommunityMX - Free Resources:
http://www.communitymx.com/free.cfm
.:Adobe Community Expert for Fireworks:.
Adobe Community Expert
http://tinyurl.com/2a7dyp
See my work on Flickr
http://www.flickr.com/photos/jim_babbage/ -
_root.page_mc1.lgpd_mc.loadMovie(a[6]);
How do I load the same image in to 6 movieclips?this is what I've done so far. but it's only showing in lgpd_mc. the remaining MC instances are lgpd_1, lgpd_2...
_root.page_mc1.lgpd_mc.loadMovie(a[6]);
for (i=1;i<8;i++){
duplicateMovieClip("_root.page_mc1.lgpd_mc", "_root.page_mc"+i, i+".lgpd_"+i, i);
Maybe you are looking for
-
Why is my executable VI not working with a PCI-6259?
I have bought a PCI-6259 which has referencing trigger capability. I wrote a VI for acquiring the data and tested the VI on my PC that has the full developmental LabView 8.2.1 package installed. The trigger is a 1 volt level that is triggered by a p
-
How to move one table to other schema
Hi; imagine i have one schema A and i create table in this schema as test. Now i have one other schema,name is B. I wanna move my A.test table to B.test2 How i can do it? thanks
-
HT5295 What are the basics of creating and distributing Podcasts?
What are the basics of creating and distributing Podcasts?
-
Connect To Server Hangs Before Prompting For Name And Password
Hi Everyone. Connect to Server hangs for 25 seconds before prompting for name and password. I am trying to access a share on a Windows 2008 R2 domain controller via a Mac running 10.6.8 (Snow Leopard) using SMB. Example: smb://192.168.101.11/sharenam
-
WildCard Certificate for IBCM - SCCM 2012
Hi, I have a Primary Site at the DataCenter. There are 2 MP's installed there. One MP I would like to publish using ISA/TMG for Internet Based Client Management. Can I use a wild card certificate on ISA Server for the same? The MP would have Local Ce