SEARCH YOUR SOLUTION HERE  

Inconsistent referencing behaviour

Can any one tell me why the listenerevent functions seem to be inconsistent. The second one works. The first one doesn't, complaining about a NULL parameter being passed to navigateToURL. I used to have the links in an array, and as you can see by my commented out code, I wanted to loop this. Any help here

Code: var links1 = new URLRequest("link1.html"); var links2 = new URLRequest("link2.html"); var links3 = new URLRequest("link3.html"); var links4 = new URLRequest("link4.html"); //for (y=1;y

Posted On: Thursday 25th of October 2012 11:18:32 PM Total Views:  471
View Complete with Replies




Related Messages:

Flash As3 referencing from an object within an array   (111 Views)
Hi I have a several objects nested within an array. I'm trying to reference a property of one specific object (intel). function eventGenerator():void { var randomArea:Number; randomArea = Math.ceil(Math.random()*5); var eventArea= ainPlaceNames[randomArea]; trace(eventArea.intel) } ainPlace names is the array's name. The random area variable contains the co ordinate on the array for the object. Each object on the array has a property called intel. The idea is I want to able to store the value of intel in a number and use in an equation. I would also like to be able to adjust the number. Would anyone here be able to help O___o the trace function here returns an error saying it is undefined so eventArea.intel for some reason isn't referencing the intel property of the object. cheers
Problems referencing movieclips   (120 Views)
I have a movieclip called 'worlds' Inside it there are 3 movieclips called 'world1', 'world2' and 'world3' Inside each of those 3 movieclips there are 20 more movieclips called 'button1', 'button2', 'button3' and so on. I'm writing a function that tracks various things about the 'button1' movieclips such as currentFrame based on numbers it is given. I've had problems trying to gather this information. I have two variables worldnum and buttonnum, they each represent the numbers at the end of the 'world' and 'button' movieclips respectively. I've tried this code: ActionScript Code: worlds.this["world"+worldnum].this["button"+buttonnum].currentFrame But no luck.... I know it's probably an obvious mistake that I'll kick myself for later, but I'd really like to know where I'm going wrong.
MovieClip referencing problem   (112 Views)
, I am making a menu in which i want to switch ON the selected submenu and button, and OFF the previous submenu and button, could anybody please tell me what is wrong with my code: Code: // Attach events to menu buttons body_mc.menu_mc.addEventListener(MouseEvent.CLICK, updateSub); // Declaring the menu elements to update var previousBtn:MovieClip; var currentBtn:MovieClip; var previousSub:MovieClip; var currentSub:MovieClip; // Update current and reset previous function updateSub(event:MouseEvent):void { // Only if currentBtn has a value already if (currentBtn) { previousBtn=currentBtn; previousSub=currentSub; previousBtn.prevFrame(); } // Update current value currentBtn=event.target.parent; currentSub=event.target.parent.parent; currentBtn.nextFrame(); // Prevent animation of the same movieclip if (currentSub!=previousSub) { previousSub.gotoAndPlay("off"); currentSub.gotoAndStop("selected"); } } What am i missing here, i know previousBtn is not identifying currentBtn before currentBtn is gaining a value, but how is it happening anyway and ignoring the if condition
mysterious rotationX behaviour   (101 Views)
I've got a movieclip on my stage that contains a scrollbar and a few buttons. I have a function that rotates the uses _mc.rotationX=10; After an interval the function uses _mc.rotationX=0; After the movieclip has be rotated back to its original position the scrollbar and buttons no longer receive mouse events. I don't understand whats happening. Could somebody help me thanks dub Code: private function saveClip(event:SaveClipEvent):void { model.saveClip(event._clipName); TweenMax.to(_waveEditor, 1, {rotationX: 10, ease: Sine.easeOut, onComplete: showSavedText}); //_waveEditor.rotationY=120 } private function showSavedText():void { var tf:TextFormat=new TextFormat() tf.color=0xffffff tf.font="Verdana"; tf.size=18; tf.bold=true _clipSavedText.defaultTextFormat=tf; _clipSavedText.text="Clip Saved To Your Clip List" _clipSavedText.textColor=0xffffff; _clipSavedText.x=310; _clipSavedText.y=150; _clipSavedText.selectable=false; _clipSavedText.alpha=0; _clipSavedText.width=300 _main.addChild(_clipSavedText); TweenMax.to(_clipSavedText, 1, {alpha: 1, ease: Sine.easeIn, onComplete: startClipSavedTextTimer}); //TweenMax.to(_waveEditor, 1,{rotationX:0,ease:Sine.easeIn}); } private function startClipSavedTextTimer():void { _clipSavedTextTimer.start(); } private function clipSavedTextTimerComplete(event:TimerEvent):void { TweenMax.to(_clipSavedText, 0.5, {alpha: 0, ease: Sine.easeOut, onComplete: endClipSavedTextTimer}); } private function endClipSavedTextTimer():void { _main.removeChild(_clipSavedText); TweenMax.to(_waveEditor, 0.5, {rotationX: 0, ease: Sine.easeIn}); }
Scripted filter changes MCs behaviour.   (117 Views)
I have an animated mc triggered by enter frame event to move towards the mouse position. It has a rollover function so when it reaches the mouse, it stops all movement until the mouse moves away again. It works fine until I scripted a drop shadow filter on it: now it keeps jigging about when it's supposed to be static, like it's animation is being retriggered all the time, even when the mouse is not moving at all. It doesn't do this all the time, but enough to be a real pain. If I comment out the drop shadow code it works fine again. Can anyone give me a pointer as to what might be occurring here
GC inconsistent behaviour between SA player and Web player   (119 Views)
Sen, perhaps this is something you can enlighten me on. Something I've recently implemented in my engine is freeing the RAM for a level. It's something that's pretty essential seeing as I'll have thousands of polygons per level, and a pretty large amount of textures too per level, with an average of around 150 to 200 megs of RAM being used. This obviously needs to be cleared before the next level is loaded. The process is pretty simple really, just nullify all references to everything. On the offline SA player, this works perfectly. After pressing the clear button you see the RAM usage burning down, before it snaps to around 3.7. Online it simply doesn't work. Firefox's RAM usage on the plugin container basically doesn't change, but even Flash's internal reading of the RAM usage only changes a bit. It gets reduced by a couple of megs. It makes no sense. If what I'm doing works offline, why would it not work on the web player Edit - you can see for yourself here - http://rumblesushi.com/trex.html Press C to clear the engine. The RAM usage goes down by like a meg, to 10.3, which is hugely different to how much RAM is free'd on the SA player. I've tested it on Firefox and IE, the behaviour is the same on both. Cheers, RumbleSushi
wildcards for referencing instance names   (124 Views)
I have a series of clips with instance names like box1, box2 etc. Altogether there are about two dozen. Is there any way I can run something like "box#.x = 0" where # would be a wildcard to place all instances starting in "box" I'd also love to be able to set their y position where box#.y = (#-1)*2. For that I believe I need to do a count function, but I was hoping there was another way. For other reasons I need to be able to control the instance names and not have that be automated in any way. Is this possible Searches in these forums as well as Google and a few other places have turned up nothing. It would save me a huge amount of time and work if either of these were possible without having to rework all of my instance names that are already in use. If it's relevant, I'm doing this all in Flash CS4. It seems like a purely Actionscript issue to me though so I've put it in this forum.
How to block htmlText css a:hover behaviour   (183 Views)
Problem: I have a couple of textfields with html/css formatting on them. Above these I want to show a popup with semitransparent cover background. Since the background is mouseEnabled all clicks are catched and blocked from the application below. The links do nothing when clicked. So far so good. But the a:hover on the links in the textfields still get the mouseover "events". Which makes them change color on hover, which makes you belive you can click them. I know the css behavior is separated from normal events but it seems really stupid if you don't have any way to control them. Is there a way to block the hover behaviour other than resetting the css for all the textfields That would be a very hacky solution and is very cumbersome since you then have to reset the css a:hover behaviour to all the textfields when the popup is closed.
Datagrid behaviour   (144 Views)
Is it me or it the DataGrid component in Flash CS3 completely different to the Flash 8 version and the Flex version In CS3 the cells are individually selectable which is what I dont want - I want to only be able to select rows like in Flash 8 and in Flex. Can someone help
referencing functions   (136 Views)
I was wondering if its possible to pass a reference for a function, not for what that function returns and put that reference to another function, i mean, something like that: PHP Code: functionf1(av:int){trace(av);}varob1:Object=newObject();//ob1.f2=function(){}ob1.f2=f1;ob1.f2(3);//3okfunctionf3(){};f3=f1;f3(2);//notok I mean, it works when the second function is inside an object, so how this can work when the second is not inside anything
Unexpected behaviour from MC   (110 Views)
Problem solved, syntax error.
referencing one element from another   (128 Views)
I made the mistake of purchasing one of those flash template sites. I have most of it customized, however I need to flip between gallery images when the user selects the menu item. I am very new to flash and do not know how to reference one element from another... I need the release event of the menu item (which i already have stubbed out, to trigger a tweenMenu function call... however, I don't know how to get the path of the argument to pass the object to the tweenMenu function call. I need to make this call (in theory) tweenMenu2(_root.gall, _root.xkoord[(_root.small-1)] ); however, the path to gall is: _level0.instance146.gall anyone know how i would make the above call using the correct path to gall
CS3 dynamical referencing []   (96 Views)
i have a mc located in main timeline , it is called (mc1) and its y properties are 338 now i want to tween it using only as3 so i try it like this : Code: import fl.transitions.Tween; import fl.transitions.easing.*; var number:int = 1; var myTweenY:Tween = new Tween(["mc"+ number], "y", Strong.easeOut , 338, 32 , 5, true); can any1 please explain why it doesnt work or tell me how to make it work
Class to Class method & property referencing.   (134 Views)
My example has you drag a key onto a keyhole, detect it, then run a few trace statements in methods of the various classes. This is a simple test for me to try and get a firmer grasp of how to communicate between classes. I keep getting error #1069: Property Keyhole not found on Door and there is no default value. at Key/drop() I know there's some basic syntax I'm doing wrong here, but I can't see it. Can you help IDE(FLA) I have a document class Room. On the stage I've placed a MovieClip of Door. Inside that Door Movie Clip are two more MovieClips of a keyhole, and a key. Each of these movieClips is linked to their respective class name, each of which extends MovieClip class. Room.as Code: package { import flash.display.MovieClip; public class Room extends MovieClip { public function Room() { trace("Room Class Loaded"); } } } Door.as Code: package { import flash.display.MovieClip; public class Door extends MovieClip { public var doorsUnlocked:uint; public function Door() { trace("Door Class Loaded"); } public function unlockDoor():void { trace("Door is unlocked"); doorsUnlocked +=1; trace(doorsUnlocked); } } } Keyhole.as Code: package { import flash.display.MovieClip; import flash.events.Event; public class Keyhole extends MovieClip { public var MainCollider:Key; public var hit:Keyhole; public function Keyhole() { trace("Keyhole Class Loaded"); } public function checkCollision(evt:Event):void { if (MainCollider && hit) { if (hit.hitTestObject(MainCollider)) { MainCollider.touchingKeyhole(this); } } else { MainCollider = Key(parent.getChildByName("key_inst")); } } } } Key.as Code: package { import flash.display.MovieClip; import flash.events.MouseEvent; public class Key extends MovieClip { var origX:Number; var origY:Number; var target:MovieClip; public function Key() { trace("Key Class Loaded"); addEventListener(MouseEvent.MOUSE_DOWN, drag); origX = x; origY = y; } function drag(evt:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_UP, drop); startDrag(); parent.addChild(this); } function drop(evt:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_UP, drop); stopDrag(); Object(parent).Keyhole.checkCollision(); } public function touchingKeyhole(obj:MovieClip):void //in a class you need to pass a PROPERTY { Object(parent).Door.unlockDoor(); } } }
Date() crazy behaviour   (145 Views)
Code: var d1 : Date = new Date(2010,4,13,1,10,10,10); var d2 : Date = new Date(); d2.setHours( d1.hours - 8 ); trace( d1 );//Thu May 13 01:10:10 GMT-0300 2010 trace( d2 );//Wed May 12 17:24:34 GMT-0300 2010 Anybody can explain why AS doesn't subtracts the exact 8 hours
Questions about referencing Movieclip in array   (164 Views)
all, Just learning as3. For testing purposes, I duplicated a movieclip 4 times on the stage and gave each mc a different instance name and put them in an array ("line1","line2","line3","line4"). Then I just want one movieclip to move 200 pixels based on the conditions of the array. Here is the code: var stuff:Array = new Array("line1","line2","line3","line4"); for(var i:int=0;i
clumsy code for textfield referencing   (135 Views)
I have to do a site with hundreds of input textfields which all have to be created dynamically. They are then filled from a database through php, but have to be editable. I want a way of referencing which input textfield I am writing in so I can let the database know exactly what to update and I have come up with the following code as an example of something that works OK. I think it's probably a clumsy way of doing things, despite the fact that it works. Can anyone give me some tips for a better way of coding this please ActionScript Code: var i:uint; var myArray:Array = new Array(); var selectedBox:String; for(i = 0; i
How to attach button behaviour to displayObject?   (128 Views)
If I am using Loader to load external swfs, can I give them button behaviours
Question for MAC-users about Flash mouse behaviour   (114 Views)
fellow Mac-Kirupians, We're in the final stages of creating a Flash-site for one of our clients, and we're getting some very strange bug-reports. These "bugs" can only be related to Flash keeping track of mouse movements, even when the mouse has left the browser window. On PC, this doesn't happen. But is it true that it does happen on Macs Because unfortunalely, we have no Macs to test on in the office a.t.m. : (