SEARCH YOUR SOLUTION HERE  

Can't addchild within this class?

I may be losing my mind. I am simply trying to add a textfield and addchild to that textfield.

Here is the textfield class
Code: package { import flash.display.*; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; public class TextTween { // public var label:TextField; // public var labelText:String; public function setLabel(str:String) { var labelText:String = str; configureLabel(labelText); } public function configureLabel(labelText:String):void { var tField:TextField = new TextField(); tField.text = labelText; tField.x = 200; tField.y = 200; tField.autoSize = TextFieldAutoSize.LEFT; tField.background = true; tField.border = true; var format:TextFormat = new TextFormat(); format.font = "Verdana"; format.color = 0xFF0000; format.size = 10; format.underline = true; tField.defaultTextFormat = format; // addChild(tField); trace (tField.text); // traces out perfectly } } // end class } // end package
This is how I am calling it from Frame 1
Code: var texty:TextTween = new TextTween(); var blah:String = "blabbers"; texty.setLabel(blah);
Works great until I try to addChild to that textField from either Frame 1 or the class itself. I can trace it perfectly, trace the class, trace the functions, trace everything in the functions but I can not addChild. Ugh. Anybody know whats going on This is scaring me.

Posted On: Thursday 25th of October 2012 09:49:03 PM Total Views:  364
View Complete with Replies




Related Messages:

I'm opening a SWF in flash CS5.5 and i cant export as HTML5 - HELP   (168 Views)
, I need to export a load of SWF files i don't have the original flash files for via Swiffy to HTML5, but i open the SWF in flash and the export to HTML option in commands isn't there, what can i do Please help!
Help! cant type certain characters in input field   (160 Views)
So I have been trying to edit this flash contact form and somthing is wrong. Please help. I cant type some characters into the input fields such as "v" "o" "@" ect. Can some one show me where I am going wrong Files below:- http://bearsdenanglingclub.net/conta...ntact_form.fla http://bearsdenanglingclub.net/conta...ntact_form.swf http://bearsdenanglingclub.net/conta...tact_form.html
I'm opening a SWF in flash CS5.5 and i cant export as HTML5 - HELP   (150 Views)
, I need to export a load of SWF files i don't have the original flash files for via Swiffy to HTML5, but i open the SWF in flash and the export to HTML option in commands isn't there, what can i do Please help!
I cant find array length   (144 Views)
For some reason I can't find an array length at a certain position. var myArray:Array = new Array(); myArray = [1,2,3,4,5,6,7]; trace(myArray[4].length); Error #1069: Property length not found on Number and there is no default value.
cant remove focus from input text field   (151 Views)
I have a swf that is having problems only when I load a movie. someButton.onRelease = function(){ empty_mc.loadMovie("C://maps/"+jpgName_txt.text+".jpg"); } I noticed that the movie does not run right only when the cursor is still bliking in the input text field. I will input text in the input field but the cursor continues to remain in the field even after clicking the "someButton". I tried to change the function to loadMovie("c://maps/"+jpgName_txt.text+".jpg",empty_mc); but is still has a problem. The problem being that when I click another button in the program, sometimes it will not work and othertimes it will. When I remove the input field and hard code the import the loadmovie it works fine. Any idea I'm loosing my hair..........
cant rotate Shape   (142 Views)
i draw rect by using mouse when i click i get x and y when i release mouse i get x2 and y2 and i draw lines to this points and its rect then i want to turn that Shape by 45* and i cant do that because its error " attempted access of inaccessible method rotation through a reference with static type flash.display:Shape " everything works good except that rotation this is part of my code zmieniona.graphics.drawRect(x1,y1,x2-x1,y2-y1); zmieniona.rotation(45); // here is error addChild(zmieniona); would be nice if someone could help me thx for help
[need help]cant get senoculars duplicatemovieclip alternative to work   (124 Views)
I was checking out this tip by senocular post no http://www.kirupa.com/forum/showpost...&postcount=172 page no http://www.kirupa.com/forum/showthre...223798&page=12 I dont know what am I doing wrong, If possible somebody please guide me mycode Code: package { import flash.display.DisplayObject; import flash.geom.Rectangle; /** * duplicateDisplayObject * creates a duplicate of the DisplayObject passed. * similar to duplicateMovieClip in AVM1 * @param target the display object to duplicate * @param autoAdd if true, adds the duplicate to the display list * in which target was located * @return a duplicate instance of target */ public function duplicateDisplayObject(target:DisplayObject, autoAdd:Boolean = false):DisplayObject { // create duplicate var targetClass:Class = Object(target).constructor; var duplicate:DisplayObject = new targetClass(); trace(targetClass) // duplicate properties duplicate.transform = target.transform; duplicate.filters = target.filters; duplicate.cacheAsBitmap = target.cacheAsBitmap; duplicate.opaqueBackground = target.opaqueBackground; if (target.scale9Grid) { var rect:Rectangle = target.scale9Grid; // WAS Flash 9 bug where returned scale9Grid is 20x larger than assigned // rect.x /= 20, rect.y /= 20, rect.width /= 20, rect.height /= 20; duplicate.scale9Grid = rect; } // add to target parent's display list // if autoAdd was provided as true if (autoAdd && target.parent) { target.parent.addChild(duplicate); } return duplicate; } } Code: import duplicateDisplayObject; var newMc = duplicateDisplayObject(oldS, true);//oldS is an on stage mc instance newMc.x = 300; newMc.y = 200; trace (newMc.x); the trace function works, but not able tosee the newMc on stage someone please explain,
image slideshow cant remove previous image   (149 Views)
I have a basic image slide show loading external images that fades out after each image and then I want to load the next image. However I can't figure out how to remove the old image, at the moment when the image fades out you can see all the previous images fading out too. Here is the code I am using: Code: var imageNo:Number = 1; ImageLoad("images/home/" + imageNo + ".jpg",imageHolderMC); // image preloader function ImageLoad(u:String,target){ var targetClip = target; var _loader:Loader = new Loader(); var request:URLRequest = new URLRequest(u); _loader.load(request); targetClip.addChild(_loader); _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); } function loadProgress(event:ProgressEvent):void { var percentLoaded:Number = event.bytesLoaded/event.bytesTotal; percentLoaded = Math.round(percentLoaded * 100); } function completeHandler(event):void { imageHolderMC.alpha = 1; imageHolderMC.addEventListener(Event.ENTER_FRAME, fadeOut); function fadeOut(evt:Event):void { if(imageHolderMC.alpha > 0){ imageHolderMC.alpha -= .02; } else { imageHolderMC.removeEventListener(Event.ENTER_FRAME, fadeOut); imageNo++; ImageLoad("images/home/" + imageNo + ".jpg",imageHolderMC); } } } I think it is something to do with removeChild() but I can't figure out where to put it.
No errrors But cant hear my keyboard   (137 Views)
My enterFrame works but onKeyDown gets nothin' can anyOne see it Code: package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.events.Event; import flash.ui.Keyboard; import flash.events.KeyboardEvent; public class PlayScreen extends MovieClip { var playScreen= new PlayScreenMC(); var ship= new Ship(); //var buttonToIntroScreen:Button1=new Button1("introScreen") // var customEvent:String="" public function PlayScreen():void { addEventListener(Event.ADDED_TO_STAGE, playGame); function playGame():void { playScreen.scaleX=7; playScreen.scaleY=7; playScreen.x=185; playScreen.y=250; addChild(playScreen); playScreen.bumpers_mc.alpha=0; ship.scaleX=2; ship.scaleY=2; ship.x=185; ship.y=250; addChild(ship); stage.addEventListener(Event.ENTER_FRAME,onEnterFrame); stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown); stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUp); trace("eventListeners");//
cant load in IE   (144 Views)
I get a load error popup in IE but not FF. How do I dix this and I have no idea where this errir is Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type. http://www.mymrt.net/cm1/cm1.html
cant view image   (132 Views)
I cant load an image from a class. I have main.as which calls Classplayer.as Classplayer calls ClassMisiile. I cant load an image from ClassMissile . I can load the image in Classplayer and dont know why the image in ClassMissile doesnt appear and it is spelt right and in the correct directory. I dont get an error and the functions work but no image. I cant load an image from a class. I have main.as which calls Classplayer.as Classplayer calls ClassMisiile. I cant load an image from ClassMissile . I can load the image in Classplayer and dont know why the image in ClassMissile doesnt appear and it is spelt right and in the correct directory. I dont get an error and the functions work but no image. Code: //main myplayer=new ClassPlayer(480); myplayer.addEventListener ("variableReached",variable_Handler); myplayer.addEventListener("image_loaded",imageLoadedHandler,false,0,t rue); myplayer.addEventListener("image_loaded2",imageLoadedHandler,false,0, true); addChild( myplayer); //ClassPlayer package { import flash.display.*; import flash.display.Bitmap; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.net.URLRequest; import flash.text.*; import flash.events.MouseEvent; import flash.events.KeyboardEvent; import flash.ui.Keyboard; import flash.text.TextField; import flash.text.TextFieldType; //import flash. import Globalvars; public class ClassPlayer extends Sprite{ private var imgStr:String; private var myx:int; private var myy:int; private var img2:String; private var myx2:int; private var myy2:int; private var sp:Sprite=new Sprite(); private var sp2:Sprite=new Sprite(); private var img1:Bitmap; private var bmp:BitmapData; private var MyImages:Array = []; private var MyBData:Array = []; private var MyBData2:Array = []; private var PointList:Array = []; private var xx:int; private var i,j,k,_x,_y,_posy,_tempX,_tempY:int; private var timej,timei:int; private var mycollision:ClassCollision ; private var mymissile:ClassMissile ; var myText:TextField = new TextField(); var urls:Array = ["scave4.png", "scave5.png", "scave6.png", "scave7.png"]; var urls2:Array = ["scave0.png", "scave1.png", "scave2.png", "scave3.png"]; private var _jump,_isfalling:Boolean; private var _YStartVelocity,jumpCount,_height,_width,_direction,stageHeight:int; private var _jumpFrame,_fallframe:Number; public function ClassPlayer(sheight:int) { Globalvars.vars.level++; Globalvars.vars.level++; Globalvars.vars.level++; i=0; mycollision=new ClassCollision(480 ); stageHeight=sheight; _jump=false; _isfalling=false; _height=32; _width=32; _fallframe=0; _direction=1 timej=0; k=0; for each (var el:String in urls) { var loader:Loader = new Loader; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); loader.load(new URLRequest(el)); trace(el + "dsds"); } for each (var el2:String in urls2) { var loader2:Loader = new Loader; loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded2); loader2.load(new URLRequest(el2)); trace(el2 + "dsds"); } getPoints(); myText.text = "The quick brown fox jumps over the lazy dog"; myText.border = true; myText.wordWrap = true; myText.width = 150; myText.height = 40; myText.x = 740; myText.y = 50; addChild( myText); mymissile=new ClassMissile(32,32,stageHeight); mymissile.addEventListener("missile_loaded",missileLoadedHandler); } private function missileLoadedHandler(e:Event):void { } //Class Missile package { import flash.display.*; import flash.display.Bitmap; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.net.URLRequest; import flash.text.*; import flash.events.MouseEvent; import flash.events.KeyboardEvent; import flash.ui.Keyboard; public class ClassMissile extends Sprite{ private var imgStr:String; private var myx:int; private var myy:int; private var img2:String; private var myx2:int; private var myy2:int; private var sp:Sprite=new Sprite(); private var sp2:Sprite=new Sprite(); private var img1:Bitmap; private var bmp:BitmapData; private var MyImages:Array = []; private var MyBData:Array = []; private var xx:int; private var i,_x,_y:int; private var timej,_direction,_width,_height,speedfire,stageHeight:int; private var _fire:Boolean; var urls:Array = ["missile2.png"]; public function ClassMissile(wwidth:int,hheight:int,sheight) & nbsp;{ _x=100; _y=100; xx=10; i=0; timej=0; speedfire=5; _fire=false; stageHeight =sheight; _width=wwidth; _height=hheight; var loader:Loader = new Loader; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); loader.load(new URLRequest("missile2.png")); } private function imageLoaded(event:Event):void { img1= new Bitmap(event.target.content.bitmapData); &nb sp; addChild(img1); img1.x=_x; img1.y=posY(_y); img1.visible=true; trace("kkk"+ _x+ " y="+_y); dispatchEvent(new Event("missile_loaded")); } public function moveMissile() { _y+=speedfire; img1.y=posY(_y); trace(_y); if (_y>400) { img1.visible =false; _fire=false; trace("end"); } } public function startMissile(sx:int,sy:int) { trace("smssile2"); _x=sx; _y=sy; img1.y=posY(_y); img1.x=_x; _fire=true; }
why cant I access properties???   (237 Views)
so Im having an issue, I have a movieclip in the library with the linkage name:BackgroundClip, so in the constructor I create it, add it to the display list and can even access and modify its properties, which I tested with the x position. Now what im having issues with is getting the stage resize listener to adjust the BackgroundClip instance, bg, to the stages width and height. In the clip is an image, so if someone has a better way of using classes to create full screen liquid gui im all ears! package com.jhannis { import flash.display.MovieClip; import flash.display.Sprite; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.Stage; import flash.events.Event; public class mainInit extends MovieClip { public function mainInit() { stage.addEventListener(Event.RESIZE, onResize); stage.scaleMode = StageScaleMode.NO_SCALE; var bgClip:BackgroundClip = new BackgroundClip; createBackground(); addChild(bgClip); bgClip.x = 50; } public function createBackground():void { /* bgClip.width = stage.stageWidth; bgClip.height = stage.stageWidth;*/ } public function onResize (event:Event):void { // Get the new stage size var sw:Number = stage.stageWidth; var sh:Number = stage.stageHeight; // Then update the children with this new size //bgClip.width = sw; //bgClip.height = sh; } } }
AS3 cant read dynamically generated with PHP   (151 Views)
sorry
Help web site and authouring flash dont work the same cant get intro working   (147 Views)
www.scareymakeup.com I have made this Flash website my first one, a university project. Only it has two scenes. It starts in scene 1, is supposed to jump to scene 2, to show an animated intro then go back. to scene 1. The way this is done is on frame 2 of the flash site the script key frame then gotoAndPlay("Scene 2", "IntroStart"); then key frame, them you have key framed labled home 2 so at the end of the intro (on the skip button has the scropt gotoAndPlay("Scene 1", "Home2"); Now here is the kicker... both the swf and index file do this locally on my computer but not on the uploaded website it just pauses then jumps straight to home to and starts the main site skipping the 'diversion' How do I get it to go to the intro on the web (where some poor kittens meet an unfortunate end) so i have the animation demo as well and the site. Ie its supposed to start, find the divert script, do the animation movie then return a bit ahead to the menu not skip to the menu
Google can or cant see text within complete flash webpages ?   (143 Views)
Is it true that Google cant recognize text paragraphs etc within a flash website Theres been mixed opinions about this whereas im able to see it identifying text within flash homepages that ive made. Is this because the text is also stored into the html counterpart when we hit publish Of this is true then google cant see text in .swf files that contain text but load into a container flash file. Eg. the home page contains the html counterpart. But then hitting enter loads another swf into the original html home page. In other words the file thats been external loaded doesnt have a html counterpart. Then google cant see text thats within those loaded .swf files
[RESOLVED] HELP: cant develop Button action   (142 Views)
I cannot seem to get the Object Actions Panel to display or I just cannot see it for some reason. I am trying to add ActionScript for a button. HELP! RESOLVED: I moved the status/toolbar from the bottom to the side and lo and behold THERS MY Object Panel.
Need help searched google still cant .......   (158 Views)
figure out how to make 2 things or insert 2 things into the flash website i am making. I want to get a calendar and a forum of some kind in my site. How could i achieve this I would like the calendar to have notes or events in it.
cant find basic shatter animation effect   (155 Views)
when you have one shape and then it breaks apart into a bunch of pieces and then comes back together, i know its a built in flash technique i remember from class but now i can't find it anywhere on flash or online. can anyone help please! urgent
cant access var from within class   (286 Views)
hey all, i m having trouble with a private var within a class. the class is composed of 2 methods, one public one private. while in the private method i can access my var, the same code in the public one gives me error #1009. this one works perfectly Code: private function runOnce():void { for(var i:int = 0; i < color.xmlList.length(); i ++) { if(color.xmlList[i].attribute("name") == "grey") { colArr = new Array (color.xmlList[i].attribute("sidePart"), color.xmlList[i].attribute("middlePart"), color.xmlList[i].attribute("sidePart")); ratArr = new Array (color.xmlList[i].attribute("ratio1"), color.xmlList[i].attribute("ratio2"), color.xmlList[i].attribute("ratio3")); gradAct = new CreateGradBox(colArr, [1, 1, 1], ratArr, stageW, stageH); this.addChild(gradAct); gradAct.alpha = 0; this.addChild(gradNext); this.addChild(pattern); FadeIn(gradAct); } } } while this : Code: public function ChangeTo(colorS:String):void { for(var d:int = 0; d < color.xmlList.length(); d++) { if(color.xmlList[d].attribute("name") == colorS) { gradNext.graphics.clear(); colArr = new Array (color.xmlList[d].attribute("sidePart"), color.xmlList[d].attribute("middlePart"), color.xmlList[d].attribute("sidePart")); ratArr = new Array (color.xmlList[d].attribute("ratio1"), color.xmlList[d].attribute("ratio2"), color.xmlList[d].attribute("ratio3")); gradNext = new CreateGradBox(colArr, [1, 1, 1], ratArr, stageW, stageH); FadeIn(gradNext); FadeOut(gradAct); } } } the color var, is declared private on the class in which both methods are situated. Tried also declaring it public but i always get error #1009 any hints would be greatly appreciated
cant pass sprite   (157 Views)
when I pass a sprite variable to a class to place images in it the spite doesnt display all the image as it should. It is unstable. Code: canvas1=new Sprite(); addChild(canvas1); mybackground=new ClassBackGroundtile(canvas1); canvas1.addChild(mybackground); /////////// ///////////////////////// classbackgroundTile private var canvas1:Sprite; public function ClassBackGroundTile(ccanvas1:Sprite...) { canvas1=ccanvas1; ..... //addChild(img1); canvas1.addChild(img1); //this causes the problem