Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-27-2009, 04:00 PM   #1
Registered User
Join Date: Nov 2009
Posts: 25
Red face Some guidance on image placement and Flex vs. Flash

Hi gang,

I have been messing with Flash for many years, but have only done a few appreciable applications with it (usually using more "industrial strength" tools).

I am trying to brush the dust off of my chops, as it were, by writing a game in Flash CS4.

To that end, I have a couple of questions that I am hoping someone would be kind enough to shed some light on.

First, the game is a card game, similar to Magic: The Gathering, where the cards have an image and some description text displayed on them. I have created a symbol (a MovieClip) that is exported in frame 1, let's say as BattleCardGfx.

In the symbol, I have a background, which is just a solid color, then two areas of white (with stroked border) where the image and description will go.

In the description area, I have a dynamic text field setup and named "descText."

In the image area is a symbol (a MovieClip) called "cardImage." The symbol is setup in the proper location and sized correctly - in this case X=0, Y=-31, W=100, H=100.

I am reading the deck from an XML file, and placing the data into an instance of a Card (new BattleCardGfx()), and everything works great, except the image. When I place the image it does not appear to be getting put into the bounds specified by the "cardImage" symbol. Here is the code I am using to do it:

ActionScript Code:
public function addImage(loc:String):void {     var imgLoader:Loader = new Loader();                    var img:URLRequest = new URLRequest(loc);     imgLoader.load(img);     basis.cardImage.removeChildAt(0);        basis.cardImage.addChild(imgLoader); }

I remove the existing image (just a place holder from when I built the symbol) and then add the Loader. I am assuming that since "cardImage" is an instance of the symbol that has all of the parameters of where I want the image to appear, adding a child to that should place it in the proper location, but it is not. The image appears down and to the right of the area by about 100 pixels in each direction.

Can someone tell me what I am missing here?

My other question is that since I am not using the timeline at all, it seems this would be a great candidate to do in Flex3, which I would love to do. Can anyone point me to a tutorial where I can learn how I would do things like add items to the Library so I can do the export to make them available to the rest of the code, like you would in Flash?

Thanks a million!!!

Raconteur is offline   Reply With Quote
Old 11-27-2009, 04:13 PM   #2
Registered User
Join Date: Nov 2009
Posts: 25

Ok... so a bit of digging, and I found that the image is getting place right where it should be. It's just that the point of registration is the upper left corner, not the center, and the upper left corner is placed at 0,0, which is the center (reg point) of the card. I offset it by -50 (1/2 the width of the image) in both directions, and viola!

Now, for the Flex bit... any assistance there would be MUCH appreciated!

Raconteur is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 03:45 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.