|
-
KoolMoves Moderator
working with bitmaps?
Ok trying to use a bitmap sheet of playing cards but am having trouble getting the bitmapData thing to work..
From the Flash online docs I got the following:
Code:
var linkageId:String = "libraryBitmap";
var myBitmapData:BitmapData = BitmapData.loadBitmap(linkageId);
trace(myBitmapData instanceof BitmapData); // true
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
I modified it for KM as:
I have a Movieclip in the library with a bitmap graphic loaded and the link name is set to 'deck'
Code:
myBitmapData = flash.display.BitmapData.loadBitmap("deck");
var mc = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
But this doesn't work. I check and myBitmapData is undefinded after that first line so something in the first line is wrong or something else needed to make it work.
Anyone shed some light here? (Wilbert?)
-
KoolMoves Moderator
Ah I see part of the problem, From AS docs Notation:
loadBitmap work only with bitmap data, but not with instances of symbol (MovieClip, Button, Graphic) in library.
Therefore, allways for this method use source(imported) bitmaps in library
We cannot load bitmaps into the symbol library...... Looking..........
-
up to my .as in code
pretty sure this:
myBitmapData = flash.display.BitmapData.loadBitmap();
has to be this:
myBitmapData = new flash.display.BitmapData.loadBitmap();
-
KoolMoves Moderator
Ultimately I want to load in a deck of cards on a "sprite sheet" and pull cards to display them when needed.
-
up to my .as in code
Probobly their bitmapdata_puzzle would be a good start towards that. It already slices a master bitmap into whatever dimensions you decide and has the drag and drop (with detection of where) you would most likely need also encompassed and would be the fastest path to the goal (maybe) using existing examples.
Last edited by Chris_Seahorn; 09-13-2006 at 07:17 PM.
-
KoolMoves Moderator
Thanks Chris. Funny thing is that was from MM docs 
Oh and oddly the link you supplied was blocked from the public access connection I'm at right now due to "pornography" Which I thought was funny. Don't know where they get that..... THey are using something called St Bernard filtering software... Odd
-
We cannot load bitmaps into the symbol library...... Looking..........
-> Yes you can through the action script editor.
-
up to my .as in code
No clue. Most likely that software thinks any flash is porno.......beats me.
-
The right syntax is
myBitmapData = flash.display.BitmapData.loadBitmap();
without new. It's a bit confusing since if you want to create a new bitmap, you do need to use new
myBitmapData = new flash.display.BitmapData();
I made the mistake several times adding new while it shouldn't be there and wondering why the bitmap wouldn't load.
Bob is right that you can add bitmaps to the symbol library using the link icon in the actionscript editor.
It works fine.
-
up to my .as in code
-
KoolMoves Moderator
Ok finally back to this topic,
I still can't get this working right. the following code:
Code:
import flash.display.BitmapData;
myImage= BitmapData.loadBitmap("logo")
//myImage=new BitmapData(200,200,false,0xffcc00cc)
this.createEmptyMovieClip("disp",this.getNextHighestDepth());
disp.attachBitmap(myImage,disp.getNextHighestDepth())
works in Flash, both the uncommented loadBitmap and the commented Created bitmap work.
yet in KM it just doesn't work, I know wilbert has done this in his sprite example but I cannot follow his code very well.
Here's what I've got so far:
Code:
//myImage= flash.display.BitmapData.loadBitmap("logo")
myImage=new flash.display.BitmapData(200,200,false,0xffcc00cc)
this.createEmptyMovieClip("disp",this.getNextHighestDepth());
disp.attachBitmap(myImage,disp.getNextHighestDepth())
I do have a bitmap image loaded in the symbol library via the actionscript editor.
Perhaps this is just not the way to go for this project idea.
Last edited by blanius; 11-28-2006 at 02:56 PM.
-
Your code works fine for me Bret.
Are you sure you got the link name of the image right and the movie is exported as flash 8 ?
-
KoolMoves Moderator
Dang it I bet is was export not set again.
-
KoolMoves Moderator
That's not the first time that's gotten me.
-
KoolMoves Moderator
Hey Wilbert, to use this for like a sprite sheet. Do I have to first load a image into a bitmapData object then load that into a movieclip and then copy the part I want to yet another bitmapData object to then copy out to display movieclip?
-
KoolMoves Moderator
Ok getting there, I'm over the bitmap hurdle at least now on to the rest of the game
http://www.bretlanius.com/flash/videopoker.html
Press the button to advance the card
this is just a test output at this point, getting a sheet of playing card graphics cut and put into a clip one at a time as needed.
-
up to my .as in code
Dude...that looks great
-
KoolMoves Moderator
Getting it all working is another matter eh? Can't bear to look at it anymore today. setting it aside for a few days. Need to think about game play and how to handle the cards. I imagine I'll use duplicateMovieClip on the one card I have and then attach a bitmap to each. Long way to go to a finished game.
-
up to my .as in code
Yeah...I magine the math is getting heavy now. It's going to be a winner..no matter how long it takes. Seriously.... that is a beautiful stage.
-
 Originally Posted by blanius
Hey Wilbert, to use this for like a sprite sheet. Do I have to first load a image into a bitmapData object then load that into a movieclip and then copy the part I want to yet another bitmapData object to then copy out to display movieclip?
Hey Bret, I'm not sure reading your other messages after this one means you figured it out or are using a more complex way.
- first load the sprite sheet into a BitmapData object.
- then create a new target bitmap image using new flash.display.BitmapData
- use targetBitmap.copyPixels(spriteSheetBitmap,new flash.geom.Rectangle(sourceX,sourceY,width,height) ,new flash.geom.Point(0,0)) to copy the desired part to the target bitmap.
- attach the target bitmap to a movieclip.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|