ActionScript 2.0 :: OnRelease Not Working Within XML For Loop
Jun 30, 2010I have set up the XML as follows:
[Code]...
I have set up the XML as follows:
[Code]...
I'm tring to add a onRelease event into every button I have, code like
for(var i = 1; i <= totalPage; i++){
_root['button'+i].onRelease = function(){gotoPage(i-1)};
}
why its doesnt work. I have to do like following
button1.onRelease = function(){gotoPage(0)};
button2.onRelease = function(){gotoPage(1)};
button3.onRelease = function(){gotoPage(2)};
[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.
View 2 RepliesI'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) {
[code]....
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
[code]......
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.
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]
View 1 RepliesI'm trying to display thumbnails with a for loop but i would like that each thumbnail have an onrelease action.
here is my scriptnote: i use trace() for look if my loop works aswith the onrelease function)
HTML Code:
var posX = 163;//1st position
var posY = 103;//1st position
var Dec = 0;// var for the space between thumbnails set to 0
[Code].,...
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:
[Code]...
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 have two buttons. Each one calls in an external swf. I would like one of them to call it in onRollOver but nothing happens. It works fine when I change it to onRelease.This is the code I have for the two.
Code:
// Instantiate MovieClipLoader Class
var thumbloader:MovieClipLoader = new MovieClipLoader();
case_btn_1.onRollOut = function() {
[code]....
I have a serious situation regarding the onRelease Funciton not working properly.I have a FVLplayback componant inside a flash project inside a movie clip. Inside that movie clip I have two layers, One for actionscript and and the other for the actual component which contains instance name of 'myPlayer' (without quotes)[code]That cameraRoll is the instance name of another movie clip I have located in the movie clip as shown in path above. Inside that movie I have rollover, Rollout effects. The actionscipt is in an invisible button right on top of the objects. The actionscript is:[code]The objective: the movieclip to carry out the rollover Rollout effect and to have the function that will start the video.The Problem: When I run the flash project, it does the effect but won't start the video. If i move things around, I can have the video start playing but then the button won't do the rollOver, RollOut effects.
-the path to the video component:-root.menu.video
-the path to the movie clip taht contains the timeframes for rollOver/rollOut effects )which contains invisible button on top of everything. root. menu.cameraRoll
I have two buttons. Each one calls in an external swf. I would like one of them to call it in onRollOver but nothing happens. It works fine when I change it to onRelease.[code]
View 1 Repliesi have a movieclip on the main timeline, and inside that mc I have 1 button on first frame and 1 button of second frame...From the main timeline i run this script for frame 1 button...
publisering2.avpubliser_btn.onRelease = function(){
publisering2.gotoAndStop(2);
}
And this works fine.. however, i run the exact same script for the button on frame 2, ofcourse changing the path and gotoAndStop(1) instead... And this isnt working.. The button's over frame works so its activated...
I am working in CS4, but using as2 as the publish setting since the swf I need to load in was previously done in as2.I have an interface that I am loading a logo.swf into. This logo has animation that works properly both in test and in the browser. There is, however, a function in the logo.swf that is not working.
this.onRelease = function() {
getURL("http://www.yourdomainhere.com");
}
When I test with the IDE this is clickable within the interface, but when I view via the webpage it is not. AllowScriptAccess was set to sameDomain, but I have also tried that set to always.
I can't get my getURL to work. It works when I use "_blank" but not when I use "_self" or "_parent" or "_top" or leave it empty. I've got it right off the main timeline. I've also tried putting it within an onRelease function.
So, this doesn't work:
Code:
getURL("images/aboutus.jpg", "_self");
But this does:
Code:
getURL("images/aboutus.jpg", "_blank");
why?
//This doesn't work
my_mc.onEnterFrame = function() {
this.alphaTo(1,1,"easeoutSine");
[code]........
Its suppose to create a Movie called container which has a text field in it then when the container movie clip is clicked on "Goodbye World" pops up in the trace window.So far the only thing this code does is display "Hello World" but no action is taken when it is clicked on.
Code:
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var label:TextField = this.createTextField("label", 1, 0, 0, 150, 20);
label.text = "Hello World";
[code]....
I am new to Flash/Actionscript and am having problems getting some movieclips to link to different URLs on release. I am able to get them to animate, and I am able to get them to link to an html page in the same folder, but I can't get both functionalities to work at the same time. I've tried putting the actionscript in the instance object, in the action layer, and other things and nothing seems to work!?
Here is the link to the source file: [URL] believe that the actionscripting needs to be done in the "banners" movieclip, but it could also be the "Symbol 3" movieclip. Here is also a link to the .swf [URL]. See, if you mouse over the first two clips, they animate, but they do not go to the HTML page if you click on them [URL]. The third clip will go to the page success1.html in the same folder if you click on it, but it does not animate on mouse over.
the seven dots u see on the stage are 7 emptymovieclips. i've coded the action script to load the thumbnails in 6 emptymovieclips on left side arranged in grid.script is working fine till 6 thumbnails are loaded in the grid.(from externel xml file as i've coded)as logically u can guess that, when we click on a thumbnail, it's bigger copy should be loaded in the black square on he stage. but it is not happening ; i;ve coded for it also ;in the following script u can see that the last command is:
_root.thumb0.onRelease = function() {
trace ("clicked");
}
it should dispaly "clicked" on output window when thumb0 is clicked but it isn't showing anything. not any error even. the above line is in firstframe's action script; and it must should work from here only, not under the AS of thumb0 movieclip.
//////////////////////////////////////////////////////actionscript for the first frame of layer1///////////////////////////////////
xmlData = new XML();
xmlData.ignoreWhite = true;
[code]...
I am trying to load images into movie clips then add a .onRelease to then dynamically so that when a user clicks on one it will pop up a bigger image of what they clicked on in a box.The images load in just fine but when i click on them i get nothing. Here is the code:
Code:
var tdata:String;
var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
[code]...
I'm loading an item to the stage and trying to apply a function to it but it doesn't seem to work.
Code:
_root.attachMovie("FullScreenBTN","FullScreenBTN",_root.getNextHighestDepth());
_root.FullScreenBTN.onRelease = function(){
trace("test")
}
When I press the button nothing happens, but when I remove the attach code and just put the button on the stage with the appropriate instance name it does work.
Is there a way to ADD onRelease method on movieclip that already has a onRelease method? Without replacing the first one.
ActionScript Code:
mc.onRelease = function(){
trace('1');
}
I was thinking this, but it doesn't work
[Code]...
PHP Code:
var trail1:MovieClip=new trail_1;
var trail2:MovieClip=new trail_2;
var trail3:MovieClip=new trail_3;
[Code]....
This is what I want to happen but attempt at making a for/while loop gives me this:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at momentum_fla::MainTimeline/frame1()
PHP Code:
var i:Number = 1;
while(i < 7){
var NameTemp:MovieClip=new ["trail_"+i];
[Code]....
Why does the first loop work but not the other?[code]
View 5 RepliesI have a project I am working on in Flash CS3 using AS3.I have a drag and drop quiz that contains 8 boxes. 4 of the boxes contain dynamic text boxes with the vocabulary words. 4 of the boxes contain the definitions to the vocab words. The students drag and drop the vocab words onto the definitions. My issue is that hitTestObject is only working on the first box everytime. I have a for loop in my endDrag code that should loop through each object and test against it to see if there is a hit. Can anyone see anything wrong with my loop?
View 2 RepliesI create 30 text fields dynamically on the stage and want to set text format for all text fields. I use 'setTextFormat'. It works fine for single text box. But not working if I give this in loop. See the code below. It creates thirty input text boxes on the stage. But it assigns text format only to the last text box. When code Copied and placed in frame 1. The stage size should be 800 x 600. Execute the program and type in the last text field. I want that to happen for all text boxes.
ActionScript Code:
var xtpos:Number = 10;
var ytpos:Number = 10;
var i,j:Number=0;
var depth:Number = 100
var k:Number=0;
[Code] .....
In the above it traces only the last text field.
I am having some trouble with some code. buttons are not working.
Code:
menuLoc = new Array("menu_main", "menu_philosophy", "menu_portfolio", "menu_resume", "menu_contact");
for(i=0; i < menuLoc.length; ++i){
_level0.navMenu.menuLoc[i].onRelease = function() {
trace("hit");
}}
The array has the instance names of the movieclips which are located in navMenu.