Add link inside Addchild


HI

I have an MC that I want to add to Stage dynamically. Until here everything seems fine:

for (var j:int = 0; j < nomePostosArray.length; j++) {
var MC:MovieClip = new mc();
namelistscroller.text.addChild(MC);
MC.name="newsMc"+j;
trace("newsMc"+j);
MC.y=MC.height*j+MC.y+20*j;
trace(MC.y);
MC.nome.text = j+". "+nomePostosArray[j];
MC.morada.text = moradaPostosArray[j];
MC.codigo.text = codigoPostosArray[j];
MC.contacto.text = contactosPostosArray[j];
MC.mapLink = "http://www.symbolbox.pt";
}

the variable mapLink is inside the MC. This should be a link that should follow when someone press the link button inside MC. This is the only part that is not working. Can anyone give me a hint

Posted On: Thursday 25th of October 2012 10:31:32 PM Total Views:  405
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




Use Loop to add external images to existing MovieClips

Back again with another dumb question. I'm sure there's a dreadfully easy answer, but I've done a ton of searching and can't seem to find it. I have a file with existing MovieClips on the stage that I want to add Loaders to that will call external .jpgs from an XML file. I have the code working, but currently I have to add the Loaders one by one to the MovieClips. I'm sure there's a way to do this more easily by using a Loop, but I can't seem to get it to work no matter what I've tried. I also want to be able to call a larger version of the image by clicking on the MovieClip/thumbnail. I've got the code working just fine, but when I tried to add a preloader to the full size image Loader, I got an error: Error #1009: Cannot access a property or method of a null object reference. Flash indicates this is happening at the callFull function so its definitely an error with my preloader code. I guess, judging by the error message, that I'm trying to reference some object that has stopped existing by that point in the code, but I don't know enough to figure out how to fix it. I'm sure its another simple thing that I've screwed up. Hopefully someone here can help me out with at least one of these problems.
VIEWS ON THIS POST

195

Posted on:

Thursday 25th October 2012
View Replies!

Flash Cannot addChild on stage after EventDispatcher successfully loaded the image???

I am trying to learn how to use EventDispatcher. I create xml gallery where I am loading content via xml. In this particular case, I am not loading a sequence of multiple images. I load just one image. I traced the path to the image location and it is correct. I have a very hard time placing the loaded item to stage. I can trace EventDispatcher functions from EventDispather Class. When I do that, the trace statements confirm that the image is loaded. I am wondering what I should do in order to place the image on stage. I definitely cannot do it from EventDispatcher class directly or I am missing something. Below is my EventDispatcher class. Please help me to find out about the correct technique to add the loaded item on stage after EventDispatcher was run. Below is the class of my EventDispatcher. Any advice is highly appreciated. Any good tutorial link is also a great help for me. Thank you in advance. Code: package net.EvtDisp { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.display.PixelSnapping; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.net.URLRequest; public class UIItems extends EventDispatcher { // The name of the event to be fired when loading the im is finished public static const TYPESH_LOADED:String = "typeShLoaded"; // The loader to be used for loading the original im private var _typeShLoader:Loader = new Loader(); // The original im as a Bitmap private var _typeShowIm:Bitmap; private var _typeS:String; // A URLRequest instance to be used while loading the images private var urlRequest:URLRequest; public function UIItems(_typeSh:String) { trace ("UIItems.as UIItems () Run"); this._typeS = _typeSho; trace ("this._typeS = " +(ConfigManager.TYPESh_DIR+this._typeS)); //loadtypeSh(); //By running loadtypeSh() I can trace if the image was successfully loaded } ///////////////////////////////////////////////////////////////////////////////////////////////////// public function loadtypeSh():void { trace ("UI Item loadtypeSh() Run"); // Start loading the typeSh _typeShLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onTypeShProgress); _typeShLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onTypeShComplete); _typeShLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError); // Start loading the typeSh _typeShLoader.load(new URLRequest(ConfigManager.TYPESh_DIR + _typeS)); //trace (ConfigManager.TYPESH_DIR + _typeS); } ///////////////////////////////////////////////////////////////////////////////////////////////////// //This method is called when loading the typeSh is completed. private function onTypeShComplete(evt:Event):void { trace ("Run dispatchEvent"); // Copy the content of the loader as bitmap var bitmapData:BitmapData = new BitmapData(_typeShLoader.width, _typeShLoader.height, true, 0x00000000); bitmapData.draw(_typeShLoader); _typeShowIm = new Bitmap(bitmapData, PixelSnapping.NEVER, true); //addChild(_typeShowIm); // Fire the event dispatchEvent(new Event(TYPESH_LOADED)); trace (TYPESh_LOADED); } ///////////////////////////////////////////////////////////////////////////////////////////////////// //This method is called during the Type Sh Image loading process. private function onTypeShProgress(evt:ProgressEvent):void { trace ("Run onTypeShProgress"); dispatchEvent(evt); } ///////////////////////////////////////////////////////////////////////////////////////////////////// //This method is called if an error occurs during the loading process. private function onIOError(evt:IOErrorEvent):void { trace ("Run onIOError"); dispatchEvent(evt); } ///////////////////////////////////////////////////////////////////////////////////////////////////// //Returns the original typeSh. /*public function get _typeSh():String { trace ("_typeSh Did"); return _typeS; }*/ public function get typeShIm():Bitmap { trace ("_typeSh Did"); return _typeShowIm; } } }
VIEWS ON THIS POST

200

Posted on:

Thursday 25th October 2012
View Replies!

MovieClip.addFrameScript problem

Can anyone tell me plz if how to use addFrameScript() method for child movie clip, the path is like: Parent movieclip on frame2 of main timeline -> its 1st child movieclip with two instance names on frames 6 & 7. I have used dynamic video MovieClip here and I am using it on two frames for 2 links with 2 instace names. So can i give addFrameScript from document class or AS file for the second child level. Any suggestion will be highly appreciated. one link is working on first click. I am using external as or Document class for the first time. My small project is incomplete: http://www.cameracraft.in/avi
VIEWS ON THIS POST

172

Posted on:

Thursday 25th October 2012
View Replies!

add stroke around loaded XML images

I need some help to add a stroke around my images when I load my XML. the images are getting loaded but they are stacked on top of one another. If I remove the code to add my stroke, then the images load and are spaced out accordingly. I am not sure what I am doing wrong. Can some one help Code: var space:int = 10;//space between cells var w:int = 122;//width of cell var h:int = 64;//height of cell var xt:int = 0; var yt:int = 0; //create a XML data container that will be the source for the scrollpane var mcHolder:MovieClip = new MovieClip(); //add container to the scrollpane scrollBar_mc.addChild(mcHolder); mcHolder.x = 20; mcHolder.y = 8; mcHolder.buttonMode = true; //set up XML loader to load color list var myXML:XMLList; var myLoader:URLLoader = new URLLoader(); myLoader.addEventListener(Event.COMPLETE, xmlLoaded, false, 0, true); myLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false,0,true); myLoader.load(new URLRequest("images.xml")); // Create the xmlLoaded function function xmlLoaded(event:Event):void { try { myXML = XMLList(event.target.data); myLoader.removeEventListener(Event.COMPLETE, xmlLoaded); myLoader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError); //Run the "for each" loop to iterate through all of //the menu items listed in the external XML file for each (var pic:XML in myXML..pic) { var picImage:String = pic.image.toString(); var picloader:Loader = new Loader(); var loadedGraphic:Sprite = new Sprite(); picloader.load(new URLRequest(picImage)); trace(picImage); picloader.x = xt; picloader.y = 3; mcHolder.addChild(picloader); picloader.contentLoaderInfo.addEventListener(Event.INIT, handleInit); picloader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true); loadedGraphic.addEventListener(MouseEvent.MOUSE_OVER, showHover); loadedGraphic.addEventListener(MouseEvent.MOUSE_OUT, hideHover); function handleInit(event:Event):void { loadedGraphic.addChild(event.target.content as DisplayObject); //addChild(loadedGraphic); mcHolder.addChild(loadedGraphic); loadedGraphic.x = 10; loadedGraphic.y = 4; } function showHover(event:MouseEvent):void { loadedGraphic.graphics.clear(); loadedGraphic.graphics.beginFill(0x000000); loadedGraphic.graphics.drawRoundRect(-5, -5, loadedGraphic.width + 10, loadedGraphic.height + 10, 12, 12); } function hideHover(event:MouseEvent):void { loadedGraphic.graphics.clear(); } // //set the spacing horizontal xt = xt+w+space; } } catch (err:Error) { trace("Could not parse loaded content as XML:\n" + err.message); } } //complete loaded image function imageLoaded(event:Event):void { //trace("loaded"); with (event.target) { content.smoothing = true; content.height = 54; content.width = 103; } } function onIOError(event:IOErrorEvent):void { trace("An error occured when attempting to load the XML.\n" + event.text); }
VIEWS ON THIS POST

190

Posted on:

Thursday 25th October 2012
View Replies!

setChildIndex and addChild Problems

Ok, I'm creating a webpage in Flash CS4. The page consists of 9 squares and when you rollover them they disappear to show information. The squares are all movie clips and they play a slideshow. My main information is located on a layer under the movie clips layer, but in one of the information squares I have a link that will not work (I know this is because my movie clip is still there, just at %0 opacity). So I was thinking I could use the setChildIndex or addChild to send the front movie clip behind the information, but I'm not sure how I would go about coding it I hope this makes sense and any help is greatly appreciated
VIEWS ON THIS POST

125

Posted on:

Thursday 25th October 2012
View Replies!

how can I add Children to MovieClip by simple way

I have some components in the library being exported to actionscript, and I add them to MovieClip,like this: var imgs01:ImgShow01=new ImgShow01 ; var imgs02:ImgShow02=new ImgShow02 ; var imgs03:ImgShow03=new ImgShow03 ; var imgs04:ImgShow04=new ImgShow04 ; var imgs05:ImgShow05=new ImgShow05 ; var imgs06:ImgShow06=new ImgShow06 ; this.addChild(imgs01); this.addChild(imgs02); this.addChild(imgs03); this.addChild(imgs04); this.addChild(imgs05); this.addChild(imgs06); I want to know another simple way to do that in AS3
VIEWS ON THIS POST

151

Posted on:

Thursday 25th October 2012
View Replies!

AS3 addChild HELP!

I'm trying to figure out how to use addChild to place a movie clip. I've got it working, but I can't get it to load in the bottom level of the movie. No matter what I do, it seems to load on top of everything else. I'm definately a newbie with AS3, and had only a little experience with AS2, but the load / unload movie seemed so much easier than this. Can anyone give me some detailed help I've found tutorials on addChild, but none of them specify how to load into a specific layer/level. Here's what I've been using... var contact:BGcontactMCin = new BGcontactMCin(); addChild(contact); contact.x=495; contact.y=350;
VIEWS ON THIS POST

130

Posted on:

Thursday 25th October 2012
View Replies!

adding multiple images to stage via the Loader Class

up - I want to move my multiple externally loaded images a little each time they are added to the stage along the x axis via the Loader class. It all works - But HOW do I access the added graphic synatically, so i can change its x pos! Ive tried picLoader.x ... but that's the Loader - NOT the image...\t\t\t!!! thanks!! Code: private function setPics():void { for(var i:int = 0; i < xItems; i++) { loadImage(xData.xmlData.image[i]); } } private function loadImage(url:String) { picLoader = new Loader(); picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,addImage); picLoader.load(new URLRequest(url)); } private function addImage(e:Event):void { addChild(picLoader); }
VIEWS ON THIS POST

156

Posted on:

Thursday 25th October 2012
View Replies!

Can't get a proper video object added

I'm so pulling my hairs out here right now. The thing is, this feels so basic, and Flash Developer Tool 3 is just giving me this nonsense error! I know, it's probably not really nonsense but... I want to create a simple video object and let it play a local flv. okay, here's the error: "call to a possible undefined method attachNetStream through through a reference with 'static' type Video" What does it means Does it means the object Video is static, and it's not supposed to be Or does it mean the attachNetStream is static here's the function Code: private function showVideo(e:MouseEvent):void { var videoConnection:NetConnection = new NetConnection(); videoConnection.connect(null); var videoStream:NetStream = new NetStream(videoConnection); videoStream.play("video1.flv"); var video:Video = new Video(); video.attachNetStream(videoStream); addChild(video); } and here are my imports, I know, some are redundant,I wanted to be sure.... Code: import flash.display.*; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.*; import flash.media.Video; import flash.net.*; import flash.net.NetConnection; import flash.net.NetStream; import flash.net.URLLoader; import flash.net.URLRequest; I hope some will give me some light in this darkness...
VIEWS ON THIS POST

173

Posted on:

Thursday 25th October 2012
View Replies!

AS3/ XML: need to add a text link into xml node

I have a dynamic text box that is populated from an xml file. Within the xml file is it possible to add a textual link that will appear in the dynamic text box as a clickable link XML structure: is it possible to use: Code: image2.jpg Keep It Simple read more]]> read more ...because the entire a href tag is shown in the flash piece... the reason the link tag is not used is that I would like the read more at the end of the text, and the text will change according to length of xml fed text... The textfields are render html.
VIEWS ON THIS POST

225

Posted on:

Thursday 25th October 2012
View Replies!

why concatonation instead of add ?

trace(_thumbArea.getBoxHeight()); // 108 trace(_xml.verticalThumbSpacing); // 4 var shiftValue:int = _thumbArea.getBoxHeight() + _xml.verticalThumbSpacing; trace(shiftValue); //1084
VIEWS ON THIS POST

119

Posted on:

Thursday 25th October 2012
View Replies!

where to add Event.ADDED_TO_STAGE with error #1009

. I have an error code #1009 and have been googling around and found a lot of links, yet I'm not sure where to put the Event.ADDED_TO_STAGE to make my project work. The error code is Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at be.boulevart.google.ajaxapi.translation::GoogleTranslation/onResponse() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() and my as3 code is: Code: package{ import flash.display.*; import flash.events.*; import gs.*; import fl.motion.easing.*; import framework.utils.LoadXML; import be.boulevart.google.ajaxapi.translation.*; import be.boulevart.google.ajaxapi.*; import be.boulevart.google.ajaxapi.search.* import be.boulevart.google.apicore.GoogleApiKeyStore; import be.boulevart.google.events.*; public dynamic class wotd_widget extends MovieClip{ //vars var loadXML:LoadXML = new LoadXML('http://wordsmith.org/awad/rss1.xml',onComplete); private var mc01:MovieClip; private var mclayout:MovieClip; //constructor public function wotd_widget():void{ trace('wotd'); init_btn(); } private function onComplete($xml:XML):void{ trace($xml.channel.item[0].title); trace($xml.channel.item[0].description); wotd_In.text = $xml.channel.item[0].title; des_In.text = $xml.channel.item[0].description; var gt:GoogleTranslation = new GoogleTranslation(); gt.translate($xml.channel.item[0].title,'en','de'); gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslate); } private function onTranslate(e:GoogleApiEvent):void{ trans_In.text = e.data.result; } private function init_btn():void{ this.mc01 = new trans_btn; this.mc01.x = 340.9; this.mc01.y = 234.4; addChild(this.mc01); TweenMax.to(this.mc01,1,{x:340.9, y:234.4, ease:Cubic.easeOut,onComplete:onComplete1}); } private function onComplete1():void{ this.mc01.buttonMode = true; this.mc01.addEventListener(MouseEvent.ROLL_OVER,mEvent01); this.mc01.addEventListener(MouseEvent.ROLL_OUT,mEvent01); this.mc01.addEventListener(MouseEvent.CLICK,mEvent01); } function mEvent01(e:MouseEvent):void{ switch(e.type){ case 'rollOver': //this executes when you rollover the target TweenMax.to(MovieClip(e.target),0,{tint:0xFF75B6}); break; case 'rollOut': //this executes when you rolloff the target TweenMax.to(MovieClip(e.target),0,{removeTint:true}); break; case 'click': //this executes when you click the target onClick01(); break; } } private function onClick01():void{ var gt:GoogleTranslation = new GoogleTranslation(); gt.translate(input_trans.text,'en','de'); gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslation); } function onTranslation(e:GoogleApiEvent):void{ trace(e.data.to); trace(e.data.orig); trace(e.data.from); trace(e.data.result); output_trans.text = e.data.result; } } } NEED YOUR HELP REALLY REALLY FAST!
VIEWS ON THIS POST

423

Posted on:

Thursday 25th October 2012
View Replies!

AS3: need help with dynamically adding multiple mc to one mask

hello, i'm trying to add movieclips to a single mask. but i cant seem to get it to work. is there a easy way to do this or do i have to remove the mask-child and add a new one again
VIEWS ON THIS POST

290

Posted on:

Thursday 25th October 2012
View Replies!

addChild query

Intro to me: (skip to Q if not interested ) all, new user - long time reader (well, about 2 weeks ) Im currently trying to learn AS3 at the moment, as a designer i have entered this world with no previous programming knowledge, which is difficult to say the least, but also good as i have no bad habbits or pre-conceptions I have a simple question about ActionScript Code: addChild() and what it does... (apologies if the answer to this already exists) lets say i added all the objects from an array (say an array of movie clips), what i want to know is... Q. If i keep adding them as a child to the stage, then at the end end start adding them again, does it start building up more and more layers to the point where you would run out of memory, or does it overwrite the previously added child Working example would be a carousel application, ie; load 3 movie clips onto the stage, then rotate through them, going back to the first one when the last one has "played".
VIEWS ON THIS POST

142

Posted on:

Thursday 25th October 2012
View Replies!

where to add event listener in experimental mvc program

Hi I'm learning MVC and wanted to start out with a simple program that counts mouse clicks on the stage. Any help would be great. There's no library objects on the stage linked to anything. Everything is done in code. I'm receiving error - Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Controller() at run_fla::MainTimeline/frame1() model Code: package { import flash.events.EventDispatcher; import flash.events.Event; public class Model extends EventDispatcher { private var _clicks:Number; public static const COUNT_CLICK:String = "clicked"; public function Model(){ } public function set clicks(num:Number):void { _clicks = _clicks + num; dispatchEvent(new Event(Model.COUNT_CLICK)); } } } controller Code: package { import flash.display.*; import flash.events.*; public class Controller extends MovieClip { private var model:Model; public function Controller(m){ model = m; this.parent.stage.addEventListener(MouseEvent.CLICK, go); } public function go(event:MouseEvent):void { model.clicks = 1; } } } fla I don't have a doucment class or view class yet. Code: var m:Model = new Model(); var c:Controller = new Controller(m); addChild(c);
VIEWS ON THIS POST

189

Posted on:

Thursday 25th October 2012
View Replies!

can anyone add an easing effect to my menu!

Hi i have created a scrolling menu based on the iphone. It works. But it needs some easing on it so that it doesnt stop moving straight away(like the iphone). If anyone can modiffy my code or re-code somthing like in the attached i would be happy to stick some cash in a paypall account! Tar Aidan
VIEWS ON THIS POST

153

Posted on:

Thursday 25th October 2012
View Replies!

How to add a child to a particular scene's stage?

I have to scenes, dashboard and game. I want to add a child just to game's stage. Can someone tell me the syntax for this
VIEWS ON THIS POST

434

Posted on:

Thursday 25th October 2012
View Replies!

How Do I add contextMenu to stage?

So in AS2 you could add a contextMenu for the whole movie like this: Code: var newMenu = new ContextMenu(); newMenu.hideBuiltInItems(); _root.menu = newMenu; There is no _root in AS3. So in my Document class I tried this: Code: stage.contextMenu = new ContextMenu(); Which results in this error: Error: Error #2071: The Stage class does not implement this property or method. at Error$/throwError() at flash.display::Stage/set contextMenu() I have also tried just adding items to stage.contextMenu but that didn't work either. I also added a custom context menu to my Document class but that doesn't work for the whole movie. So does anyone know if there is something I can do to set the contextMenu for the whole movie
VIEWS ON THIS POST

177

Posted on:

Thursday 25th October 2012
View Replies!

adding one to name on button press

, I have a button on stage and when it is pressed I would like to add a movieclip in increments of one. For example if I press the button once I get "mc1", if I press it twice I get "mc2". Does anyone know what I'm doing wrong Right now its just counting straight to 9. Thank you. Code: private function more_text_ButtonPressed(event:MouseEvent) { for (var i:Number = 0; i < 9; i++) { var my_mc:MovieClip = new MovieClip(); my_mc.name = "mc"+[i]; addChild(my_mc); trace(my_mc.name); } }
VIEWS ON THIS POST

127

Posted on:

Thursday 25th October 2012
View Replies!

Where does addChild come from?

Hi all, I'm new to ActionScript 3 (had *some* experience with ActionScript 2) and I was just wondering where addChild comes from Is it pre-built in or does it com from importing Flash.display.Sprite (and if it is from Flash.display.Sprite, does it mean it gets imported whenever you display *any* subpackage of Flash.display)
VIEWS ON THIS POST

112

Posted on:

Thursday 25th October 2012
View Replies!