You could keep track of the graphic elements (and their ID's) in an ArrayCollection for accessing later. When adding them to the stage, also add an event listener so when a user clicks on them, you can do some sort of action.
thx 4 ur answer, but:
1) its flex, so no stage
2) adding a marker (bmp/jpg) to the backgroundimage forces me to "merge" them, right? i mean i need to store that image in a database...
im kinda lost..
Yes, the "stage" exists in Flex. Sorry for the reference--think of it as the DisplayList, instead.
Not sure what you mean by merging. I'm assuming you are merely adding a graphic to the display list somewhere and need to refer to that. If you are, in fact, literally merging the pixels together so that you only have one bitmap graphic, I don't know how you would keep any kind of pointer to the merged graphic, because it no longer exists except as part of another graphic. Unless you stored its coordinates before merging it.
Can you provide more detail about how you are merging the graphics? And what needs to happen after that?
sure, and sorry for the confusion.
ok, this would be the steps:
1) user uploads a backgroundimage, eg a floorplan (uploads means storing into a db)
2) whenever the user wants, he needs to be able to "add" markers (predefined icons or little images) to the backgroundimages
3) the markers can have more associated information with them.
so, right now im literally merging the bitmaps :
var mergedData:BitmapData = _data1;
var tx:Number = x
var ty:Number = y
mergedData.draw(_data2, new Matrix(1,0,0,1, tx, ty));
where tx & ty are the mousecoordinates.
but doign this solution, im loosing the "uniquness" of the markers, unless:
1) they have an ID (how?)
2) i store the coordinates in the db too (but what if two markers have the same coordinates?)
so, doing it in memory with Displkaylist would be good, but as soon as i save i loose all the uniquenss due saving / merging?
You could certainly store the mouse coordinates, but I'm thinking instead you probably need to store a polygon as the "hit area" to respond to mouse events. I've never done this.
My first thought is to keep all the graphics separate, and when the user loads the floor plan, reassemble its last state, not merging the bitmap but keeping them discrete so you can add event listeners to them using addEventListener(). Then all you'd have to store is each graphic's unique ID and its x/y location on the floor plan.
Maybe there is someone reading this who has an approach.
I just had another thought, but it involves actually using a hidden map under the floor plan and SQL Server 2008's spatial datatype to store the polygons of the merged bitmaps. But it's probably too much work, and would weigh the app down.
Sorry I could not provide an easy solution for you.
i actually stunbled over flexlib and their imagemap. this looks very promising. dont know yet if i do the merge though.
but thx for sharing ur thougts!