Solved

Having trouble with flash builder and masking

Posted on 2011-03-06
3
506 Views
Last Modified: 2012-05-11
I am trying to get an image to move behind a mask in flex.  here is the code:

public function ImageOnStage(bmp:Bitmap)
            {
                  super();

                    var myShape:Sprite = new Sprite();
                  myShape.graphics.lineStyle(1, 0x000000);
                  myShape.graphics.beginFill(0x0000ff);
                  
                  myShape.graphics.lineTo(154.6862, 173.2246);
                  myShape.graphics.lineTo(183.2958, 171.4443);
                  myShape.graphics.lineTo(221.7057, 165.7216);
                  myShape.graphics.lineTo(254.3983, 156.2645);
                  myShape.graphics.lineTo(292.5086, 139.3242);
                  
                  myShape.graphics.lineTo(315.4861, 127.1510);
                  myShape.graphics.lineTo(330.4385, 117.6560);
                  myShape.graphics.lineTo(344.3118, 107.2436);
                  myShape.graphics.lineTo(352.0309, 100.6078);
                  myShape.graphics.lineTo(361.9321, 91.2264);
                  
                  myShape.graphics.lineTo(368.1939, 82.8642);
                  myShape.graphics.lineTo(372.3505, 74.1243);
                  myShape.graphics.lineTo(373.2142, 65.1147);
                  myShape.graphics.lineTo(372.7254, 57.5077);
                  myShape.graphics.lineTo(371.4799, 53.4322);
                  
                  myShape.graphics.lineTo(368.1330, 47.0660);
                  myShape.graphics.lineTo(362.9509, 40.9697);
                  myShape.graphics.lineTo(355.6635, 36.1682);
                  myShape.graphics.lineTo(344.5973, 29.8022);
                  myShape.graphics.lineTo(335.2389, 25.6178);
                  
                  myShape.graphics.lineTo(314.0247, 18.1188);
                  myShape.graphics.lineTo(291.2447, 12.0224);
                  myShape.graphics.lineTo(272.9992, 8.6236);
                  myShape.graphics.lineTo(264.2212, 7.1979);
                  myShape.graphics.lineTo(223.5897, 50.0132);
                  
                  myShape.graphics.lineTo(196.6493, 79.1452);
                  myShape.graphics.lineTo(171.0339, 105.6289);
                  myShape.graphics.lineTo(144.9767, 130.7583);
                  myShape.graphics.lineTo(131.2858, 144.4715);
                  myShape.graphics.lineTo(113.1782, 159.9203);
                  
                  myShape.graphics.lineTo(104.7869, 166.9825);
                  myShape.graphics.lineTo(103.5696, 167.9901);
                  myShape.graphics.lineTo(102.5271, 169.3665);
                  myShape.graphics.lineTo(102.4287, 170.2119);
                  myShape.graphics.lineTo(102.5271, 171.6275);
                  
                  myShape.graphics.lineTo(102.9993, 172.1780);
                  myShape.graphics.lineTo(103.7862, 172.6499);
                  myShape.graphics.lineTo(105.8910, 173.0431);
                  myShape.graphics.lineTo(108.7240, 173.3774);
                  myShape.graphics.lineTo(154.6862, 173.2246);
                  
                  this.addChild(myShape);
                  
                  var bUtil:BitmapUtil =new BitmapUtil();
                  originalBitmap = bUtil.cloneBitmap(bmp);                  
                  this.bitmapImage = bmp;
                  bitmapImage.smoothing = true;
                  this.type = TYPE;
                  ImageOnStage.idCount++;
                  this.idImage = ImageOnStage.idCount+".png";
                  
                  image.mask = myShape;
                  image.startDrag();
}

The issue is the image.startDrag.  It does not work.  How do I make the image scroll behind the mask.  I want the mask to remain fixed.  Anyone?
0
Comment
Question by:mhoard8110
  • 2
3 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35052592
set this and try:
myShape.mouseEnabled = false;
myShape.mouseChildren = false;

Open in new window


Warm Regards
Deepanjan Das
0
 

Author Comment

by:mhoard8110
ID: 35052675
thanks for the post.  the bigger issue I have is the:
                  image.startDrag();
returns an error in flash builder.  

myShape.startDrag();   and
this.startDrag();

work, but image.startDrag does not.
0
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 35052812
I did not find the image variable declared in your code snippet, may be I am missing something here.
I guess image is a Bitmap, so, try adding the image to another sprite and drag the sprite.

Warm Regards
Deepanjan Das
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now