ActionScript 2.0 :: MX: OnRelease Defined In For Loop - Always The Same?
Mar 7, 2005
I'm trying to have a bunch of buttons generated in a for loop, and I want the onRelease function defined so that each button has a unique e-mail address attached to it.As it stands now, all the buttons are being assigned the last e-mail address in the XML file. I've got more code in my actual file that creates text fields on top of the buttons, and they're displaying the correct info, so it's only the onRelease function that isn't working...Here's the abridged code:
var xmlPeopleList:XML = new XML();
xmlPeopleList.ignoreWhite = true;
xmlPeopleList.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
So I'm trying to have a bunch of buttons generated in a for loop, and I want the onRelease function defined so that each button has a unique e-mail address attached to it.As it stands now, all the buttons are being assigned the last e-mail address in the XML file. I've got more code in my actual file that creates text fields on top of the buttons, and they're displaying the correct info, so it's only the onRelease function that isn't working.[code]
I am designing and coding a navigation menu at the moment, and so far I have got the button instances to duplicate for each of the menu items, and set widths, positioning values and RollOver/RollOut functions. However, I would ideally like to include the onRelease button functions in the for loop too - as they are all the same apart from the variable "i". Here is the code snippet:
ActionScript Code: for (i=1;i<(_root.noofmenuitems+1);i++){ duplicateMovieClip("mc", "mc"+i, i);
[code]...
Now my problem is that by the time the onRelease function is called, the for loop has been completed and the value of i returned is the last i value from the loop (_root.noofmenuitems+1). The this["mc"+i] part obviously works, because the trace function is called when I click any of the menu items.The problem is that I have 6 menu items, and when I click any of them, the trace function returns "test 7" - not the corresponding i values for each button.
I am having a hard time trying to use an onRelease event handler inside a for loop. Basically, I am developping a custom player for articulate presenter using flash and AS2.This code is generating a movie clip in a for loop for each line in the sidebar, with slide title and slide number parsed from a XML.Until here, all works fine.But when I try to generate the onRelease event handler to play the wanted slide when I click on the line, the value inside the onRelease is always the highest value of i.Looks like the onRelease evaluates i only when I click on the line, after all the clips have been generated.[code]I have to find a way to capture the value of i for each clip.
I have a loop to create clip buttons w/jpg images on face && load same jpgs into main viewer clip. Problem is, the mc buttons won't respond to onRelease.
for(i=1;i<3;++i) { var mc = "mc"+i; // button mc clip names
I am making a few drag and drop games that work great when I hard code them. When I use a FOR loop and name = eval("something"+i+"_mc") everything works great. I can assign startDrag to all MCs, I can make it stop drag, and so on. But when I try to do a hitTest, it only works for the highest value of [i] in the FOR loop. It will still assign text to all the dynamic text boxes in each MC, and do the dragging stuff, but it won't do a hitTest for anything other than the highest value.
I've searched several sites and have found things about Delegate.create, using [this.i] rather than just [i], and much more. The problem is it always partially or half works. It won't just break, it will either let both drag and only acknowledge one hitTest, or ignore the stopDrag or whatever else. Either they both partially work, or only the highest [i] value is acknowledged.
I have another question about my For loop. I am designing and coding a navigation menu at the moment, and so far I have got the button instances to duplicate for each of the menu items, and set widths, positioning values and RollOver/RollOut functions. However, I would ideally like to include the onRelease button functions in the for loop too - as they are all the same apart from the variable "i". Here is the code snippet:
Here my attempt at creating the Kirupa's Spinning Images gallery. I'm so damn close it somewhat works, I'm still having trouble with the rotational calculations. Not sure, but I think I might be passing the wrong values from the onRelease to the enterFrame loop?
spin3a.fla var world:Array = []; var rotate = 0; var fl = 1000; var clip; function spin() { [Code] .....
I want to loop through an array of mc's, and assign each a onRelease function. I have the following code but the trace inside the function doesn't seem to find the array.I understand why but what is the correct way of doing this?
ActionScript Code: var theArray:Array = new Array(); var j:Array = new Array();[code].......
I am using flex builder 3.2, Action Script 3 and develop for Flash Player 10 and am quite new to it. when I call a method of a self defined class, I get the 1061 error (not defined). But the class and the method exist and are public, so what the hell am I doing wrong? Flash Builder is even offering me this method in the auto-completion, so at least the builder knows it... I have already tried cleaning the project (as this is the common source of strange errors when working with java/eclipse),
edit: solved... The problem was that a package had the same name as the variable I used for the class. Very strange error message, thumbs down for this .
It is called Play_button. This time I ran it and got a different error, (Access of undefined property Play_button)but is still in the same direction as the first one.
I have seen a few posts regarding: ReferenceError: Error #1065: Variable is not defined, but none solving this issue.I have just upgraded to CS4 from CS3. I compiled and run the projects built in CS3 and get this error on loads of MovieClip classes available in the Library.ReferenceError: Error #1065: Variable Movieclip_mc is not defined.Sounds like there is a difference in the compilers that is kicking this error up. I have tried creating a new central .fla document in CS4 and stil no good.
I'm building an AIR application with Flash Builder 4. in the application descriptor I set the minimum AIR version to 3.0 I'm building against Flex SDK 4.5.1 which I overlayed with the AIR 3.0 SDK
I have this line of code in my app:
var nativeWinOpt:NativeWindowInitOptions = new NativeWindowInitOptions(); nativeWinOpt.renderMode = NativeWindowRenderMode.GPU;
this compiles fine, but when I run it in ADL, I get:
ReferenceError: Error #1065: Variable flash.display::NativeWindowRenderMode is not defined.
NativeWindowRenderMode should be available in AIR 3.0?
I am trying to modify a menu system that I like that I found on the web I thought this would be easy enough to modify and make each named menu item a hyperlink.The menu items are dynamically created depending on the number of items in an array. I thought I could create another array and add an eventListener to each menu item created with a hyperlink from the second array:
ActionScript Code: public var menuLinks:Array = ["/about", "/portfolio", "/photos", "/blog", "/contact", "/guest_book"];
I'm displaying a variable into a textbox, but sometimes it's value is unset (loading delay) I'm using loadVariables so the .onLoad won't work.. How can I check if a variable already has a value?
I have a "onRelease function" CODE: btn_4.onRelease = function () { var yTween = new mx.transitions.Tween(slider, "_x", mx.transitions.easing.Strong.easeOut, slider._x, 695 , 0.600000, true); } This works good but I like to add in a "onRelease" play sound, too. How it have to look like and where do I have to place the sound? Because: When I add in a new function "onRelease" both block each other.
I have a Red Cup which is a MC and I want the Red Cup to go UP when clicked on and goes back down when you release the mouse click. I know the coding is On(press) { and On(release) { But I do not know the details.
I am trying set up a simple onRelease function of a button in AS2 within a class file but this is not allowed. It's been ages since I have worked in AS and have a client who needs some work done by a previous developer. why I cannot just use myButton.onRelease = function ()....Here's a sample of the AS2 snippet
Code: public function callFunction(functionString:String) { var functionItems:Array = functionString.split(","); var functionName = functionItems.shift();
I'm writing a program that has a button, and when pressed, and the shift key is pressed, will do an action. I have an onRelease function for that button also, but for some reason when I have the button pressed, and I press shift or any other key, it automatically thinks the button is being released. I was using the onMouseDown, onMouseUp functions before, but they caused me a lot of problems aswell.
Try it for yourself:
Code: btn.onPress = function() { trace("pressed"); //now hit a keyboard button }
I'm making a contact form, and I keep getting two errors when I try previewing it in a web browser.
ReferenceError: Error #1065: Variable Button is not defined. ReferenceError: Error #1065: Variable ComponentShim is not defined.
I don't know what these errors mean. Can anyone give me an explanation? I am using Flash CS4 with ActionScript 3.0. The first function is for the contact button to go to the contact page. The code following is the code for the contact form.Here is my code for the contact form:
Code: function onContactClick(e:MouseEvent):void { gotoAndStop("contact");[code]............
I try to load some images from urls, but the index of the function fixSize, is out of the array limit exactly by 1(index=total). I know this by using the debugger.
Actionscript Code: ...//vars are definedvar imageMvc:Array = new Array(); function insertImages() :void{for (var i:int = 0; i < total; i++){var l:Loader = new Loader();l.addEventListener(Event.ADDED, function(){ fixSize(i)});l.load(new URLRequest(images[i]));imageMvc[i] = new MovieClip(); imageMvc[i].x = 160 + i * 80;imageMvc[i].y = -35;imageMvc[i].addChild(l); imageMvc[i].width = 70;imageMvc[i].height = 70; addChild(imageMvc[i]);}}function fixSize(index: int):void{ imageMvc[index].width = 70; imageMvc[index].height = 70;}...
In this case, total=4 and I trace that fixSize is called with the argument index=4. So of cource I get an error which said that imageMvc[4] is not defined.
In my Flash, when I have created a document "AIR for Android" with the sdk emulating working (and having installed de Air 2.5 in it), when i clic on "Configuration of Air Android..." appears the error:
"Apollo_OpenSettingDialog.jsfl":ReferenceError: Air2_5_Android is not defined