Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bitmap

New Here ,
Jul 21, 2009 Jul 21, 2009

Hello guys !

I have an issue with Bitmap object. I have a photo gallery which I read from an XML file. Each photo has a path, id and description.

When I'm adding the picture to the screen I am doing as follows:


var content:Bitmap = Bitmap(loader.content);

var subContainer:MovieClip = new MovieClip();


subContainer.addChild(content);

My problem is that when I click the bitmap added to the container I must know what picture this is by getting an id. This way I know what gallery I am to open. A bitmap object does not have this property to be set (id and path). I have decided to create a class which extends Bitmap and then add these attributes within this class. So instead of using a bitmap I would use something like:

var content:Picture = new Picture(id,path,Bitmap(loader.content));

subContainer.addChild(content);

Where Picture would be that class with path and id attributes. So when I click image I could get by event.target.id the source and hen take a decision of what gallery to open.

However, this is not working. It returns converson type error.

Can someone help me ??

Thanks !!

TOPICS
ActionScript
535
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2009 Jul 21, 2009

if you create a new movieclip parent for each bitmap, add whatever properties you want (like id and path) to the movieclip.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2009 Nov 15, 2009

Hey check by adding a properties using getter/setter. Try with the code below:

package components
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;

    public class Picture extends Bitmap
    {
        private var _id:Number = 0;
        private var _path:String = '';
        public function Picture(bitmapData:BitmapData=null, pixelSnapping:String=auto, smoothing:Boolean=false)
        {
            super(bitmapData, pixelSnapping, smoothing);
        }
       
        public function get id():Number
        {
            return _id;
        }
        public function set id(value:Number):void
        {
            _id = value;
        }
        public function get path():String
        {
            return _path;
        }
        public function set path(value:String):void
        {
            _path = value;
        }
       
    }
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 15, 2009 Nov 15, 2009
LATEST

go with susrut316's post.

you clearly have an understanding of classes, and adding properties to movieClips is a poor idea in as3.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines