Jump to content
Search Community

Can't use blitmask's wrap mode

Icecage test
Moderator Tag

Recommended Posts

I seem to have a problem trying to make an infinite scroller by using blitmask's wrap mode. It just won't repeat.

 

private function drawCalendar():void
 {
  for (var i:int = 0; i < 4; i++) //type
  {
var _rowMax:int;
var _curWidth:Number;
switch(i)
{
 case 0:
  _rowMax = 12;
  _curWidth = 100;
  break;
 case 1:
  _rowMax = 31;
  _curWidth = 75;
  break;
 case 2:
  _rowMax = 24;
  _curWidth = 75;
  break;
 case 3:
  _rowMax = 12;
  _curWidth = 75;
  break;
}
for (var j:int = 0; j < _rowMax; j++)
{
 var d:Dimension_Sp = new Dimension_Sp(i, j);
 d.y = 40 * j;
 d.txt.width = _curWidth;
 containerVector[i].addChild(d);
}

containerVector[i].maxValue = _rowMax;
containerVector[i].x = previousWidth;
containerVector[i].graphics.beginFill(0xCCCCCC);
containerVector[i].graphics.drawRect(0, 0, _curWidth, 40 * _rowMax * 3);
containerVector[i].graphics.endFill();
addChild(containerVector[i]);

var blitMask:BlitMask = new BlitMask(containerVector[i], containerVector[i].x, containerVector[i].y, containerVector[i].width, 40, true, true, 0xFFFFFF, true);
blitMask.enableBitmapMode();
blitMask.wrap = true;
blitMask.autoUpdate = true;
blitMask.update(null, true);
blitMask.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
previousWidth += _curWidth;
  }
 }

 private function onClick(e:MouseEvent):void
 {
  var myTarget:Dimension_Container = (e.target).target;
  TweenMax.to(myTarget, 3, { y:-myTarget.maxValue*40} );
 }

Link to comment
Share on other sites

Hi,

 

Perhaps I'm missing something but wouldn't myTarget.maxValue*40 always be the same number every time you click on a particular BlitMask?

 

Can you try something like

 

TweenMax.to(myTarget, 3, { y:"-1000"} );

 

Will that make the BlitMask wrap?

Link to comment
Share on other sites

A few questions:

  1. What version of BlitMask are you using? Please make sure you're using the latest version.
  2. When you say "it doesn't loop back", could you describe what it does do instead? Does everything just disappear?
  3. If you trace() the getBounds() of your object, is it returning what you'd expect? I wonder if you've placed things in your target that stretch its bounds way out. For example, imagine a 100x100 pixel photo inside a Sprite and then a little 1x1 pixel rectangle that is positioned at x:2000, y:2000. That would suddenly make the bounds of that Sprite 2001x2001 whereas maybe you're expecting BlitMask to only care about the 100x100 image and repeat that. Very difficult for us to troubleshoot blind though.
  4. Can you post a very simple example FLA that we can publish on our end? Please don't post your production files - only a very basic example.

Actually, in light of question #3, I noticed that you did a drawRect() on your target and made its height 40 * _rowMax * 3 which appears to me like it might be 3 times higher than the actual content that you placed in there (I can't tell for sure from your code). If that's the case, you'd have a big space that's just filled with 0xCCCCCC which would be included in the wrapped target, thus perhaps when you see that space you're thinking that your other content is failing to wrap. Keep in mind that you can set the wrapOffsetY to a negative number if you want to get rid of that gap.

  • Like 1
Link to comment
Share on other sites

You were right, it's the rectangle.

40 * _rowMax * 3 was leftover of my previous code. The value 3 was because I used 3 containers to make it seamless (before I'm aware of existence of blitmask)

 

Sorry, my bad. Thanks for the reply

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...