RE: [Flashcoders] spacing horizontal dynamic xml menu textfields
No problem :) This is using AS3. Where do you have problem with? Sid > is this using as2 as im trying to do it in as3 so am a bit confused > > -Original Message- > From: flashcoders-boun...@chattyfig.figleaf.com > [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Sidney de > Koning > Sent: 25 August 2009 15:22 > To: Flash Coders List > Subject: Re: [Flashcoders] spacing horizontal dynamic xml menu textfields > > Yup that is correct. X and width, Y and height. > > Good luck! > > Sid > > On Aug 25, 2009, at 3:36 PM, thomas horner wrote: > >> Hi thanks, so this is for a vertical menu or positioning vertical >> textFields, >> >> i will try and adjust this for horizontal purposes and measure the >> width as >> opposed to the height then? >> >> -Original Message- >> From: flashcoders-boun...@chattyfig.figleaf.com >> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of >> Sidney de >> Koning >> Sent: 25 August 2009 14:22 >> To: Flash Coders List >> Subject: Re: [Flashcoders] spacing horizontal dynamic xml menu >> textfields >> >> Hi Thomas, >> >> Try to do something like this and adjust it to your own needs; >> >> // When you are in a for loop, create new items and and try to measure >> the height of an item. >> // And position items vertically.You need to remember the previous >> item, the fastest way to do this is to have a runningY var declared >> outside the for loop with an initial value of zero. >> //See comments in code for further explanation. >> >> var runningY:Number = 0; >> var OFFSET_X:Number = 20; >> >> for (var index:int = 0; index < 4 ; index++) { >> >> var _textheader:TextField = new TextField( ); >> _textheader.text = "Text"; >> _textheader.autoSize = TextFieldAutoSize.LEFT; >> _textheader.x = _background.x - _background.width / 2 + OFFSET_X; >> // First iteration runningY = 0; >> // Second iteration runningY = 0 + textHeader.height +2; >> textHeader.height = 20 >> // Third iteration runningY = 22 + textHeader.height +2; >> textHeader.height = 40 -- mutiple lines of text >> // Fourth iteration runningY = 64 + textHeader.height +2; >> textHeader.height = 20 >> // Fifth iteration runningY = 86 >> _textheader.y = runningY; >> runningY += _textheader.height + 2; // textheader = 20 >> } >> >> >> >> On Aug 25, 2009, at 3:06 PM, thomas horner wrote: >> >>> >>> >>> Hi all am struggling to position, my textFields generated within my >>> loop >>> from my external xml, >>> >>> >>> >>> i want to evenly space them and as they are dynamic they are all of >>> different sizes. >>> >>> >>> >>> i have run a trace on the loop as follows; >>> >>> >>> >>> trace(navbut.label.width); >>> >>> >>> >>> which gives me the widths of each field how do it add the total of >>> the >>> widths from the loop? to then space them. >>> >>> ___ >>> Flashcoders mailing list >>> Flashcoders@chattyfig.figleaf.com >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> ___ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> ___ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Hire me to do your website, businesscards, presentations or flyers. -- Only those who dare to fail greatly can ever achieve greatly. - Robert F. Kennedy -- Sidney de Koning | Flash Developer/Creative Soul/Multimedialist Funky Monkey Studios | Van Ostadestraat 286 HS | 1073 TW | Amsterdam | e:sid...@funky-monkey.nl | tel: +31(06)24 548336 | fax: +31 (0)84 747 7288 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] spacing horizontal dynamic xml menu textfields
He Thomas, This stuff can be a bit difficult when making the transition. Textfield has a really cool property called textWidth and textHeight, that retruns only the width and height of the actual height :) I have put comment in the code that explain it. Here is an example to demo: var runningX:Number = 0; // This is basically your data comming from XML var itemsArr:Array = new Array("one", "different length", "piece of text", "last bit", "evently spaced"); // It does not really matter what kind of loop you do, it is the way of spacing them thst matters, so you can do your loop like you normally would, // here i'm just using an array to demonstrate for (var index:int = 0; index < itemsArr.length ; index++) { // You create items of any kind you like... var _textheader:TextField = new TextField( ); _textheader.text = itemsArr[index]; _textheader.autoSize = TextFieldAutoSize.LEFT; // You say that runningX is some value. since it was zero in the beginning we are adding the value ontop of its current value (see line below) _textheader.x = runningX; // ... And then you space them. You can use textWidth if using text width or plain width for object that extend from DisplayObjects or Sprites etc... runningX += _textheader.textWidth + 20; // +10 is the offset between the items you want ot use. Can be any number. // And then you add the child to the display list so it becomes visible. addChild(_textheader); } Any questions, just ask :) Cheers, Sid > im using it with in the gaia framework do you know it? below is my loop > and > 'navbut.x' is what im trying to find, i need to add all the widths of all > the dynamic textfields sequentially and then space them out evenly > horizontally , > > im just totally stuck! > > > for each (var section:XML in siteNav.section) { > > navbut = new navItem(); > > > navbut.label.autoSize=TextFieldAutoSize.LEFT; > > > //Insert the menu text (li...@name reads the > link's "name" attribute) > navbut.label.text=secti...@name; > //Assign an url to a menu item > navbut.linkto=secti...@src; > navbut.keepopen=secti...@keep; > navbut.isclicked=secti...@highlight; > > //Insert the menu button to stage > > navbut.y=0; > > trace(total); > > navbut.x= ?; > > nav1.addChild(navbut); > > > //Make the button look like a button (hand > cursor) > navbut.buttonMode=true; > navbut.mouseChildren=false; > navbut.alpha=0; > navbut.name=secti...@url; > TweenMax.to(navbut, 0.5, {alpha:1}); > //Add event handlers (used for animating the > buttons) > > navbut.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); > > navbut.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); > navbut.addEventListener(MouseEvent.CLICK, > mouseClickHandler); > > > //trace(navbut.x); > > //Increment the menu button counter, so we > know how many buttons there are > i++; > } > } > > -Original Message- > From: flashcoders-boun...@chattyfig.figleaf.com > [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Sidney de > Koning - Funky Monkey Studios > Sent: 25 August 2009 15:52 > To: Flash Coders List > Subject: RE: [Flashcoders] spacing horizontal dynamic xml menu textfields > > No problem :) > This is using AS3. Where do you have problem with? > > Sid > > >> is this using as2 as im trying to do it in as3 so am a bit confused >> >> -Original Message- >> From: flashcoders-boun...@chattyfig.figleaf.com >> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Sidney >> de >> Koning >> Sent: 25 August 2009 15:22 >> To: Flash Coders List >> Subject: Re: [Flashcoders] spacing horizontal dynamic xml menu >> textfields >> >> Yup that is correct. X and width, Y and height. >> >> Good luck! >> >> Sid >> >> On Aug 25, 2009, at 3:36 PM, thomas horner wrote: >> >>> H
Re: [Flashcoders] Detect iPhone version
Hi Kevin, I think its Capabilities.os (http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/system/Capabilities.html#os) And the properties you were taling about; Capabilities.touchscreenType are only available in AIR 2.5 for Android prerelease but this is going live tomorrow ;) Have fun! Sidney > No way to tell? > > Kevin N. > > > On 10/2/10 3:06 AM, Kevin Newman wrote: >> Hi, >> Anyone know how to detect the iPhone version a Flash CS5 iPhone app is running on? I have a game that runs at 59.1 FPS on a 3GS or ~45FPS on an older iPod touch. >> I'd like to be able to detect which device the app is running on, so I can throttle back the FPS, to 30 or 40 on slower hardware (30 for iPhone 3G which is slightly less powerful on paper, than iPod touch 2g). >> BTW, the frameskip feature isn't very smooth (I'm using the >> ENTER_FRAME/stage.invalidate()/RENDER method). >> Thanks, >> Kevin N. > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Sidney de Koning - "If you're not prepared to be wrong, you'll never come up with something original" Flash / AIR Developer @ www.funky-monkey.nl Actionscript 3 Teacher @ www.sae.nl Technical Writer @ www.insideria.com Blogger @ www.funky-monkey.nl/blog/ 3GB free storage you can sync with your mobile device or Mac or PC. Check out https://www.getdropbox.com/referrals/NTI1MjcxMzk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] getPixel32 - get alpha value
Hi Karim, Something along the lines of this: var bmd:BitmapData = new BitmapData(80, 40, true, 0xFF44AACC); var pixelValue:uint = bmd.getPixel32(0, 0); var alphaValue:uint = pixelValue >> 24 & 0xFF; var red:uint = pixelValue >> 16 & 0xFF; var green:uint = pixelValue >> 8 & 0xFF; var blue:uint = pixelValue & 0xFF; trace(alphaValue.toString(16)); // ff trace(red.toString(16)); // 44 trace(green.toString(16)); // aa trace(blue.toString(16)); // cc Also check http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#getPixel32%28%29 Cheers, Sidney > Hello All - > > anyone can point me in the right direction to get the alpha component of > getPixel32 ? > > Thanks > > > Karim > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Sidney de Koning - "If you're not prepared to be wrong, you'll never come up with something original" Flash / AIR Developer @ www.funky-monkey.nl Actionscript 3 Teacher @ www.sae.nl Technical Writer @ www.insideria.com Blogger @ www.funky-monkey.nl/blog/ 3GB free storage you can sync with your mobile device or Mac or PC. Check out https://www.getdropbox.com/referrals/NTI1MjcxMzk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Calling an element in an Array as an Class
Hi List, I want to load some bitmap images, so i have created a class with embed meta data in it, and i wrote a function to get them out and use them. But it does not seem to work. Can you use the 'new' keyword for an element in an Array? Code below: public class CarAssets { [Embed(source="img/pro_car.png")] private static const PRO_CAR : Class; public static const ALL_CARS:Array = [PRO_CAR]; public static function getAsset( index:uint ):Bitmap { return Bitmap( new ALL_CARS[index]() as Class ); } } } I need some help (the code rather than me) because when i do: var carImage:Bitmap = CarAssets.getAsset( _index ); it fails. Or does anybody know a better method? Cheers, Sidney -- Sidney de Koning - "If you're not prepared to be wrong, you'll never come up with something original" Flash / AIR Developer @ www.funky-monkey.nl Actionscript 3 Teacher @ www.sae.nl Technical Writer @ www.insideria.com Blogger @ www.funky-monkey.nl/blog/ 3GB free storage you can sync with your mobile device or Mac or PC. Check out https://www.getdropbox.com/referrals/NTI1MjcxMzk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Calling an element in an Array as an Class
Hi Michael, Thanks for the tip, normaly i would to, its just that this particular project has already set its course on using the EMBED method. Stubborn as i am, i still want to crack this nut :) So does anybody know how to accomplish this? Greets, Sid >> Or does anybody know a better method? > > I recently started using LoaderMax for loading assets. I will never ever > look back to manually loading my assets. :-) > http://blog.greensock.com/loadermax/ > > - Michael M. > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Sidney de Koning - "If you're not prepared to be wrong, you'll never come up with something original" Flash / AIR Developer @ www.funky-monkey.nl Actionscript 3 Teacher @ www.sae.nl Technical Writer @ www.insideria.com Blogger @ www.funky-monkey.nl/blog/ 3GB free storage you can sync with your mobile device or Mac or PC. Check out https://www.getdropbox.com/referrals/NTI1MjcxMzk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling an element in an Array as an Class
Thanks! The double cast was causing the problems. By removing the 'as Class' you can actually make a new instance of what ever in in the array at element n. It works super smooth now :) function getAsset( index:uint ):Bitmap { return Bitmap( new ALL_CARS[index]() as Class ); } Good weekend all! Sidney > Version 1: > > public class EmbedTest extends Sprite { > [Embed(source="clear.png")] > private static const PRO_CAR : Class; > public static const ALL_CARS:Array = [PRO_CAR]; > > public static function getAsset( index:uint ) : Bitmap { > return new ALL_CARS[index](); > } > > public function EmbedTest() { > addChild(getAsset(0)); > } > } > > Version 2: > > public class EmbedTest2 extends Sprite { > [Embed(source="clear.png")] > private static const PRO_CAR : Class; > > public static function getAsset(name : String) : Bitmap { > try { > return new EmbedTest2[name](); > } catch (e:Error) { > trace ("ERROR asset is not accessible " + name); > } > return new Bitmap(); > } > > public function EmbedTest2() { > addChild(getAsset("PRO_CAR")); > addChild(getAsset("PRO_CAR2")); > } > } > > Am 11.02.2011 15:30, schrieb Sidney de Koning - Funky Monkey Studios: >> public static function getAsset( index:uint ):Bitmap { >> >> return Bitmap( new ALL_CARS[index]() as Class ); >> } > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Sidney de Koning - "If you're not prepared to be wrong, you'll never come up with something original" Flash / AIR Developer @ www.funky-monkey.nl Actionscript 3 Teacher @ www.sae.nl Technical Writer @ www.insideria.com Blogger @ www.funky-monkey.nl/blog/ 3GB free storage you can sync with your mobile device or Mac or PC. Check out https://www.getdropbox.com/referrals/NTI1MjcxMzk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders