-
Help with aligning text
I guys,
I been given some banners to adapt, unfortunately on not very familiar with AS3 and im trying to align a word to the left but for the life of me i cant figure out what to change. Can anyone please shed some light? I can get letter spacing to work but I can't find an align command.
Actionscript Code:
import flash.events.EventDispatcher; import flash.text.StyleSheet; import flash.text.TextFormatAlign;
public class ScreenTextModelSky extends EventDispatcher implements IScreenTextModel { private static var _inst:ScreenTextModelSky; private static var _text:Array = [ // don't forget to update the embeded characters in the fla! ['<span class="b">Free</span>', 'text', 'text'', 'text''], ['<span class="c">text' ', 'text'</span>', '<span class="d">text'</span> ',], ['<span class="b">text'</span> text'', '<span class="b">text'</span> minutes', '<span class="b">text'</span> text'a'], ['text'', '<span class="b">text'', 'text' </span>', 'text' ', 'text''] ];
private var _style:StyleSheet; public function ScreenTextModelSky(enforcer:Singleton) { } public static function getModel():ScreenTextModelSky { if (_inst==null) _inst = new ScreenTextModelSky(new Singleton()); return _inst; } public function getText(num:uint):Array { return _text[num]; } public function getStyle():StyleSheet { if (_style==null) { _style = new StyleSheet(); var body:Object = { fontFamily: (new FrutigerFont()).fontName, fontSize: 16.5, color: '#FFFFFF' }; var c:Object = { fontFamily: (new FrutigerBoldFont()).fontName, fontSize: 28, letterSpacing: 0 }; var d:Object = { fontFamily: (new FrutigerFont()).fontName, fontSize: 11, letterSpacing: 0 }; var b:Object = { fontFamily: (new FrutigerBoldFont()).fontName }; _style.setStyle('body', body); _style.setStyle('.b', b); _style.setStyle('.c', c); _style.setStyle('.d', d); } return _style; } } }
class Singleton {}
-
Flash/Flex Developer
I would check the style sheet, it appears to be controlling everything here.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
hmmm, It didnt come with the assets? I just assumed it was embedded somewhere?
-
Flash/Flex Developer
You are right. Missed that part. However, I don't see where the text is being displayed. Where does it appear, what component?
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
this is what's in the other .as file
Actionscript Code:
import banner.model.text.IScreenTextModel;
import flash.display.Sprite;
public class ScreenText extends Sprite { protected var _num:uint; protected var _model:IScreenTextModel; protected var _tf:Array = []; public function ScreenText(num:uint) { _num = num; init(); }
protected function init():void { addModel(); for (var i:uint = 0; i<_model.getText(_num).length; i++) { _tf[i] = SimpleTextField.getTextBox(_model.getText(_num)[i], Model.getModel().width, null, true, _model.getStyle()); addChild(_tf[i]); } position(); } protected function addModel():void { trace("WARNING: override and add format's screenText model"); } public function position():void { for (var i:uint = 0; i<_model.getText(_num).length; i++) { _tf[i].x = -_tf[i].width/2; _tf[i].y = _tf[i].height*i+(_tf[i].height/10); _tf[i].alpha = 0; _tf[i].visible = false; } } public function fadeIn():void { for (var i:uint = 0; i<_tf.length; i++) TweenMax.to(_tf[i], 0.3, { delay: i*0.1+0.2, y: _tf[i].y-(_tf[i].height/2), autoAlpha: 1 }); } public function fadeOut():void { for (var i:uint = 0; i<_tf.length; i++) TweenMax.to(_tf[i], 0.3, { delay: i*0.1, y: (-_tf[i].height/2).toString(), autoAlpha: 0 }); }
} }
-
and
Actionscript Code:
package banner.view.content { import banner.view.text.ScreenText; import banner.view.text.ScreenTextSky;
import flash.display.BitmapData; import flash.display.Bitmap;
import banner.view.Phone; import banner.view.PinkPuff;
import flash.display.Sprite;
import banner.view.end.EndScreenSky;
public class ContentSky extends Content { private var _top:Number = 150; private var _phoneBaseHeight:Number; override protected function addModifiers():void { _puffScale = 0.8; } override protected function addPuff():void { var ex:Number = _model.width/2; var ey:Number = _model.height/2; // add phone early for skyscrapper _phoneBox = new Sprite(); _phone = new Phone(); _phoneBaseHeight = _phone.height*_phoneScale; _phoneOffset = ((_h/2)-(_phoneBaseHeight/2+_top))*-1; phoneStartPos(); _holder = new Sprite(); _holder.x = ex; _holder.y = ey; addChild(_holder); _puff = new PinkPuff(ex, ey+_phoneOffset, _puffScale, 0.2, _freeze); _puff.x = -ex; _puff.y = -ey; _holder.addChild(_puff); // init will be called later }
override protected function addPhone():void { _phoneBox.addChild(_phone); _bmp = new Bitmap(); addChild(_bmp); _bmp.bitmapData = new BitmapData(_model.width, _model.height, true, 0); _bmp.bitmapData.draw(_phoneBox); init(); } override protected function addText():void { for (var i:uint = 0; i< 4; i++) { _screens[i] = new ScreenTextSky(i); screenTextSetUp(_screens[i]); } } override protected function screenTextSetUp(screen:ScreenText):void { screen.x = _w/2; screen.y = _top+_phoneBaseHeight+16; addChild(screen); } override protected function addEnd():void { _endScreen = new EndScreenSky(); addChild(_endScreen); } } }
-
Flash/Flex Developer
The position function is what set the new location for all text objects. It appears that the individual textfield dimensions control the position of the text.
Actionscript Code:
public function position():void { for (var i:uint = 0; i<_model.getText(_num).length; i++) { _tf[i].x = -_tf[i].width/2; _tf[i].y = _tf[i].height*i+(_tf[i].height/10); _tf[i].alpha = 0; _tf[i].visible = false; } }
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
Thanks for replying Samac.
So, what exactly would i need to change for the text to align left? Currently it's all centred? Any idea?
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
|