Mask And ScrollRect?
Hey everyone
All I want to do is to set a mask on a textfield and then get the new maksed height of the textfield.
1) If I set a normal mask, I still get the full height of the textfield.
2) If I use scrollRect then the height should be the new masked height, but this isn't updated until a a point later in the movie....
How can I set a mask and get the new height of the masked content through .height?
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 12-03-2008, 11:05 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help With ScrollRect
Hey guys ..im trying to make a simple scroller with scrollRect using
import flash.geom.Rectangle;
var container:MovieClip = _root.rowHolder;
goto = 0;
var window:Rectangle = new Rectangle(dynamicWidth, dynamicHeight, measureBox._width, measureBox._height);
rowHolder.scrollRect = window;
..but how do i read the properties... lets say i dont know what dynamicHeoght is.. can i read it somehow? ..by getProperty?`..somthing?
[F8] ScrollRect MC Property
Not an expert flasher by any means -- just a designer forced to try to do new things and figure out how and why.
I'm in URGENT need of implementing a scrollRect (Rectangle property) on a movie clip and from my extensive search on the net I STILL HAVE NOT FOUND a good example from which to learn. Lots of theory -- no good examples.
I need to cache the clip as a bitmap also -- that I can get. I need the movie clip -- lets call it largeMovieClip for now - to scroll, with accelerations and decelerations, to specified locations on the _y axis when a button is pushed.
I have no idea even where to begin???!!!
PLEASE HELP!
Thanks in advance!
ScrollRect MC Properties
Greetings!
FLASH 8 professional version
Not an expert flasher by any means -- just a designer forced to try to do new things and figure out how and why.
I'm in URGENT need of implementing a scrollRect (Rectangle property) on a movie clip and from my extensive search on the net I STILL HAVE NOT FOUND a good example from which to learn. Lots of theory -- no good examples.
I need to cache the clip as a bitmap also -- that I can get. I need the movie clip -- lets call it largeMovieClip for now - to scroll, with accelerations and decelerations, to specified locations on the _y axis when a button is pushed.
I have no idea even where to begin???!!!
PLEASE HELP!
Thanks in advance!
ScrollRect - How Does This Work?
Hi guys.
I am creating some comment boxes and want to use the scrollRect functionality. However, my comments slide up from the bottom.
I create my Rectangle:
Code:
var commentsMask:Rectangle = new Rectangle(0,0,427,400);
Now, I need the masking to be -480... But as soon as I adjust anything to the Rectangle object, all kinds of weird things happen. Flash actually moves my content to a new position all by itself...
It also seems that when I try and move the Rectangle to a negative value, my other content dissappear. Obviously it is the Rectangle that is making it move somewhere... but I don't know where or why.
I can get it to work by adjusting my clips Y point, but that seems like a hack.
Anyone care to explain a little bit for me?
Tali ho!
DisplayObject.scrollRect
I have few questions about DisplayObject.scrollRect:
1. how it actually work? is it automatic setup a mask?
2. when using the scrollRect, will DisplayObjects outside the bounding still get render?
thankyou very much.
[AS3] ScrollRect Weirdness
I'm getting some weird behavior while trying to build a scrollbar in as3. I've applied a scrollRect to the movieclip I want to scroll:
Code:
public function create(targ, w, h):void{
trace('Scrollbar: Create');
this.targ = targ;
this.w = w;
this.h = h;
trace("targ.height is: "+targ.height);
this.targ.scrollRect = new Rectangle(0, 0, this.w, this.h);
trace("targ.height is: "+targ.height);
scrollpos=0;
checkComponents();
}
Both the traces before and after trace out the correct value, in this case 267. However, once I call any sort of mouseEvent (applied to the targ, the arrows used for the scrollbar... etc) it traces the height of targ as 125 - the height of the scrollRect. Is this a bug? Am i missing something about scrollRect?
Thanks,
Sarah
Resetting ScrollRect?
Hey there, Im having an issue with scrollRect. Its all set up and works like a dream, but I cant get it reset properly.
scrollRect moves from a .x of 0 to about 4000.
To reset, I use the following AS
_root.scrollRect.x = 0;
This works fine, and is confirmed by a trace action. However, the scrollRect area doesnt actually move? However, next time the move action is initiated, is goes back to the right place? I dont get it!
Unresponsive ScrollRect
Hey,
I've built a class that extends Sprite and is pretty simple. It has a setImage(obj:Sprite) method, which adds a passed Sprite as a child, then setters and getters for clipWidth and clipHeight. Setting these variables sets the image's scrollRect. Here's the code:
Code:
public function set clipWidth(n:Number):void {
_clippingWidth = n ;
this.scrollRect = new Rectangle(0, 0, _clippingWidth, _clippingHeight);
}
public function get clipWidth():Number {
return _clippingWidth ;
}
public function set clipHeight(n:Number):void {
_clippingHeight = n ;
this.scrollRect = new Rectangle(0, 0, _clippingWidth, _clippingHeight);
}
public function get clipHeight():Number {
return _clippingHeight ;
}
Not exactly rocket science, or so I thought, but it doesn't work. When I tween the clipWidth or clipHeight values, using either a flash Tween or caurina.transitions.Tweener's addTween method, it will work for a little while, then stops. Tracing out the objects scrollRect shows that the scrollRect Rectangle is changing, and is showing the right values, but visually the image doesn't change.
What could I be doing, or not doing, here that would cause this kind of behavior?!
Thanks.
ScrollRect In Thumbs Gallery
Hi to all. I have a gallery with thumbnails. When i click on a thumb a larger picture appears in a big rectangle with a large image item. I want the picture inside the big rect to scroll up down and left right onmousemove. The gallery takes the data from an xml file. The big rect is a mc with a mask. So i want to put actions and make the mc scrollable. I need your help!!! Sorry for my bad english.
How To Get The Height Masked By ScrollRect
Hey,,i was wondering.. immaking a scroller..that uses scrolRect, but the content af the scroller are constantly changing, and the dynamic height of the content is kinda hard to calculate..so i'd rather use content._height.. but when content is masked by scrollRect, it naturally just gives me the masked height.. =/ ..anyone knows?
Which Is Faster CopyPixel() Or ScrollRect()?
Is it better/faster/smoother to use copyPixel() of scrollRect for fast animations?
Is there some way to time those methods beside FPS?
Is there some better way for fast and smooth scroling large bitmaps?
And one more question, does Flash 9 has something like vertical sync, to wait for monitor refresh and than to draw picture?
Repeating/Looping With ScrollRect?
Hello Everybody,
I am sitting here reading the "Flash 8 Action Script Bible" which is pretty great, but I am curious about something concerning the use of "ScrollRect".
Basically I have the code from the book, with some edits to give my code a "scrolling" feel. Here is the code:
Code:
import flash.geom.Rectangle;
import DrawingUtilities;
// create movieclip and embed text inside it
this.createEmptyMovieClip("mTextClip", this.getNextHighestDepth());
var tField:TextField = mTextClip.createTextField("tField",
mTextClip.getNextHighestDepth(), 0, 0, 200, 200);
tField.multiline = true;
tField.wordWrap = true;
tField.autoSize = "left";
// original rectangle to scroll set to 0, 0
mTextClip.scrollRect = new Rectangle(0, 0, 200, 200);
var DuDrawer:DrawingUtilities;
// use loadvars to load the text
var lvText:LoadVars = new LoadVars();
lvText.onData = function(sText:String):Void {
tField.text = sText.substring(0, 5000);
};
lvText.load("http://www.person13.com/asb/lorem_ipsum.txt");
// two movie clip objects to scroll the text.
this.createEmptyMovieClip("mScrollUp", this.getNextHighestDepth());
duDrawer = new DrawingUtilities(mScrollUp);
duDrawer.beginFill(0xFF0000, 100);
duDrawer.beginRectangle(20, 20, 10, 10);
duDrawer.drawPolygon(5, 3, Math.PI / 6, 10, 10);
duDrawer.endFill();
this.createEmptyMovieClip("mScrollDown", this.getNextHighestDepth());
duDrawer = new DrawingUtilities(mScrollDown);
duDrawer.beginFill(0xFF0000, 100);
duDrawer.beginRectangle(20, 20, 10, 10);
duDrawer.drawPolygon(5, 3, -Math.PI / 6, 10, 10);
duDrawer.endFill();
// move these clips to the right side
mScrollUp._x = mTextClip._x + tField._width;
mScrollUp._y = mTextClip._y;
mScrollDown._x = mScrollUp._x;
mScrollDown._y = mTextClip._y + 200 - 20;
// functionality for the buttons
mScrollUp.onRelease = function():Void {
var rctText:Rectangle = mTextClip.scrollRect;
nInterval = setInterval(scroll, 10, 10, rctText.y - 200, "up");
};
mScrollUp.onReleaseOutside = mScrollUp.onRelease;
mScrollDown.onRelease = function():Void {
var rctText:Rectangle = mTextClip.scrollRect;
nInterval = setInterval(scroll, 10, -10, rctText.y + 200, "down");
};
mScrollDown.onReleaseOutside = mScrollDown.onRelease;
function scroll(nScrollAmount:Number, nEndPoint:Number, stDir:String):Void {
// retrieve the current scrollRect value
var rctText:Rectangle = mTextClip.scrollRect;
//update the y property
rctText.y += -nScrollAmount;
// check if the rectangle would scroll the text out of bounds
if (rctText.y <= 0) {
clearInterval(nInterval);
}
else if (rctText.y > mTextClip.tField._height - 200) {
clearInterval(nInterval);
}
else if ((rctText.y > nEndPoint) && (stDir == "down")) {
clearInterval(nInterval);
}
else if ((rctText.y < nEndPoint) && (stDir == "up")) {
clearInterval(nInterval);
}
else {
mTextClip.scrollRect = rctText;
}
}
What I want to do now is make it so that when I get to the end of the text, it will almost loop so that the start of the text is now under what is the "end". It's a lot like a repeating background from the cartoons of yore (see: Flinstones) and it is a big part to something I am working on at the moment.
Thank you very much!
Scrollrect Positioning Problem
On my root level I have a movieclip called main that houses everything I need to scroll. This was the code I was using before on the root level:
Code:
import flash.geom.Rectangle;
var rightWindow:Rectangle = new Rectangle(0, 0, 968, 582);
this.scrollRect = rightWindow;
But now I need to put a movieclip outside of the scrollRect rectangle so I tried changing the code to:
Code:
main.scrollRect = rightWindow
But then the scrollrect is placed at the center registration point. So attempted to move the retangle so the scrollrect is put back in the upper left hand corner. When I do this weird things happen with the positioning and the masking.
does anyone know how to properly position the scroll rect and move it around so you get the contents you want within the mask?
ScrollRect Moving My Sprite
Confused here...If I comment out the scrollRect line then it displays properly but it doesn't scroll. However, if I uncomment scrollRect it scrolls but the playlist and all the stuff in the sprite move to a new location. Why? I just want it to stay there.
ActionScript Code:
var playlist:Sprite = new Sprite();
playlist.graphics.beginFill(0xFFCC00);
playlist.graphics.drawRect(490, 31.8, 300, 375);
playlist.cacheAsBitmap = true;
playlist.scrollRect = new Rectangle(490, 31.8,300,375);
addChildAt(playlist,0);
Setting ScrolLRect Y Property
Hey everyone
I have this code:
Code:
private function moveScrollObject(e:MouseEvent):void
{
var moveNum:Number = 50;
_scrollObject.scrollRect.y += moveNum;
trace(_scrollObject.scrollRect.y); // traces 0 all the time
}
I can't see what my problem is. Even though I plus the scrollRect y property with 50, it keeps tracing 0?
Problems With Printjob And Scrollrect
I have a sprite that has a scrollbar that uses the scrollrect feature. The sprite has several bitmaps and textfields. When I print the outer sprite (The one with the scrollrect) all of the textfields outside the scrollrect are cut after the first line.
In case anyone else is having problems with printing sprites with scrollrects using the bitmap printing option fixes and prints most of the stuff in the sprite. Excluding all textfields outside of the scrollrect. This however can be fixed partially by embedding your fonts.
So now the only problem left is printing multiline textfields that are outside the scrollrect.
P.S. Imho the scrollrect should have nothing to do with the printed area of the sprite because the printJob.addPage has a printarea parameter. What do you think?
ScrollRect And Browser Resizing...
I'm trying to make a full browser webpage that utilizes the scrollRect type of class to pan around a movieclip that contains other movieclips and so on. The problem I run into is that when the browser window is resized that panning doesn't go with it. So panning to all the edges becomes impossible. I've tried a bunch of different stage resizing techniques but none of them give any good results. Here's the actionscript I'm currently working with:
Code:
stop();
import com.McSliderB;
Stage.scaleMode="noScale";
Stage.align="TL";
var stageListener:Object = new Object();
stageListener.onResize = function() {
img._x = Stage.width - img._width;
img._y = Stage.height - img._height;
};
Stage.addListener(stageListener);
var myclip:MovieClip = _root.img;
var myeasing:Number = .9;
var myX:Number = 0;
var myY:Number = 0;
var myviewW:Number = 1440;
var myviewH:Number = 800;
var mystartX:Number = ((myclip._width - myviewW)/2);
var mystartY:Number = ((myclip._height - myviewH)/2);
//new McSlider(yourMovieClip, easing, clipX, clipY, aperature_width, aperature_height, initial_x_Offset, initial_y_Offset);
var nMC:McSliderB = new McSliderB(myclip, myeasing, myX, myY, myviewW, myviewH, mystartX, mystartY);
If anyone could help me out with this I would greatly appreciate it. Thanks!
Scrollrect And ScaleX / ScaleY
Hey guys, i've got a scrollrect on a movieclip, however when i scale the movieclip, my scrollrect rectangle visible area on the screen gets dramatically smaller. is there a way to keep it proportion to the viewable area if my moveclip scales to a larger size?
UIScrollbar With MovieClip.scrollRect
I have an article with text, images, and buttons that I want to scroll.
The site uses UI components for this type of thing already, so I don't want to build my own (like LiveDocs recommends), I want to use the same skins as the rest of the site.
I've searched Google and LiveDocs and can't find a good example of using the UIScrollbar with MovieClip.scrollRect. Though one guys comments say it can be done.
This is what I have so far:
Actionscript Code:
import fl.events.ScrollEvent;import flash.geom.Rectangle;import flash.geom.Point;
var totalHeight:Number = mcArticle.height;var croppedHeight:Number = 418;
var rect:Rectangle;rect = new Rectangle(0, 0, mcArticle.width, croppedHeight);
// Cache the MovieClip as a bitmap to improve performance.mcArticle.cacheAsBitmap = true;
mcArticle.scrollRect = rect;
cmpntScrollBar.setScrollProperties(croppedHeight, 0, totalHeight - croppedHeight);cmpntScrollBar.setSize(cmpntScrollBar.width, croppedHeight);cmpntScrollBar.update();
Then, to handle the UIScrollBar event:
Actionscript Code:
//set scrollbar eventcmpntScrollBar.addEventListener(ScrollEvent.SCROLL , scrollArticle);
function scrollArticle(evt:ScrollEvent){ //I got this from comments on LiveDocs, but it doesn't seem to work. mcArticle._y = -cmpntScrollBar.scrollPosition;}
So when the SWF loads, it does crop my article and the UIScrollBar seems to be setup correctly, but dragging the scrollbar doesn't move the MovieClip.
Thanks for any advice!
Brandon
ScrollRect Crash (how Else To Scroll) (Flash8)
Hi
I am making a side (and up and down) scrolling game. I draw the background in a movieclip once, and use scrollRect to scroll it. (I am using Flash 8)
I am having a few problems.
1 - First and worst is that it keeps crashing both the flash player, and the flash IDE. In a browser it doesn't crash.
2 - If I don't set the scrollRect every frame, the background gets erased by whatever is moving in front of it.
3 - If I set cacheAsBitmap=true for the background, it doesn't scroll at all.
Any ideas why it doesn't work, and what methods do you use to scroll your map/background?
HitTest Hides Inside ScrollRect..?
I have following hitTest on my mc:
Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();
}
} else {
if (this._currentframe>1) {
prevFrame();
}
}
}
hitTest works fine - until I put this scrollRect on it's parent mc:
Code:
web_slide.scrollRect={x:0,y:0,width:250,height:104}
btn_up.onRelease = function () {
if (web_slide.scrollRect.y = web_slide.scrollRect.y ) {
var newpos=web_slide.scrollRect
newpos.y-=53
web_slide.scrollRect=newpos }}
btn_down.onRelease = function () {
if (web_slide.scrollRect.y = web_slide.scrollRect.y - 106 ) {
var newpos=web_slide.scrollRect
newpos.y+=53
web_slide.scrollRect=newpos }}
Here's the funny thing: The scrollRect code also works fine on its own - but when I put the scrollRect on, the hitTest mc hides inside the scrollRect - meaning, the hitTest runs, but the result displays only inside the scrollRect area, and what is supposed to display outside of it (which is practically everything of it) is hidden. How do I get around that?
ScrollRect Crash (how Else To Scroll) (Flash8)
Hi
I am making a side (and up and down) scrolling game. I draw the background in a movieclip once, and use scrollRect to scroll it. (I am using Flash 8)
I am having a few problems.
1 - First and worst is that it keeps crashing both the flash player, and the flash IDE. Sometimes it crashes imediately, an sometimes after some time. In a browser it doesn't crash.
2 - If I don't set the scrollRect every frame, the background gets erased by whatever is moving in front of it.
3 - If I set cacheAsBitmap=true for the background, it doesn't scroll at all.
Any ideas why it doesn't work, and what methods do you use to scroll your map/background?
Getting Height Of Display Content When Using ScrollRect?
Does anybody know how to get the height and width of the content in a display object when using scrollRect.
For example>
Code:
import flash.display.Sprite;
import flash.geom.Rectangle;
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFFCC00);
circle.graphics.drawCircle(200, 200, 200);
addChild(circle);
//display object width and height is 200
circle.scrollRect = new Rectangle(0, 0, 100, 100);
//display object width and height is now 100
The code above creates a 200pix circle and sets the scrollRect for the circle display object to 100pix. So you can only see a quater of the circle.
The height and width of the display object is now the height and width of the scrollRect which is 100. However the height of content (circle) is 200 but I have no way of finding this out.
There is no contentHeight or contentWidth propertys so how am I ment to find out the height and width of the content if I don't know what it is beforehand?
I need to know the content height and width so I know what the max scroll positions are. I need a scrolling solution where the height and width of the display object does not increase when the size of the content increases beond certain values. scrollRect fits the bill perfectly but its all useless if I dont know what the dimentions of the actual content are!
I'm sure there is a solution, please enlighten me!
Determining Original Size After ScrollRect
I'm trying to determine the size of a MovieClip which has a scrollRect. As expected, the _width/_height reflects the size after scrollRect applied, not the original clip. The problem is, that in my testing it appears that scrollRect does not take affect until after the code(frame?) is executed. Example:
import flash.geom.Rectangle;
mc.scrollRect = new Rectangle(0,0,55,55);
trace(mc._width); // 200, or whatever original size is
function onEnterFrame(){
trace(mc._width); // 55
}
The makes it impossible to set the scrollRect to null, measure, then re-apply a clone of the original scrollRect. Am I stuck? Is there any way to determine the original size?
Scrollrect + Dropshadow = Weird Behaviour
http://img.ravenworks.ca/scrollrectDropshadow.html
Mouse around this example to see a clip whose scrollrect automatically changes its height/width every frame according to the mouse's position. At least, in theory!
Move upwards and left slowly, and notice how 'jumpy' the movement of the shape is... sometimes the shadow moves without it, sometimes they both move but the shadow is further than the vector, and sometimes the vector jumps to catch up with where the shadow is!
If I had to guess, I'd say this is a problem with the flash player not hiding the clip where it knows the clip's shadow should be seen, but failing to consider that the vector inside the clip should be hidden anyway... one way or another, are there any known workarounds?
(Is this forum the right place to be posting bug reports, for that matter?)
ScrollRect + Continous Scrolling Help Needed
I have an "mc_appetizers" movie clip set to a scrollRect. I can scroll mc_appetizers up and down with my btn_upscroll and btn_downscroll buttons, but only 10px at a time. How can I make these buttons scroll continuously until the user releases the mouse button or until the movie clip has reached botttom? Here is my code, a conglomeration of various tutorials and forum posts (I'm rather new to this).
Attach Code
import flash.geom.Rectangle;
var container:MovieClip = mc_appetizers;
var window:Rectangle = new Rectangle(0, 0, 215, 215);
container.scrollRect = window;
btn_upscroll.onPress = function() {
var scrollUp = window;
var scrollmax = container._y;
trace(scrollmax);
trace(scrollUp.y);
if (scrollUp.y>scrollmax) {
scrollUp.y -= 10;
container.scrollRect = window;
}
}
btn_downscroll.onPress = function() {
var scrollDown = window;
var scrollmax = 400;
trace(scrollmax);
trace(scrollDown.y);
if (scrollDown.y<scrollmax) {
scrollDown.y += 10;
container.scrollRect = window;
}
}
Edited: 09/04/2007 at 08:40:57 AM by th_k
Image Slider Pan Thing With ScrollRect
I'm not sure if something like this has been posted, I've seen requests, and I've seen versions on this site and other sites - anywho.
I created a class file for this, all you need is one movieclip containing your image. It uses scrollRect vs. masking. One note, I'm placing button events on the image clip itself, so if you want to pan a movieclip that contains buttons, you'll have to create a button clip to handle those events. To initiate:
ActionScript Code:
import com.McSlider;var myclip:MovieClip = _root.img;var myeasing:Number = .5;var myX:Number = 40;var myY:Number = 40;var myviewW:Number = 720;var myviewH:Number = 520;var mystartX:Number = ((myclip._width - myviewW)/2); //want the image to start centeredvar mystartY:Number = ((myclip._height - myviewH)/2); //want the image to start centered//new McSlider(yourMovieClip, easing, clipX, clipY, aperature_width, aperature_height, initial_x_Offset, initial_y_Offset);var nMC:McSlider = new McSlider(myclip, myeasing, myX, myY, myviewW, myviewH, mystartX, mystartY);
To view:
http://flash.creatify.com/experiments/McSlider.html
Download:
http://flash.creatify.com/experiments/McSlider.zip
*****EDIT 09.07.06:
I've uploaded a version that accepts buttons within the movieclip - enjoy:
VIEW:
http://flash.creatify.com/experiments/McSliderB.html
DOWNLOAD:
http://flash.creatify.com/experiments/McSliderB.zip
*****EDIT 12.12.06
I've uploaded a version that with 3 new public methods:
stopMotion();
startMotion();
slideToPoint(x,y);
VIEW:
http://flash.creatify.com/experiments/McPan.html
DOWNLOAD:
http://flash.creatify.com/experiments/McPan.zip
HitTest On Mc Doesn't Work With ScrollRect
I have two pieces of code, that won't work together...
First: this makes a hitTest on an mc to make it run on rollover:
Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();
}
} else {
if (this._currentframe>1) {
prevFrame();
}
}
}
This works - until I put the next part of code inside to make the parent mc scroll:
Code:
web_slide.scrollRect={x:0,y:0,width:250,height:104}
btn_up.onRelease = function () {
if (web_slide.scrollRect.y = web_slide.scrollRect.y ) {
var newpos=web_slide.scrollRect
newpos.y-=53
web_slide.scrollRect=newpos }}
btn_down.onRelease = function () {
if (web_slide.scrollRect.y = web_slide.scrollRect.y - 106 ) {
var newpos=web_slide.scrollRect
newpos.y+=53
web_slide.scrollRect=newpos }}
Each work seperately, but they won't together. How do I get around this?
HELP Problem Scrolling ScrollRect With A ScrollBar
Hope you guys can help me out on this one.
Here's my problem. So I have some actionscript, and it scrolls the scrollRect, but there is a catch. It doesn't completely scroll it. It lets me scroll down until it's halfway and stops. I can still scroll up to the top, but the problem is unerving. I can't find a fix for it. Does anybody know how to fix it or has had a similar problem?
PHP Code:
stop();var maxItem = 10;var numColumns = 1;var leftMargin = 0;var topMargin = 0;var cellWidth = 273.4;var cellHeight = 54;for (var i = 0; i<maxItem+1; i++) { var mc = rssHolder.attachMovie("rssItem", "rssItem_"+i, i); var cellX = i%nbrColumns; var cellY = Math.floor(i/numColumns); mc._x = leftMargin+cellX*cellWidth; mc._y = topMargin+cellY*cellHeight; mc.name.text = "Hi. I'm Item "+i+".";}rssHolder.scrollRect = new flash.geom.Rectangle(0, 0, cellWidth, 122);//Beggining of scrollbar codebar.useHandCursor = dragger.useHandCursor=false;y = dragger._y;maxy = bar._y+bar._height-dragger._height;function moveDragger() { var scrollrect = _root.rssHolder.scrollRect; r = (dragger._y-y)/(bar._height-dragger._height); scrollrect.y = Math.round(r*scrollrect.height); _root.rssHolder.scrollRect = scrollrect;}dragger.onPress = function() { ref = this._parent; this.startDrag(false,this._x,ref.y,this._x,ref.y+ref.bar._height-this._height); id = setInterval(moveDragger, 50);};dragger.onMouseUp = function() { this.stopDrag(); clearInterval(id);};bar.onPress = function() { ref = this._parent; ref.dragger._y = ref._ymouse>ref.maxy ? ref.maxy : ref._ymouse; id = setInterval(moveDragger, 10);};bar.onMouseUp = function() { clearInterval(id);};
Thank you,
motionman95
ScrollRect, Panning, Browser Resizing...
I'm trying to create a webpage where the user pans around to discover the content. Something similar to this website:
http://www.vermeersch.ca/
Just click on explore at the bottom and resize the window and then pan around to see the effect I want.
I used a scrollRect like class to get the panning to work but when the browser window is resized I can't get the panning to cover the whole page like it would if the window was fully open. I've tried a few of the basic onResize type of commands but they didn't produce any good results. I'm guessing the problem is within the class itself. But I'm not really sure what or how to edit it.
Here's my actionscript:
Code:
stop();
import com.McSliderB;
Stage.scaleMode="noScale";
Stage.align="TL";
var stageListener:Object = new Object();
stageListener.onResize = function() {
img._x = Stage.width - img._width;
img._y = Stage.height - img._height;
};
Stage.addListener(stageListener);
var myclip:MovieClip = _root.img;
var myeasing:Number = .9;
var myX:Number = 0;
var myY:Number = 0;
var myviewW:Number = 1440;
var myviewH:Number = 800;
var mystartX:Number = ((myclip._width - myviewW)/2);
var mystartY:Number = ((myclip._height - myviewH)/2);
//new McSlider(yourMovieClip, easing, clipX, clipY, aperature_width, aperature_height, initial_x_Offset, initial_y_Offset);
var nMC:McSliderB = new McSliderB(myclip, myeasing, myX, myY, myviewW, myviewH, mystartX, mystartY);
And here's the actionscript from the class I'm using:
Code:
import mx.utils.Delegate;
import flash.geom.Rectangle;
class com.McSliderB {
private var __mc:MovieClip;
private var __mcp:MovieClip;
private var __ease:Number;
private var __control:MovieClip;
private var __yDiff:Number;
private var __yScale:Number;
private var __yPos:Number;
private var __xDiff:Number;
private var __xScale:Number;
private var __xPos:Number;
private var __imgW:Number;
private var __imgH:Number;
private var __rect:Rectangle;
//new McSlider(yourMovieClip, easing, clipX, clipY, aperature_width, aperature_height, initial_x_Offset, initial_y_Offset);
public function McSliderB(_mc:MovieClip, _ease:Number, _clipX:Number, _clipY:Number, _apertureW:Number, _apertureH:Number, _xoff:Number, _yoff:Number) {
// your clip to pan
__mc = _mc;
// amount of easing - .7 works well
__ease = _ease;
// store the clip's parent in a variable, it will be used for _xmouse, _ymouse
__mcp = __mc._parent;
// get the initial width and height of the images
__imgW = __mc._width;
__imgH = __mc._height;
// position the clip to x, y
__mc._x = _clipX;
__mc._y = _clipY;
// turn on cache
__mc.cacheAsBitmap = true;
// I decided to run the onEnterframe within another clip vs. __mc
// just incase __mc contained an animation or some other onEnterFrame events
__control = __mc.createEmptyMovieClip("controller", __mc.getNextHighestDepth());
// create a new rectangle - position your clip to the offsets and aperature width / height
__rect = new Rectangle(_xoff, _yoff, _apertureW, _apertureH);
// set the clip's scrollRect
__mc.scrollRect = __rect;
// button events to control movement start / stop
__mc.onRollOver = Delegate.create(this,initiateMovement);
__mc.useHandCursor = false;
}
private function killMovement():Void {
delete __control.onEnterFrame;
}
private function initiateMovement():Void {
delete __mc.onRollOver;
__control.onEnterFrame = Delegate.create(this,calcXY);
}
private function calcXY():Void {
// calculate the Y offset / positions
__yDiff = __mcp._ymouse-__mc._y;
__yScale = __yDiff/__rect.height;
__yPos = __yScale*(__imgH-__rect.height);
// calculate the X offset / positions
__xDiff = __mcp._xmouse-__mc._x;
__xScale = __xDiff/__rect.width;
__xPos = __xScale*(__imgW-__rect.width);
// set the rectangles offsets
__rect.x = __xPos-(__xPos-__rect.x)*__ease;
__rect.y = __yPos-(__yPos-__rect.y)*__ease;
__mc.scrollRect = __rect;
//detect hit area
if(!__mc.hitTest(_root._xmouse, _root._ymouse, true)) {
killMovement();
__mc.onRollOver = Delegate.create(this,initiateMovement);
}
}
}
If anyone could help it would be greatly appreciated. Thank you!
ScrollRect Issues In Full Browser Implementation
Hi all.. i thought this would be relatively simple but alas!
i have a parent movieclip which houses a movieclip which has a scrollrect applied.. i load images into the scrollrect and then in my document class on resize am trying to center the conainter movieclip with the scrollrect inside..
unfortunately the holder clip of the scrollRect gets a width equal to the width of all the images etc so i can't use it as a basis for scaling..
has anyone else encountered this or know of a fix..
see code below! ARG!
My Parent and scrollRect MovieClip
ActionScript Code:
public function CollectionImageScroller(imageArray:Array)
{
collectionImageScrollRect = new MovieClip();
collectionImageScrollRect.scrollRect = new Rectangle(0, 0, 0, 0);
collectionImagePathArrayFromXmlLoad = imageArray;
if(collectionImagePathArrayFromXmlLoad.length > 0)
{
collectionImages = new Array();
loadCollectionImage(collectionImagePathArrayFromXmlLoad[0]);
}
else
{
//display no images
}
}
function loadCollectionImage(imageUrl:String):void {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, showLoading);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, initListener);
loader.load(new URLRequest("http://jademichelle.tom.test" + imageUrl));
}
function showLoading(e:Event):void
{
removeEventListener(Event.INIT, showLoading);
loaderIcon = new mcLoaderIcon();
addChild(loaderIcon);
}
function initListener(event:Event):void {
removeChild(loaderIcon);
var currentImage:DisplayObject = loader.content;
maxImageWidth = (maxImageWidth > currentImage.width) ? maxImageWidth : currentImage.width;
maxImageHeight = (maxImageHeight > currentImage.height) ? maxImageHeight : currentImage.height;
currentImage.x = currentImageX;
collectionImageScrollRect.addChild(currentImage);
currentImageX = currentImageX + currentImage.width + 5;
p++;
collectionImages.push(currentImage);
if (p < collectionImagePathArrayFromXmlLoad.length) {
loadCollectionImage(collectionImagePathArrayFromXmlLoad[p]);//create loop
}
if (p == collectionImagePathArrayFromXmlLoad.length) {
//do when done
this.graphics.drawRect(0,0, maxImageWidth, maxImageHeight);
collectionImageScrollRect.scrollRect = new Rectangle(0, 0, (maxImageWidth + 30), maxImageHeight);
addChild(collectionImageScrollRect);
var leftGradBorder:MovieClip = new mcGradBorder();
leftGradBorder.x = -5;
leftGradBorder.height = (maxImageHeight + 5);
addChild(leftGradBorder);
var rightGradBorder:MovieClip = new mcGradBorderRight();
rightGradBorder.x = maxImageWidth - 20;
rightGradBorder.height = (maxImageHeight + 5);
addChild(rightGradBorder);
collectionImageScrollRect.addEventListener(MouseEvent.CLICK, scrollMe);
dispatchEvent(new Event("CollectionImagesLoaded", true, false));
p=0;
}
}
function scrollMe(e:MouseEvent):void
{
rect = collectionImageScrollRect.scrollRect;
trace("rectx" + rect.x + "currentimgindex" + currentImageIndex);
TweenLite.to(rect, 1, {x:(rect.x + collectionImages[currentImageIndex].width + 5),onUpdate:updateScrollRect, onComplete:function() { currentImageIndex++; }});
}
function updateScrollRect()
{
collectionImageScrollRect.scrollRect = rect;
}
My Document Class handling scaling:
ActionScript Code:
function setBackground():void {
if(collectionScroller != null)
{
collectionScroller.width = stage.stageWidth / 3;
collectionScroller.height = stage.stageHeight / 3;
collectionScroller.scaleX <= collectionScroller.scaleY ? (collectionScroller.scaleX = collectionScroller.scaleY) : (collectionScroller.scaleY = collectionScroller.scaleX);
collectionScroller.x = stage.stageWidth / 2 - (collectionScroller.width / 2);
collectionScroller.y = 100;
trace(collectionScroller.CalculatedWidth);
}
}
function positionCollectionImages(e:Event):void
{
removeEventListener("CollectionImagesLoaded", positionCollectionImages);
trace("MOOOOO");
trace("CALCULATED WIDTH " + collectionScroller.CalculatedWidth + " collectionscrollerx" + collectionScroller.x + " collectionscrollerwidth" + collectionScroller.width + " maximagewidth" + collectionScroller.MaxImageWidth);
collectionScroller.x = (stage.stageWidth / 2) - (collectionScroller.CalculatedWidth / 2);
collectionScroller.alpha = 1;
collectionScroller.visible = true;
//TweenLite.to(collectionScroller,1,{alpha:1});
setBackground();
}
ScrollRect Issues In Full Browser Implementation
Hi all.. i thought this would be relatively simple but alas!
i have a parent movieclip which houses a movieclip which has a scrollrect applied.. i load images into the scrollrect and then in my document class on resize am trying to center the conainter movieclip with the scrollrect inside..
unfortunately the holder clip of the scrollRect gets a width equal to the width of all the images etc so i can't use it as a basis for scaling..
has anyone else encountered this or know of a fix..
see code below! ARG!
My Parent and scrollRect MovieClip
Code:
public function CollectionImageScroller(imageArray:Array)
{
collectionImageScrollRect = new MovieClip();
collectionImageScrollRect.scrollRect = new Rectangle(0, 0, 0, 0);
collectionImagePathArrayFromXmlLoad = imageArray;
if(collectionImagePathArrayFromXmlLoad.length > 0)
{
collectionImages = new Array();
loadCollectionImage(collectionImagePathArrayFromXmlLoad[0]);
}
else
{
//display no images
}
}
function loadCollectionImage(imageUrl:String):void {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, showLoading);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, initListener);
loader.load(new URLRequest("http://jademichelle.tom.test" + imageUrl));
}
function showLoading(e:Event):void
{
removeEventListener(Event.INIT, showLoading);
loaderIcon = new mcLoaderIcon();
addChild(loaderIcon);
}
function initListener(event:Event):void {
removeChild(loaderIcon);
var currentImage:DisplayObject = loader.content;
maxImageWidth = (maxImageWidth > currentImage.width) ? maxImageWidth : currentImage.width;
maxImageHeight = (maxImageHeight > currentImage.height) ? maxImageHeight : currentImage.height;
currentImage.x = currentImageX;
collectionImageScrollRect.addChild(currentImage);
currentImageX = currentImageX + currentImage.width + 5;
p++;
collectionImages.push(currentImage);
if (p < collectionImagePathArrayFromXmlLoad.length) {
loadCollectionImage(collectionImagePathArrayFromXmlLoad[p]);//create loop
}
if (p == collectionImagePathArrayFromXmlLoad.length) {
//do when done
this.graphics.drawRect(0,0, maxImageWidth, maxImageHeight);
collectionImageScrollRect.scrollRect = new Rectangle(0, 0, (maxImageWidth + 30), maxImageHeight);
addChild(collectionImageScrollRect);
var leftGradBorder:MovieClip = new mcGradBorder();
leftGradBorder.x = -5;
leftGradBorder.height = (maxImageHeight + 5);
addChild(leftGradBorder);
var rightGradBorder:MovieClip = new mcGradBorderRight();
rightGradBorder.x = maxImageWidth - 20;
rightGradBorder.height = (maxImageHeight + 5);
addChild(rightGradBorder);
collectionImageScrollRect.addEventListener(MouseEvent.CLICK, scrollMe);
dispatchEvent(new Event("CollectionImagesLoaded", true, false));
p=0;
}
}
function scrollMe(e:MouseEvent):void
{
rect = collectionImageScrollRect.scrollRect;
trace("rectx" + rect.x + "currentimgindex" + currentImageIndex);
TweenLite.to(rect, 1, {x:(rect.x + collectionImages[currentImageIndex].width + 5),onUpdate:updateScrollRect, onComplete:function() { currentImageIndex++; }});
}
function updateScrollRect()
{
collectionImageScrollRect.scrollRect = rect;
}
My Document Class handling scaling:
Code:
function setBackground():void {
if(collectionScroller != null)
{
collectionScroller.width = stage.stageWidth / 3;
collectionScroller.height = stage.stageHeight / 3;
collectionScroller.scaleX <= collectionScroller.scaleY ? (collectionScroller.scaleX = collectionScroller.scaleY) : (collectionScroller.scaleY = collectionScroller.scaleX);
collectionScroller.x = stage.stageWidth / 2 - (collectionScroller.width / 2);
collectionScroller.y = 100;
trace(collectionScroller.CalculatedWidth);
}
}
function positionCollectionImages(e:Event):void
{
removeEventListener("CollectionImagesLoaded", positionCollectionImages);
trace("MOOOOO");
trace("CALCULATED WIDTH " + collectionScroller.CalculatedWidth + " collectionscrollerx" + collectionScroller.x + " collectionscrollerwidth" + collectionScroller.width + " maximagewidth" + collectionScroller.MaxImageWidth);
collectionScroller.x = (stage.stageWidth / 2) - (collectionScroller.CalculatedWidth / 2);
collectionScroller.alpha = 1;
collectionScroller.visible = true;
//TweenLite.to(collectionScroller,1,{alpha:1});
setBackground();
}
AS3: Mask Within A Mask (or How To Use A Shape With A Hole In It As A Mask)
Hi guys,
I've been stuck on this AS 3 masking problem for days now. I'm sure there's a simple solution to my problem but it's proving to be a pain.
I have a movieclip that contains some drawings, bitmap, etc. on top of that I am drawing a yellow rectangle with a hole in it using ActionScript:
What I want to achieve is to mask the movieclip container using the yellow rectangle, but I want the hole in the middle to not show the drawings and line:
However what I am actually getting is the yellow rectangle is masking the movieclip, but is ignoring the hole within it:
This is the AS3 code that I've written to get the above effect (with 'maskee' being the movieclip that contains the drawings):
Code:
function drawRectMask(p_sprite:Sprite) : void {
p_sprite.graphics.beginFill(0xf0ff00);
p_sprite.graphics.drawRect(100,100,300, 300);
p_sprite.graphics.moveTo(100,200);
p_sprite.graphics.drawRect(150,150,100, 100);
p_sprite.graphics.endFill();
}
var spr:Sprite = new Sprite();
drawRectMask(spr);
addChild(spr);
maskee.mask = spr ;
I'm at wits end. Any help on this would be greatly appreciated.
Using ScrollRect To Scroll Through "Pages"
Hello.
I am working with the ScrollRect Function and I was wondering how I could make it so when I was to click one of my buttons I would have an animated move to the next "page".
For example, say a page is 100 pixels long, I click a "down" button to move 100 pixels down, but I want the animation, I don't just want to appear at the next 100 pixels. Does anyone know how I could do this?
This is my current code...
Code:
mScrollDown.onRelease = function():Void {
var rctText:Rectangle = mTextClip.scrollRect;
rctText.y += -(-100);
mTextClip.scrollRect = rctText;
};
I did have a scroll function in there that would work with intervals, but the thing would just scroll through my entire "book".
Thank you.
How To Mask Duplicated Movie Clips With A Single Mask?
I have created 11 movie clips 17px in a vertical column.
I have used this code to duplicate them.
ActionScript Code:
for(i=0; i <10; i++){
newName = "softwareBar" + i;
duplicateMovieClip("softwareBar", newName, i);
softwareBar._y += 17;
}
I have a mask that I need to use to cover all the clips, however when I use setmask it only covers the last looped item in the duplicateMovieClip code.
How would I go about masking all the duplicated clips with a single mask?
Not sure if this info is pertinent but once they are masked I will then be animating each duplicated bar separate using this function.
ActionScript Code:
loadBar = function(clipName, amount){
clipName.onEnterFrame = function(){
if(clipName._width<amount){
clipName._width +=speed * speedDim;
}
}
}
Thanks
DDC
Mask Over Mask Leaving Pasrts Covered From Overlap.
Hello,
I have a complex image that I would like to mask with an animated mask.
I am using a movie clip with a couple of layers that "reveal" parts of the complex image at a time.
The problem is, when part of a mask overlaps another, it leaves that part of the complex image covered.
Is there a way around this?
Thanks in advance.
Drag A Mask, With Out Draging The MC Under That I Want To Mask Over?
Hello,
I have a mask and MC button which I am draging. I works fine other the fact the the whole MC movies even the MC inwhich I want to mask over: "BigYears" .
I have tryed to use:
onClipEvent (enterFrame) {
setProperty (this.BigYears, _x, -this._x);
setProperty (this.BigYears, _y, -this._y);
}
Then "BigYears" is not viewable under the mask.
INVERSED Mask? REVERSE Mask?
Okay, here's my dilemma.
I want a small circle to grow to reveal the contents within the circle, and THEN (and this is the hard part) I want another circle to grow from the same starting point that makes shows THROUGH to what's behind the circle.
So
I already have the first part done, where there's the contents on one layer, and a masked circle that tweens to reveal the contents.
BUT, the second part has to reveal the INVERSE of the contents... I don't really know HOW to explain this other than saying I want to punch a hole THROUGH the contents.
Any ideas?
HELP I Need A Mask Guru To Help Me With A Mask Problem
Hi,
I've got two mc's that are suppose to be playing simultaneously. Both duplicate mc's are called "Cloud Motion Tween" and there is one on the main timeline that has a brightness of -55 and the other duplicate of that mc is inside a mask in a mc called "Nav Bar (About)". Both mc's are suppose to be in sync.
Now every time I rollover the "Nav Hit Panel" button the mc inside the mask starts all over again and stuffs up the synchronization of the two mc's.
I have attached the fla file. You'll see what I mean.
Thank you so much for you valued time and effort. You are a true champ!!! (Whoever you are)
Blastbum
HELP I Need A Mask Guru To Help Me With A Mask Problem
Hi,
I've got two mc's that are suppose to be playing simultaneously. Both duplicate mc's are called "Cloud Motion Tween" and there is one on the main timeline that has a brightness of -55 and the other duplicate of that mc is inside a mask in a mc called "Nav Bar (About)". Both mc's are suppose to be in sync.
Now every time I rollover the "Nav Hit Panel" button the mc inside the mask starts all over again and stuffs up the synchronization of the two mc's.
I have attached the fla file. You'll see what I mean.
Thank you so much for you valued time and effort. You are a true champ!!! (Whoever you are)
Blastbum
Dynamic Mask Doesn't Mask...
I have a local radar image that I am loading into a holder movie clip and trying to mask but it doesn't work. Both the image and the mask are being displayed.
The holder movie clip is 'dopplerRad_mc' and I am attaching from the library.
The clip the image is loaded into is 'dopplerHolder_mc' and is dynamically created.
I then attach a mask movie clip from the library, 'imageMask1'.
My code is below. Any idea what I am missing?
var dopplerRad_mc:MovieClip = attachMovie("doppler_mc","dopplerRad_mc", getNextHighestDepth());
var doppler_mc:MovieClip = dopplerRad_mc.createEmptyMovieClip("dopplerHolder_ mc", dopplerRad_mc.getNextHighestDepth());
var mclListener:Object = new Object();
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(mclListener);
mcLoader.loadClip(doppler, dopplerRad_mc.dopplerHolder_mc,1);
dopplerRad_mc.attachMovie("imageMask","imageMask1" ,2);
dopplerRad_mc.dopplerHolder_mc.setMask(dopplerRad_ mc.imageMask1);
Attaching Mask Onto Mask Layer
Hi,
I've been trying to attach a movieclip from the library, to the Mask layer using actionscript so that the mask_mc can hide a line of text as it moves.
But the movieclip is not getting attached to the mask layer.
Please help....
Gradient Mask Using JPEG As Mask
Hi there. I am trying to find a way to use loaded greyscale JPEGs to form gradient masks in Flash. Basically I want to be able to create an opacity mask just like you do in Illustrator or Photoshop, where it's the darkness of each pixel that determines opacity, rather than the alpha value.
It seems that in Flash the only way to create a gradient mask is to use a mask that has varying alpha values. I suppose that means I could use PNG files to form my mask instead, but I really need to be able to do it with JPEGs.
Perhaps there is a BitmapData filter that can convert shades of grey to degrees of alpha?
Thanks :)
Lara.
Mask To Reveal Preloader And Mask To Hide Preloader Upon Load.
Hi all, can anyone help me in regard to a mask over a preloader of elements.
Ok I have a preloader all set up, this includes a logo, a notice, i.e please wait loading in progresss, a load bar, and a percentage reading.
All I want is a simple wipe effect using a mask, which is very easy to achieve, I have done so already. But I am unsure in how to hide all the preloader elements, and how to use the wipe to reveal all elements on the stage / timeline. I have the wipe setup using two layers, and decided to place these inside a movie clip and place the movie clip on the timeline. But now I am stuck in what to do next.
As when everything is loaded I want the wipe to hide the preloader and move onto the design aspects.
Does anyone have an idea how to achieve this?
To Mask Or Not To Mask, That Is The Question
Greetings helpful ones..
I am new to Flash and I need your help with a little project
I need to create an animation of a Car breaking through a brick wall and I am not sure if It is possible to import layers including a mask layer from photoshop into Flash and if so how, or if it is easier to create the mask layer in Flash, not quite sure how to do this either.
The other issue is scaling the image of the car as it will get bigger as it comes out through the wall - ie can I group the mask and image of car together whilst scaling..??
Perhaps you know of a better way to do all this, any help would be much appreciated - What I would really like to have is a 3D effect of the Car skidding round on it's front wheels
Thanks for your time
MN
|