Jump to content
Search Community

Can't set width or height of added item

Handycam test
Moderator Tag

Recommended Posts

I have an application where I ask the user dimensions of a room and then add 4 walls for them to use as a starting point (so they can tweak the room with drag and drop.

 

protected function buildRoom(event:Event):void {
// get numbers from dialog
var w:Number = event.currentTarget.roomWidth;
var l:Number = event.currentTarget.roomLength;

var origin:Number = gridInc;

trace('creating room '+w+' wide and '+l+' long.');

// get instances of wall objects from XMLListCollection
var wallV1:Object = structural.getItemAt(0);
var wallV2:Object = structural.getItemAt(0);
var wallH1:Object = structural.getItemAt(1);
var wallH2:Object = structural.getItemAt(1);

// wall postions				
wallH1.x = gridInc;
wallH1.y = gridInc;
wallH2.x = gridInc;
wallH2.y = wallV1.height+(gridInc-wallThickness);
wallV1.x = gridInc;
wallV1.y = gridInc;
wallV2.x = wallH1.width+(gridInc-wallThickness);
wallV2.y = gridInc;

var wallH2y:Number = origin + (l * gridInc);
var wallV2x:Number = origin + (w * gridInc);

// first vertical wall
addWall(wallV1, gridInc, gridInc, l, 'vert');
// second vertical wall
addWall(wallV2, wallV2x, gridInc, l, 'vert');

// first horizontal wall
addWall(wallH1, gridInc, gridInc, w, 'horiz');
// second horizontal wall
addWall(wallH2, gridInc, wallH2y, w, 'horiz');

}


/** add a new wall */
protected function addWall(obj:Object, posX:Number, posY:Number, len:Number, wallType:String):void {
var actualLength:Number = len * gridInc;
var stageItem:AddedItem = new AddedItem();
stageItem.source = "images/full/"+obj.img;
stageItem.itemName = obj.name;
var rn:int = Math.floor(Math.random() * 1000);
stageItem.name = obj.name+"_"+rn;
stageItem.addEventListener(Event.COMPLETE, selectMe);
stageItem.x = posX;
stageItem.y = posY;

var item:TransformItem = ws.myManager.addItem(stageItem);
updateItemCount();
}

 

However, I have tried setting the width and/or height of the transform item both after it's added, such as item.height, in which case no items are added (or at least not visible)

and I have tried right before it's added, as in stageItem.height, but then the bounding boxes are sized, not the artwork.

 

What am I missing here?

 

EDIT: BTW, the code posted works great in that the walls are posted, and the positioning is perfect. I just cannot set their size properly.

Link to comment
Share on other sites

I'm not quite sure what AddedItem is or how this chunk of code fits into the greater context of the app. It definitely sounds like a problem with something else in your app, not TransformManager. If you think there's a problem with TransformManager, please go ahead and send me an FLA or Flex project that only has the essential code necessary to demonstrate the issue and I'll take a peek. (don't post the TransformManager files here, though)

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...