1120 error, don't get it


Hi!

I'm trying to "link" a button(fac_btn) on a movieclip(tint_mc).
Only thing is that my button(fac_btn) is inside another movieclip-layer(fac_mc).
I know it's a bad habit, but there's no other way...
So Flash can't find tint_mc, because he is on the stage.

How can I fix this
This is my code


Code: fac_btn.addEventListener(MouseEvent.CLICK, clickFunction); function clickFunction(evt:MouseEvent):void { tint_mc.gotoAndPlay("on"); }
Posted On: Thursday 3rd of January 2013 10:21:08 PM Total Views:  295
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




[help]as3 xml error

So I'm playing around with xml and as3. Now I got this: Code: var fileList:XMLList = bookInput.Songs.file1; And now I want that if you push a button, file1 changes in file2. So I got this: Code: var j:uint=1; But when I change the first snipped in this: Code: var fileList:XMLList = bookInput.Songs.file+j; it gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert "1" to XMLList. How to fix it
VIEWS ON THIS POST

275

Posted on:

Thursday 25th October 2012
View Replies!

AS3, error 1119 - when class is same name as last folder in package.

I have this strange error, I have a class defined like so: ------ Code: package net.guttershark.model { public class Model { private static var instance:Model; public var test:Boolean; public static function gi():Model { if(instance == null) instance = new Model(); return instance; } } } ------ It throws error 1119 any time I try to use it like so: trace(Model.gi().test); The error: "1119: Access of possibly undefined property test through a reference with static type Model. Now when I simply rename the class to this: Code: package net.guttershark.model { public class Model2 { private static var instance:Model2; public var test:Boolean; public static function gi():Model2 { if(instance == null) instance = new Model2(); return instance; } } } I get no errors, and it works fine. Whey does the class name conflict with the last folder in the package structure And is there a way around this
VIEWS ON THIS POST

207

Posted on:

Thursday 25th October 2012
View Replies!

setChildAt errors and troubles

all, I'm trying to make a simple gallery with over lapping images, when clicked I trying to make the selected image change its index value to come to the front. I seem to be hitting a brick wall with ArgumentErrors and RangeErrors... This is my code Code: private function xmlLoadedHandler(event:Event):void { _xmlObject = new XML(event.target.data); addChild(container); var i:uint = 0; for each(var image:XML in _xmlObject.image) { i = i + 1; var displayImage:ImageDisplay = new ImageDisplay(_xmlPath + image.@src); container.addChildAt(displayImage, 0); displayImage.name = "image" + i; trace(displayImage.name); displayImage.x = image.@x; displayImage.y = image.@y; displayImage.alpha = 0.5; displayImage.rotation = Math.random() * 15; displayImage.addEventListener(MouseEvent.CLICK, onMouseEventHandler); } trace("There are", container.numChildren, "images in this gallery!"); } private function onMouseEventHandler(event:MouseEvent):void { event.target.setChildIndex(event.target, container.numChildren - 1); //var circle:Sprite = Sprite(event.target); //var topPosition:uint = container.numChildren - 1; //container.setChildIndex(circle, topPosition); //container.setChildIndex(container.getChildAt(1), 0); } I've tried a few different ways in the onMouseEventHandler function but so far turned up nothing.
VIEWS ON THIS POST

181

Posted on:

Thursday 25th October 2012
View Replies!

"Type coercion error" when I'm not coercing types

Here's an FLA of what I'm experiencing: http://spamtheweb.com/ul/upload/310308/6 6135_help.fla I don't understand it at all. I have two different movieclips with the same name on different frames, and for some reason Flash is exploding. Please help me. I am so confused.
VIEWS ON THIS POST

151

Posted on:

Thursday 25th October 2012
View Replies!

Kinda urgent question (code error = frozen flash :S), and then a URL question

Code: import flash.net.navigateToURL; import flash.net.URLRequest; navigateToURL(new URLRequest('http://www.url.org/',"_blank"); There is no autoRecovery u must save ur work often.
VIEWS ON THIS POST

283

Posted on:

Thursday 25th October 2012
View Replies!

IE - JS error w/ addCallBack & call

** sorry mods - could you move this to the AS2 section ... my mistake ** I've got a little color-picker swf that tells JS when a new color has been selected, and recieves a new color from JS. Everything works perfectly in FireFox, but throws "Object doesn't support this property or method" in IE 7. I've been all over the interweb and can't find any solutions that work.
VIEWS ON THIS POST

185

Posted on:

Thursday 25th October 2012
View Replies!

removeChild errors

I am trying to create a movie clip by using a button in Flash. The button's instance is cir_btn which creates a circle on the stage I am using an external .as file to generate the public class Cir which calls upon several mouse actions as well as referrence a movie clip in my library that contains a shape. The movie clip's name is circle and it has a linkage of circle I am able to repeatedly generate circles inside of the swf, however when I try to use the remove button, this is what I get: ReferenceError: Error #1065: Variable circ is not defined. at Cir/::removeCirc() Here is the code for my .as file: package { import flash.display.MovieClip; import flash.events.MouseEvent; public class Cir extends MovieClip { var timeline:MovieClip; public function Cir(tl:MovieClip) { timeline=tl; timeline.cir_btn.addEventListener(MouseEvent.MOUSE _DOWN, onMouseDown); timeline.reset_btn.addEventListener(MouseEvent.MOU SE_DOWN, removeCirc); } public function onMouseDown( event:MouseEvent ):void { var circ:MovieClip = new circle; circ.x = 110; circ.y = 70; this.addChild(circ); } private function clicked(e:MouseEvent):void { removeEventListener(MouseEvent.CLICK,clicked); } private function removeCirc( event:MouseEvent ):void { parent.removeChild(circ); } } } Just to see if I was ever meeting the removeCirc function, I did both a trace and I changed the code from parent.removeChild(circ); to parent.removeChild(this); which does remove the circle from the stage, but I can't generate a new circle as long as I have the swf open. I am having a very hard time unlearning AS2 to learn AS3. Can any one help me out EXTRA CREDIT: I am also looking for a way to constrain the circle movie clip to a certain portion of the stage only. Some kind of bounds command so that the movie clip will only display in a rectangular area inside of the swf. This is not as important right now as figuring out how to remove the circle, but I will need to get to it eventually.
VIEWS ON THIS POST

198

Posted on:

Thursday 25th October 2012
View Replies!

jpg into swf - loaded into 2nd swf - error!

I've got a runtime jpg that I'm loading into a swf via loader.load() - works great. However, when this primary swf is loaded into a secondary swf - via a button (MouseEvent.CLICK) I get the following error: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. The primary swf is loaded into the secondary swf when the button is clicked - just with the error above and without the jpg. discussed above is occuring as I test project locally. Apparently, here is yet another concept in AS3 that I'm missing. Help is appreciated.
VIEWS ON THIS POST

175

Posted on:

Thursday 25th October 2012
View Replies!

removeChild 2ce -> error

I have a script which at some point MIGHT remove a child removeChild(obj[2]); At the end of script I need another script which has to remove the child if it is still present. I thought that if(obj[2]){ removeChild(obj[2]); } would do the trick. But even if it's removed in first part, then the second part still tries to remove it (it still sees obj[2] as TRUE) even though it already was removed from stage. Results in error ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. Am I doing something wrong here
VIEWS ON THIS POST

137

Posted on:

Thursday 25th October 2012
View Replies!

Array of type string with unique value

I am recently working with an application. Where I need 4 unique values from an array in such a way that it should be checking random item every time. For eg:- Main_Array = ["one","two","three","four","five","six","seven "]; Sub_Array = ["three"]; // initially it holds one value for(each value of Sub_Array) { If(Sub_Array[value] == Main_Array[Random Number]) { // It should get another random item from Main_Arr and check } else { Sub_Array.push(Main_Array[Random Number]); //next time updated Sub_Arrays values should be checked. } } // I want an array with 3 unique values other then the one already pushed in Sub_Array I am trying but I don't get unique values, or something gets wrong which I am not able to solve. Looking forward desperately for some help
VIEWS ON THIS POST

126

Posted on:

Monday 29th October 2012
View Replies!

Event not bubbling to ancestor?

I can't figure out why the event listener callback function isn't being fired when a child object is being clicked. Since the "SelectionPoint" object is a child of this class, shouldn't the listener get notified of the MouseEvent.CLICK event during the capture phase Code: package { import flash.display.*; import flash.events.*; import SelectionPoint; public class AreaSelectionManager extends Sprite { public function AreaSelectionManager(){ addEventListener(MouseEvent.CLICK, function(evt){ trace('hi'); }); } // Create new point public function newPoint(x:Number, y:Number):void { var point:SelectionPoint = new SelectionPoint(x, y); addChild(point); } } }
VIEWS ON THIS POST

72

Posted on:

Monday 29th October 2012
View Replies!

Flash Playing Video referenced from within a class

I have this video button, with a class attached, works ok but when I come to press the button I get my trace but the player does not work. MY BUTTON is in a Container MY FLVPlayer is in another Container my button class is as follows: Code: package com.ppr.buttons{ import flash.events.*; import flash.display.*; import flash.media.Video; public class lrgPlayButton extends MovieClip { //-- some setting/properties or variables as I know them private var videoContainer:MovieClip; public function lrgPlayButton(vCont:MovieClip) { // constructor code stop(); this.alpha=.4; videoContainer= vCont; this.buttonMode = true; this.addEventListener(MouseEvent.MOUSE_OVER, buttonOver); this.addEventListener(MouseEvent.MOUSE_OUT, buttonOut); this.addEventListener(MouseEvent.CLICK, buttonClick); } private function buttonClick(e:MouseEvent) { trace("Play " + videoContainer); //-- how do i reference the flvplayer on the //--- on the stage within a container named videoContainer and flvplayer instance named _flvPlayer videoContainer._flvPlayer.play(); } private function buttonOver(e:MouseEvent) { this.gotoAndStop(2); this.alpha=1; } private function buttonOut(e:MouseEvent) { this.gotoAndStop(1); this.alpha=.4; } } } on the Stage of my flash I have the following as to attach the button within a container: Code: var lrgPlayBtn:lrgPlayButton = new lrgPlayButton(videoScreenContainer); _contentCont_mc.addChild(lrgPlayBtn); lrgPlayBtn.y=140; lrgPlayBtn.x=245; My flv player is in a container called: videoScreenContainer with a instance name of _flvplayer, and this is placed on the stage. At the moment I am passing the name of the video container into the above constructer 'public function lrgPlayButton(vCont:MovieClip) {..' then assigning that to a variable called 'videoContainer= vCont;' thus.. thinking it would be 'videoContainer._flvPlayer.play();'so I thought. any ideas how I can do this many
VIEWS ON THIS POST

77

Posted on:

Monday 29th October 2012
View Replies!

Flash hitTestPoint Help

I'm trying to set up a collision so that when a bullet hits a wall it is destroyed. Here is the snippet of code I am using: PHP Code: while(_root.newWall.hitTestPoint(x,y+radius,true)){y-=Math.sin(angle);deleteMe=true;}while(_root.newWall.hitTestPoint(x,y-radius,true)){y+=Math.sin(angle);deleteMe=true;}while(_root.newWall.hitTestPoint(x-radius,y,true)){x+=Math.cos(angle);deleteMe=true;}while(_root.newWall.hitTestPoint(x+radius,y,true)){x-=Math.cos(angle);deleteMe=true;}if(deleteMe){deleteMe=false;removeEventListener(Event.ENTER_FRAME,eFrame);_root.removeChild(this);} This method works great for when detecting a collision between other moving instances and the walls, but for some reason with the bullets I get this error message when they almost touch the wall and Flash freezes and I usually have to restart it: PHP Code: Error:Error#1502:Ascripthasexecutedforlongerthanthedefaulttimeoutperiodof15seconds.atBullet/eFrame() I attempted to debug it and it said that the problems were at the four lines beginning the while loop. Can someone help me please
VIEWS ON THIS POST

86

Posted on:

Monday 29th October 2012
View Replies!

Flash Data Oriented Programming and ActionScript

I recently read some forum thread and article talking about Data Oriented Programming. This think seem realy interesting. I tryed to find some exemple, but i did not find any one using ActionScript. I would like to know if it is a good thing to use DOP with AS3 and how exactly this could be done
VIEWS ON THIS POST

74

Posted on:

Monday 29th October 2012
View Replies!

Google map: How to display Markers?

I'm having an issue to display markers into google map. I use XML to parse those markers. **Flash gives me that error msg: TypeError: Error #1009: Cannot access a property or method of a null object reference. However I can see Latitude and Longitude display while traced them... Does anyone can help me Code: package { import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; import com.google.maps.LatLng; import com.google.maps.Map; import com.google.maps.MapEvent; import com.google.maps.MapType; import com.google.maps.overlays.Marker; import com.google.maps.overlays.MarkerOptions; import com.google.maps.controls.ZoomControl; import utils.LoadXML; import utils.ParseXML; public class GoogleMaps extends Sprite { private var loader:LoadXML; private var parser:ParseXML; private var tabMarkers:Array; private var map:Map; private static var FILE:String = "../xml/markers.xml"; private static var KEY:String = ""; public function GoogleMaps() { map = new Map(); map.key = "ABQIAAAAySpiyKFbR2kyvDyp02w_DhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTnKLUMs9zrkisTjGfTICBrTK1K2w"; map.setSize(new Point(stage.stageWidth, stage.stageHeight)); map.addEventListener(MapEvent.MAP_READY, onMapReady); addChild(map); loadXML(); } private function onMapReady(event:Event):void { map.setCenter(new LatLng(45.555255,-73.581336), 13, MapType.NORMAL_MAP_TYPE); map.addControl(new ZoomControl()); } private function loadXML() { loader = new LoadXML(FILE, handleLoadedXML); } private function handleLoadedXML(event:Event) { var markers:XML = new XML(event.target.data); parser = new ParseXML(markers); tabMarkers = new Array(); for each(var item:XML in markers.point) tabMarkers.push({ latitude:item.lat, longitude:item.long }); for(var i:int=0; i
VIEWS ON THIS POST

115

Posted on:

Monday 29th October 2012
View Replies!

Flash Trouble with a few basic things

I'm having a real hardtime with several things that seem relatively easy to do in AS2 with AS3. I can't seem to find any tutorials in AS3 to create a very basic RPG with making maps, some simple tiles and collision, and battle-screens. Everything is in AS2. What I have been trying to do for the past 2 days with little to no success is: Create Collision Detection for human-controlled movieClip and also randomly moving movieClips. The former is most important, obviously. *And how to implement the classes for it in the best organized fashion. Create Classes Dynamically from MovieClips and Sprites in the Library. PHP Code: //Thenameoftheautomaticclassforawallis:Wallvarwall=newWall(); I've tried using a loop with getDefinitionByName, but it kept giving me the 1065 error, that something isn't defined. The last attempt at it looks like this kind of: PHP Code: \t\t\t\tpublicfunctiondoIt(howMany:int):void\t\t\t\t{\t\t\t\t\t\tfor(vari:int=1;howMany>i;i++)\t\t\t\t\t\t{\t\t\t\t\t\t\t\t//varBlockClass:Block;\t\t\t\t\t\t\t\tvarBlockClass:Class=getDefinitionByName("Block"+i)asClass;\t\t\t\t\t\t\t\tblock=newBlockClass();\t\t\t\t\t\t\t\tblock.x=i*10;\t\t\t\t\t\t\t\taddChild(block);\t\t\t\t\t\t}\t\t\t\t} I was trying to do that in attempts to also make the Block's go into an array that maybe I could also loop on EventHandlers for collision detection; but when I isolated that attempt of code, it didn't work at all, so I won't bother posting that. So basically I want to make a reusable code for collision on tiles or anything that can at least get me started on how to properly use Collision Detection in OOB. And how to create classes dynamically in loops and how to call on them. I am pretty new at this sort of stuff for Flash, so linking me to adobe, won't help. I've read and digested everything they have and it was no help.
VIEWS ON THIS POST

67

Posted on:

Monday 29th October 2012
View Replies!

video resolution

I have an instance of the video class that attaches a web cam, I want to set the web cams resolution to 25x25 so that there are 25 blocks of colour and very little detail, I can make the video resolution25x25 but it cuts of most of the video. Can anyone point me in the right direction
VIEWS ON THIS POST

86

Posted on:

Monday 29th October 2012
View Replies!

drag / snap back (on a button)

hello all been searching google for a good bit now and find all sorts of drag stuff except what i need. what i want to achieve is this http://www.christiankragh.com/blog/p=42 i can do the drag stuff etc...but i need it to snap back smoothly into place. any ideas anyone tutorials etc are welcome as i REALLY REALLY wanna learn.
VIEWS ON THIS POST

68

Posted on:

Monday 29th October 2012
View Replies!

Flash Auto Scrolling XML gallery

Hi Guys! I am a beginner to Flash and action script. I want to make a filmstrip view in Flash. The filmstrip should contain images originating from external source (say XML). Though I found some relating tutorials for this over the net. For example: http://www.flashfridge.com/tutorial.aspID=204 Now what I want is that the images should move diagonal from top right corner to bottom left corner. Also the images should scroll automatically without any mouse effect. Only mouse effect should be to stop the animation when mouse points any thumbnail (which I can do with onRollover action). As the number of thumbnails will not be constant, I need some technique which can make it dynamic and load n number of thumbnails depending upon the XML file. Experts, Kindly help me.
VIEWS ON THIS POST

50

Posted on:

Monday 29th October 2012
View Replies!

AS3 Button Events to load external SWF's into mc on stage

I have been trying to pick up more as3 lately, also have been converting some of my sites from as2 to as3. So I've seen alot of threads regarding my problem, but no clear concise solution. Here's what I desperately need help understanding. In as2 I could create 3 menu buttons and save them in a mc- lets call it menu_mc. This menu_mc sits on my main stage. I have also placed a mc on stage to hold anything that I load. Lets call it holder_mc. So I figured out how to get my email button to work using this: email_mc.addEventListener(MouseEvent.CLICK, mailto); function mailto(event:MouseEvent):void { var email:URLRequest = new URLRequest("mailto:myemail@mail.com"); navigateToURL(email, "_blank"); } That's fine. What I can't for the life of me figure out is understanding how to click on one of my menu buttons and load a swf into my holder_mc on stage. In as2 I could use this code on a button : on (release) { //load Movie Behavior if(this.my_holder == Number(this.my_holder)){ loadMovieNum("test.swf",this.my_holder); } else { this.my_holder.loadMovie("test.swf"); } //End Behavior } Can someone please help me. Teaching myself is not easy and I am sure there's alot I am missing, even though I watch alot of tutorials, I haven't found any that do what I am trying to do. You can see what I am trying to do here: http://shareeneff.com/NEW.html
VIEWS ON THIS POST

78

Posted on:

Monday 29th October 2012
View Replies!

Create a cards game with flash

, i wasnt sure where to post this but since t has to do with flash i ll just post it here. I want to create a flash card game for multiple players. I guess it would be a client - server programm. However i have no idea where to start from so if i could find an example with code of such a game would be great. Does anyone know if and where i can find a coding example of an online cards game like poker Thank you in advance
VIEWS ON THIS POST

87

Posted on:

Monday 19th November 2012
View Replies!

add milliseconds to countdown

I have a countdown object which countdowns from 30 seconds. I am very new to this so please bare with me. I have created a timer which counts down and displays it in a textfield. The problem is it countdown the seconds only, I want to also display the milliseconds, I have no clue how to do this var count:Number = 30; var myTimer:Timer = new Timer(1000,count); myTimer.addEventListener(TimerEvent.TIMER, countdown); myTimer.start(); function countdown(event:TimerEvent):void { myText_txt.text = String((count)-myTimer.currentCount); }
VIEWS ON THIS POST

113

Posted on:

Monday 19th November 2012
View Replies!

Dynamically loaded Images have low quality

Hiya, I've been working on some flash banners for websites, and I have a mix of static images which are included in the .fla and .swf files, and some dynamically loaded images. When the images are loaded on my system, everything is crisp and clean and perfect, when I upload the .swf to a server, the images become grainy and distorted. I've worked around the problem for all the static images, by ticking the 'allow smoothing' option, and now only the dynamically loaded images look bad. I need a way to make the dynamic images appear either in proper quality, or allowing smoothing, is there a way to do this The closest thing I've heard of is turning them into bitmap's when loading, and then allowing smoothing for those, somehow, but I've no idea how to go about that. The dynamically loaded image is called name.png, and its a high resolution .png image. The publish settings on my .swf are all set to make images high quality, no compression etc.
VIEWS ON THIS POST

77

Posted on:

Friday 30th November 2012
View Replies!

moving movie clips on the stage

this might sound really silly but im trying to get a movieclip to move up the stage and then when it gets to the top it randomly selects a new position on the bottom of the screen and moves up the stage again. im having trouble doing this i can get it to move from top to bottom perfectly but when i change the code to move the other direction it doesnt seem to work and i dont know why can anyone help please\t\t\t\t\t\t\t\t this is my code:- onClipEvent(load) { newScale = Math.random() * 150 + 50; this._xscale = newScale; this._yscale = newScale; } onClipEvent(enterFrame) { if (this._x > Stage.height) { this._x = 600; this._y = Math.random() * 400 +1 } else { speed = -1 this._x += speed; } }
VIEWS ON THIS POST

56

Posted on:

Friday 30th November 2012
View Replies!

Tutorial: Removing Things Using Code

Hi , This is the place to discuss anything regarding the Removing Things Using Code tutorial Cheers, Kirupa
VIEWS ON THIS POST

51

Posted on:

Friday 28th December 2012
View Replies!

Multidimensional arrays

I wondered if anyone that uses multidimensional arrays can tell me how to get an array length value for each 'layer' of data. e.g for nested objects trace(someArray.length) for(var i in someArray) { trace(someArray[i]) }
VIEWS ON THIS POST

51

Posted on:

Friday 28th December 2012
View Replies!

Assign variables do dynamic created buttons?

Hi: I have a 13 buttons to wich I added Event listeners using a for loop: Code: for (var i:Number = 1; i < 13; i++) { this["main_bt_" + i].addEventListener(MouseEvent.CLICK, onClick); } function onClick(e:MouseEvent):void { trace(i); } When clicking the button it should return the variable i that generated it (1,2,3...etc) It always returns the last i (13). How can I get this to work Do I have to create the buttons manually and add a functions to each button
VIEWS ON THIS POST

70

Posted on:

Friday 28th December 2012
View Replies!

Flash AS3 mc removing from itself problem (...again)

i know there is many posts about this problem, but i haven't solved my problem yet. Maybe is because i'm thinking in a wrong way and i haven't understood AS3 concept yet... My problem is the following: I was programming games in AS2 in a way where movieclips could themselves remove, for example, when they collide whit main character. If the objects where created in realtime with attachmovie then removeMovieClip, but if they where objects that where already existing because placed in the timeline, unloadmovie () was working. I know in AS3 i can delete them from the parent who created them but, most of my movieclips are thrown into a frame in the main clip editor. I mean, i use the timeline frames as level editor where i design my levels and i place the objects directly there and not create them by code. How can i remove them\t
VIEWS ON THIS POST

43

Posted on:

Sunday 30th December 2012
View Replies!

Flash Accessing classes from externally loaded swf's?

I have a document class which links to several classes, one of which adds a container onto the stage and loads external .swf's into it. Q: How do I access the various classes loaded in the document class from the external swf timeline For instance, when you click a button in the loaded swf it changes the soundtrack from the soundtrack class. I have tried dispatchevent from the external swf timeline, but I still can't seem to get it to work. Is this supposed to work, or should I be doing something different
VIEWS ON THIS POST

45

Posted on:

Sunday 30th December 2012
View Replies!

Error #1009: Cannot access a property or method of a null object reference.

Hi all, I'm new to Flash and I'm having some issues with my code. It was working fine until I made some unrelated changes (highlighted in the code) and now suddenly my move the player function won't run. Code: import flash.events.Event; var KeyThatsPressed = uint; var rightKeyIsDown:Boolean = false; var leftKeyIsDown:Boolean = false; var upKeyIsDown:Boolean = false; var downKeyIsDown:Boolean = false; var PlayerSpeed:Number = 7; var gravity:Number = 1; var yVelocity:Number = 0; var canJump:Boolean=false; player_mc.gotoAndStop(1); stage.addEventListener(KeyboardEvent.KEY_DOWN, PressAKey); stage.addEventListener(KeyboardEvent.KEY_UP, ReleaseAKey); //Press A Key function PressAKey(event:KeyboardEvent):void { if(event.keyCode == Keyboard.RIGHT){ rightKeyIsDown = true; player_mc.gotoAndStop(2); } if(event.keyCode == Keyboard.LEFT){ leftKeyIsDown = true; player_mc.gotoAndStop(3); } if(event.keyCode == Keyboard.UP){ upKeyIsDown = true; player_mc.gotoAndStop(4); } } //Release A Key function ReleaseAKey(event:KeyboardEvent):void { if(event.keyCode == Keyboard.RIGHT){ rightKeyIsDown = false; player_mc.gotoAndStop(1); } if(event.keyCode == Keyboard.LEFT){ leftKeyIsDown = false; player_mc.gotoAndStop(1); } if(event.keyCode == Keyboard.UP){ upKeyIsDown = false; player_mc.gotoAndStop(1); } } player_mc.addEventListener (Event.ENTER_FRAME, moveThePlayer); function moveThePlayer(event:Event):void { if(rightKeyIsDown) { player_mc.x +=5; } if(leftKeyIsDown) { player_mc.x -=5; } if(upKeyIsDown&&canJump) { yVelocity = -15; canJump=false; } yVelocity+=gravity; if(!floor_mc.hitTestPoint(player_mc.x, player_mc.y, true)) { player_mc.y+=yVelocity } if(yVelocity>20) { yVelocity = 20; } for(var i:int = 0;i
VIEWS ON THIS POST

74

Posted on:

Sunday 30th December 2012
View Replies!

Flash Flash CS4, AS3 - addChild after a MovieClip has played problem

In my .fla file, in frame 1 on the main timeline, I have a Button symbol in the display list. When that button is clicked, a function removes it from the display list, then adds a MovieClip (created in the library & exported for AS3) to the display list, then plays the MovieClip. Within that MovieClip, on the last frame is the stop(); function. The MovieClip is an animation of a transition from one room to another. Everything works ok up to this point. After the MovieClip is done playing, I need to add more whatevers to the display list (such as a button to transition back to the previous room). The problem is I don't know how to tell ActionScript to wait till the MovieClip has played before adding to the display list. When trying to get it to do so, it just skips to the last frame of the MovieClip, not playing the animation. Please help. Code: import flash.display.MovieClip; import flash.display.SimpleButton; import flash.events.MouseEvent; //----------------------------------------------------------- //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //----------------------------------------------------------- // Background images: var background_01:Background_01 = new Background_01; background_01.name = "background_01"; var section_01bright:Section_01bright = new Section_01bright; section_01bright.name = "section_01bright"; var section_02bright:Section_02bright = new Section_02bright; section_02bright.name = "section_02bright"; // -------------------------------------------------- // The Buttons: var btn_goRight_01:Btn_GoRight_01 = new Btn_GoRight_01; btn_goRight_01.name = "btn_goRight_01"; btn_goRight_01.x = 736; btn_goRight_01.y = 300; var btn_goLeft_01:Btn_GoLeft_01 = new Btn_GoLeft_01; btn_goLeft_01.name = "btn_goLeft_01"; btn_goLeft_01.x = 63; btn_goLeft_01.y = 300; // ------------------------------------------------- // The MovieClip: var sectionChange_1to2:SectionChange_1to2 = new SectionChange_1to2; //----------------------------------------------------------- //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //----------------------------------------------------------- // Display list: addChild(background_01); background_01.addChild(section_01bright); section_01bright.addChild(btn_goRight_01); //----------------------------------------------------------- //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //----------------------------------------------------------- // Event listener and function: btn_goRight_01.addEventListener(MouseEvent.CLICK, changeToSection2); function changeToSection2(event:MouseEvent):void { section_01bright.removeChild(btn_goRight_01); background_01.removeChild(section_01bright); background_01.addChild(sectionChange_1to2); sectionChange_1to2.play(); if (sectionChange_1to2.currentFrame == 45) { background_01.removeChild(sectionChange_1to2); background_01.addChild(section_02bright); section_02bright.addChild(btn_goLeft_01); } }
VIEWS ON THIS POST

49

Posted on:

Thursday 3rd January 2013
View Replies!