Trouble Adding Eventlistener In Loop
I'm having trouble adding this eventlistener in a simple loop. Can somebody tell, why the eventhandler doesn't get triggered?
Code: // handler function countryHandler(e:MouseEvent) { trace(e.currentTarget.name); }
// add eventlistener loop for (var i:Number = 0; i < isoCountriesArr.length; i++) { var tempId:String = isoCountriesArr[i]; if (map_mc.getChildByName(tempId) != null) { var tempCountryMc:MovieClip = MovieClip(map_mc.getChildByName(tempId)); countryArray.push(tempCountryMc) tempCountryMc.addEventListener(MouseEvent.CLICK, countryHandler); } }
FlashKit > Flash Help > Actionscript 3.0
Posted on: 05-14-2008, 08:33 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
AS3: Adding Parameter To EventListener
hi everybody.
i'd like to know how to pass a parameter to my function through an eventListener.
to illustrate, I've made this example:
http://campjohn.dk/AS3/addingParamet...ntListener.swf
by clicking the boxes on the left, the bigBox centrered changes color.
nice!
right now, I have to use a if else-loop:
Code:
//imports
import caurina.transitions.Tweener;
this.blueBox.addEventListener(MouseEvent.CLICK, changeColor);
this.redBox.addEventListener(MouseEvent.CLICK, changeColor);
this.yellowBox.addEventListener(MouseEvent.CLICK, changeColor);
function changeColor(e:Event):void {
trace("CLICKED: e.target.name = "+e.target.name);
if(e.target.name == "blueBox"){
Tweener.addTween(this.bigBox, {_color:0x0000FF, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "redBox") {
Tweener.addTween(this.bigBox, {_color:0xFF0000, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "yellowBox") {
Tweener.addTween(this.bigBox, {_color:0xFFFF00, time:1, transition:"linear"});
trace("changing color to blue");
} else {
trace("this shouldn't be possible");
}
}
can I somehow change the example above so it passes the color to use to the function as a parameter instead?
thanks
felisan
AS3: Adding Parameter To EventListener
hi everybody.
i'd like to know how to pass a parameter to my function through an eventListener.
to illustrate, I've made this example:
http://campjohn.dk/AS3/addingParamet...ntListener.swf
by clicking the boxes on the left, the bigBox centrered changes color.
nice!
right now, I have to use a if else-loop:
Code:
//imports
import caurina.transitions.Tweener;
this.blueBox.addEventListener(MouseEvent.CLICK, changeColor);
this.redBox.addEventListener(MouseEvent.CLICK, changeColor);
this.yellowBox.addEventListener(MouseEvent.CLICK, changeColor);
function changeColor(e:Event):void {
trace("CLICKED: e.target.name = "+e.target.name);
if(e.target.name == "blueBox"){
Tweener.addTween(this.bigBox, {_color:0x0000FF, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "redBox") {
Tweener.addTween(this.bigBox, {_color:0xFF0000, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "yellowBox") {
Tweener.addTween(this.bigBox, {_color:0xFFFF00, time:1, transition:"linear"});
trace("changing color to blue");
} else {
trace("this shouldn't be possible");
}
}
can I somehow change the example above so it passes the color to use to the function as a parameter instead?
thanks
felisan
AS3: Adding Parameter To EventListener
hi everybody.
i'd like to know how to pass a parameter to my function through an eventListener.
to illustrate, I've made this example:
http://campjohn.dk/AS3/addingParameterToEventListener/addingParameterToEventListener.swf
by clicking the boxes on the left, the bigBox centrered changes color.
nice!
right now, I have to use a if else-loop:
Code:
//imports
import caurina.transitions.Tweener;
this.blueBox.addEventListener(MouseEvent.CLICK, changeColor);
this.redBox.addEventListener(MouseEvent.CLICK, changeColor);
this.yellowBox.addEventListener(MouseEvent.CLICK, changeColor);
function changeColor(e:Event):void {
trace("CLICKED: e.target.name = "+e.target.name);
if(e.target.name == "blueBox"){
Tweener.addTween(this.bigBox, {_color:0x0000FF, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "redBox") {
Tweener.addTween(this.bigBox, {_color:0xFF0000, time:1, transition:"linear"});
trace("changing color to blue");
} else if(e.target.name == "yellowBox") {
Tweener.addTween(this.bigBox, {_color:0xFFFF00, time:1, transition:"linear"});
trace("changing color to blue");
} else {
trace("this shouldn't be possible");
}
}
can I somehow change the example above so it passes the color to use to the function as a parameter instead?
thanks
felisan
Trouble Removing EventListener
The rest of the code appears to be working, but the EventListener won't go away.
Can anyone see what's wrong?
Thanks much.
Code:
// Create an MC to hold global vars:
var globals:MovieClip = new MovieClip();
addChild(globals);
globals.currentMC = "";
showSection (mc_cuss);
function showSection(who:MovieClip):void {
globals.currentMC = who;
globals.currentMC.gotoAndPlay(1);
globals.currentMC.addEventListener(Event.ENTER_FRAME, setNavBtns);
} // End Function
// When currentMC has finished, stop
function setNavBtns(e:Event):void {
trace (globals.currentMC.name);
if (globals.currentMC.currentLabel == "endIntro") {
trace ("Current Frame label is endIntro");
globals.currentMC.removeEventListener(Event.ENTER_FRAME, setNavBtns);
}
};
/*
Output:
mc_cuss
mc_cuss
mc_cuss
mc_cuss
mc_cuss
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
mc_cuss
Current Frame lable is endIntro
*/
Trouble With Remoting Connector EventListener
i have a flashremoting connector component called insertComment_con
when triggered.
the remoting component does make the connection and the cfc method.
but the problem is the eventListener I can't capture the onSuccess.
even though it does make the connection I get the error listener being called.
this is the trace.
Error - fault - Variable results is undefined.
Code:
insertComment_con.addEventListener("result",insertComment_conSuccess);
insertComment_con.addEventListener("status",insertComment_conError);
function insertComment_conError(stat:Object) {
trace("Error - " + stat.code + " - " + stat.data.faultstring);
}
function insertComment_conSuccess(ev:Object) {
trace("Blog updated");
}
EventListener In For Loop
Hey everybody
I found a lot of information on this site. Great job!
Now I came over a problem wich is really strange. I'm parsing a XML File and loop some nodes to create Links. On each link i'm going to add EventListeners for MouseDown, MouseOver and MouseOut actions.
It works perfectly. But the first Link (Index 0) is not working. It doesnt add an EventListener to it. I can't see the problem, can you help me?
Code:
function loadXML( xmlpath:String ) {
var xmlloader:URLLoader = new URLLoader();
xmlloader.load(new URLRequest( xmlpath ));
xmlloader.addEventListener( Event.COMPLETE, parseXML );
}
function parseXML( e:Event ) {
var xml_document:XML = new XML(e.target.data);
xml_document.ignoreWhitespace = true;
var titel:Titel= new Titel();
titel.titel.text = xml_document.Titel.text();
titel.alpha = 0;
titel.x = xml_document.Titel.@x;
titel.y = xml_document.Titel.@y;
addChild(titel);
for (var i:int = 0; i<xml_document.Links.Link.length(); i++) {
Links[i] = xml_document.Links.Link[i].text();
Links[i][1] = xml_document.Links.Link[i].@url;
Links[i][2] = xml_document.Links.Link[i].@color;
Links[i][3] = xml_document.Links.Link[i].@rollover;
}
setElements();
}
function setElements() {
for (var j:int = 0; j < Links.length; j++) {
var Link:MovieClip = new MovieClip();
/* Background */
var Background:MovieClip = new MovieClip();
Background.graphics.beginFill(0xFF0000);
Background.graphics.drawRect(0, 0, 200, 14);
Background.graphics.endFill();
Background.alpha = 0;
Background.name = "Background";
Background.x = 0;
Background.y = (j*19)+2;
Link.addChild(Background);
/* Icon */
var LinkIcon:linkicon = new linkicon();
LinkIcon.y = j*19;
LinkIcon.mouseEnabled = false;
Link.addChild(LinkIcon);
/* Text */
var color = "0x"+Links[j][2];
var Format:TextFormat = new TextFormat("Verdana", 12, color, true);
var Text:TextField = new TextField();
Text.x = 15;
Text.y = j*19;
Text.autoSize = TextFieldAutoSize.LEFT;
Text.text = Links[j][0];
Text.setTextFormat(Format);
Text.mouseEnabled = false;
Link.addChild(Text);
/* Rollover Linie */
var Line:MovieClip = new MovieClip();
Line.graphics.beginFill(0xFFFFFF);
Line.graphics.drawRect(0, 0, Text.textWidth, 1);
Line.graphics.endFill();
Line.alpha = 0;
Line.name = "Line";
Line.x = 17;
Line.y = (j*19)+15;
Link.addChild(Line);
Background.addEventListener(MouseEvent.MOUSE_DOWN, linkaction);
if(Links[j][3] == "ja"){
Background.addEventListener(MouseEvent.MOUSE_OVER, linkaction);
Background.addEventListener(MouseEvent.MOUSE_OUT, linkaction);
}
LinkBox.addChild(Link);
}
}
Thank you
Adding Eventlistener At Runtime, Error #1006
Hii guys
I'm a newbie in AS3 working with flex
I have a custom control named as Frame
I'm adding a event listener to frame object
and have to call the function for event handling
where I want the objFrame, where I could do some functioning
on it
I dont know how to add a listener to a object at runtime n calling the
listener function and passing some values to it.
Below is my code
I'm getting the error
TypeError: Error #1006: value is not a function.
at presentation/FrameClick()[E:aFlex workspaceCreatorsrcpresentation.mxml:82]
plz help me out
its urgent
some function
{
for(var intD:int=0;intD<intNoOfFrames;intD++)
{
var objTmpFrame:Frame=new Frame();
objTmpFrame.height=intHeight;
objTmpFrame.width=intWidth;
strFrameId="FrameNo:"+(intD+1);
objTmpFrame.id=strFrameId;
objTmpFrame.graphics.beginFill(0x0000ff);
objTmpFrame.addEventListener(MouseEvent.CLICK,Fram eClick); //adding the
//listener at runtime n calling the function frameclick
MainMiddleVbox.addChildAt(objTmpFrame,intD);
}
lblCurrentFrame.text="Frame:1";
}
private function FrameClick(event:MouseEvent):void
{
LINE:82 var objCurrentFrame:Frame=event.currentTarget() as Frame;
var objAmanda:amanda=new amanda();
}
thanks in advanx
Eventlistener To Sprite In Loop?
Ok, I have a loop which loops out 10 empty movie clips and then adds 10 sprites inside those movieclips.
What I want to do is to change the alpha of the sprite I hover. But since I can't add eventlistener to the sprite how can change it's alpha?
Can't just use:
PHP Code:
private function hoverSprite(event:MouseEvent)
{
spritename.alpha = 0.5;
}
Because then only the last looped sprite will change alpha then.
Eventlistener To Sprite In Loop?
Ok, I have a loop which loops out 10 empty movie clips and then adds 10 sprites inside those movieclips.
What I want to do is to change the alpha of the sprite I hover. But since I can't add eventlistener to the sprite how can change it's alpha?
Can't just use:
PHP Code:
private function hoverSprite(event:MouseEvent)
{
spritename.alpha = 0.5;
}
Because then only the last looped sprite will change alpha then.
Eventlistener To Sprite In Loop?
Ok, I have a loop which loops out 10 empty movie clips and then adds 10 sprites inside those movieclips.
What I want to do is to change the alpha of the sprite I hover. But since I can't add eventlistener to the sprite how can change it's alpha?
Can't just use:
PHP Code:
private function hoverSprite(event:MouseEvent){spritename.alpha = 0.5;}
Because then only the last looped sprite will change alpha then.
[F8] Adding Eventlistener To Geturl After A Specific Flv Is Finnish Playing
my evenlistener is able to get a url after my video player finish playing
but i need it to be specific after the dvd.flv video finish the function is executed please see coding below, i would appreciate some help
stop();
attachMovie("FLVPlayback", "myplayer", 1);
myplayer._x = 415;
myplayer._y = 203.1;
myplayer._width = 320;
myplayer._height = 240;
myplayer.autoPlay = true;
myplayer.activePlayControl = true;
myplayer.controllerPolicy = "on";
myplayer.totalTime = 0;
myplayer.bufferTime = 3;
myplayer.autoSize = true;
myplayer.skinAutoHide = false;
myplayer.maintainAspectRatio = true;
myplayer.volume = 110;
myplayer.playButton = playbtn;
myplayer.pauseButton = pausebtn;
myplayer.backButton = backbtn;
myplayer.muteButton = mutebtn;
myplayer.seekBar = seekbtn;
//myplayer.volumeBar = volumebtn;
//myplayer.bufferingBar = BufferBar;
myplayer.contentPath = "videos/dvd.flv";
video1_mc.onRelease = function() {
myplayer.contentPath = "videos/interview.flv";
};
video2_mc.onRelease = function() {
myplayer.contentPath = "videos/dvd.flv";
};
var displayListener:Object = new Object();
displayListener.complete = function() {
getURL("http://www.woolworths.co.uk/ww_p2/product/index.jhtml?pid=50787969");
};
myplayer.addEventListener("complete", displayListener);
video3_mc.onRelease = function() {
myplayer.contentPath = "videos/Demoreel.flv";
};
Adding EventListener MouseEvent Click To Existing Mc Which Aleady Has Alpha Motion...
hi, my name's jude and i'm an author designing a site for my new publishing company. i want to use a flash button on the site and am having problems finding the right actionscript. i'm a total nOOb in actionscript but i promise i've done lots of research into this - however the only tutes i can find are for starting from scratch making movie clip buttons.
all i want to do is add the actionscript for a mouse click which takes you to the desired URL, to this existing code controlling the motion of the movie clip.
onClipEvent(load)
{
dir = 0;
speed = 6;
original._alpha = 0
this.onRollOver = function()
{
dir = 1;
}
this.onRollOut = function()
{
dir = -1;
}
useHandCursor = true;
}
onClipEvent(enterFrame)
{
temp = original._alpha + speed*dir;
original._alpha = Math.min(100,Math.max(temp,0));
}
you can see the completed .swf (before i changed the HandCursor to true) here.
and here are screenshots of the relevant pages in flash
http://i250.photobucket.com/albums/g...reenshot-1.jpg
http://i250.photobucket.com/albums/g...reenshot-2.jpg
http://i250.photobucket.com/albums/g...in/scene-1.jpg
- i would be so grateful for any help from you guys (and, i presume, girls!) - many thanks in advance.
Trouble With Adding A New Scene
Hi,
I have a main scene that begins with a animation. Now when i add a new scene to house a preloader and place it above the main scene and play the movie the preloader works fine but when it plays the next scene everything stops at frame 1. At 1st I thought it was my preloader but i tripled checked it and it was fine, I also just added a blank scene but i get the same problem. Im using flash 8. ne 1 ever get this problem?
thx
Having Trouble Adding A SWF File To Vb.net
Ok so I found this on a help site somewhere but I can't seem to locate the Shockwave control in VB.net. I am currently using the trial version of Flash 8 and vb.net from 2002. Are my versions incompatible?
VB.Net
Right click on the tool box. Select “Add/Remove Items…”. Select “COM Components”
Select “Shockwave Flash Object”. Click OK
Draw it on the form
Name it “SF1”
Adding Load Bar Trouble
hey guys, i think i posted this once before but i still havnt gotten a solution.
basically what i want to achieve is a site like the "Preloader and Transition for Dynamic Files" tutorial but where it says "loading" i want to replace with a loading bar. now i thought this would be pretty simple and straight forward but as hard as i try to make it work, it wont
this is my best guess so far in the 'content' actionscript
onClipEvent (enterFrame) {
if (!loaded && this._url != _root._url) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.transition.loadBar._width = getPercent*100;
_root.transition.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
loaded = true;
_root.transition.gotoAndPlay("opening");
}
}
}
i thought that should work but it doesnt? can anyone help me out? ill really appreciate some help.
cheers, evan
Adding Load Bar Trouble
hey guys, i think i posted this once before but i still havnt gotten a solution.
basically what i want to achieve is a site like the "Preloader and Transition for Dynamic Files" tutorial but where it says "loading" i want to replace with a loading bar. now i thought this would be pretty simple and straight forward but as hard as i try to make it work, it wont
this is my best guess so far in the 'content' actionscript
onClipEvent (enterFrame) {
if (!loaded && this._url != _root._url) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.transition.loadBar._width = getPercent*100;
_root.transition.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
loaded = true;
_root.transition.gotoAndPlay("opening");
}
}
}
i thought that should work but it doesnt? can anyone help me out? ill really appreciate some help.
cheers, evan
Trouble Adding .mp3 To Project
Hello, I have just started to play around with Flash this week and I am having trouble importing an .mp3 file to my project. It gives me the error, "One or more files were not imported because there were problems reading them". However, this is only for certain .mp3 files. I can import some .mp3's, just not all of them. They all exist in the same folder and I made sure that the file name were legit. I am completey lost, so if anybody could help, I would appreciate it!
Regards,
Corey
Still Having Trouble Adding Link To Swf File
Hey There,
I'm still having difficulty adding a hyperlink to an swf file... i tried adding the 'get url' action into the graphic itself, even changed it into a movie behavior- but for some reason when i go to 'basic actions', and scroll down to the 'on mouse event' or 'on clip event', they aren't highlighted- so i can't choose them.
so- essentially. i want the animation to loop, but i only want the url link to open if someone clicks on the animation. the animations i want to become hyperlinks are at the bottom of this page: http://www.lynnguppy.com/johnnyfish.htm
? any more help ? i know i'm probably missing something simple. but i guess that's why i'm a newbie.
thanks for your kind indulgence, lynn
Having Trouble With Dynamic Text Adding, Etc
Hello, Ive gotten lots of help here for my dynamic text and this is the last thing to complete my site.
What I have is a main scene with 2 movie clips
one movie clip you make a selection
the other movie clip shows the total cost, adding or subtracting the amount of your choice.
Its confusing so ill show you what code I have
On first frame of the main scene
Code:
_root.baseprice=700;
_root.surfaceprice=0;
_root.cupprice=0;
_root.legprice=0;
_root.addonprice=0;
_root.total_price=_root.baseprice + _root.surfaceprice + _root.cupprice + _root.legprice + _root.addonprice;
In the movie clip where I want to display the total (named "right"), i have a dynamic text field var: named "total_price" and this code in the first frame of the clip
Code:
_root.right.total_price=_root.total_price;
Now this displays the "700" like it should. But I want it to change as i make my selections in the other movie clip.
So I have this code for 3 buttons, one button makes the value 0, one 100, and one 200.
Code:
//first button
on (press) {
_root.surfaceprice =0;
//different button
on (press) {
_root.surfaceprice =100;
//last button
on (press) {
_root.surfaceprice =200;
So, in theory, shouldnt pressing these buttons change the value of the "_root.surfaceprice" in the main scene, then in turn chang the value of the "total_price" in the other movie clip?
Thank you for the help.
Brian
Trouble Adding Flvplayback Flash Cs3
Hi,
I can't seem to add the flvplayback component to the stage to a flash actionscript 3 file (for that matter my video imports seem to fail as well)---i have no trouble doing it in a action script 2 file though.
any advice?
thanks.
FMS 2 - Trouble Adding Application (CentOS)
Hi,
Very recently I managed to install on a CentOS 4.4 platform. I checked what services were running:
./fmsmgr list
21937 pts/0 00:00:00 fmsmaster
32580 pts/0 00:00:00 fmsadmin
I tried to develop my first test application found in 'Learning Flash Media Server 2' book. After creating the subfolder under applications folder, I them tried to add the application inside the Admin Console. The application was added momentarily and then disappeared. I went to check the messages log and by stopping and starting the fms server I was able to isolate the weird Failed messages below:
Jul 27 14:21:49 popcodestudio 257[21937]: Server starting...
Jul 27 14:21:49 popcodestudio Server[21937]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio 257[21937]: Server started (/opt/macromedia/fms/conf/Server.xml).
Jul 27 14:21:49 popcodestudio Server[21950]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio Server[21953]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio Adaptor[21950]: Listener started ( _defaultRoot__edge1 ) : 19350
Jul 27 14:21:50 popcodestudio Adaptor[21950]: Failed to create thread (TCProtocolAdaptor::startListenerThread).
Jul 27 14:21:50 popcodestudio Adaptor[21950]: Failed to start listeners for adaptor _defaultRoot__edge1.
Can anybody help me please, I couldn't find any help anywhere on the WEB.
Thanks a lot
Trouble Adding Commas To String
I'm using code I found on this site to add commas to a large number (so that a number like 1000000 appears as 1,000,000). Below is the actionscript I'm using.
When I define the variable debt as any number, the script works perfectly. But if I define debt as a variable passed to the movie from a PHP file, then the script puts the commas in the wrong places (i.e., 10,000,00). Can anyone explain to me why this would happen, and how to fix it?
var input = debt;
var inputString = input.toString();
var finalString = "$";
var count = 0;
var tempString = "";
for (var i = inputString.length-1; i>=0; i--) {
count++;
tempString += inputString.charAt(i);
if ((count%3 == 0) && (i - 1 >= 0)) {
tempString += ",";
}
}
for (var k = tempString.length; k>=0; k--) {
finalString += tempString.charAt(k);
}
return(finalString);
Trouble Adding Numbers In Array
As an excercise, I'm trying to create a class that will take the average value of numbers in an array.
I'm stuck on adding the values of the array elements. I keep getting "NaN" for the total. Below is my code.
ActionScript Code:
private function getTotal ():Number
{
var total:Number;
for (var i = 0; i<numArray.length; i++)
{
total += Number(numArray[i]);
}
trace("total= "+total);
return (total);
}
Having Trouble Adding Adverts And External Xml
Hello,
I am having trouble adding adverts and external files to a flash website.
I needs some guidance on how to do this properly. Can someone share their knowledge with me?
Thanks,
Sid
Trouble With Adding Buttons That Link To Other Scenes...? (PLEASE HELP)
Greetings...
I have put in the following code, to link to various scenes in my movie...
================================================
For example:
on (press, release) {
gotoAndPlay("Scene 6", 1);
}
================================================
Now, I place these actionscripts on the images that I converted to Flash Buttons and the following error comes up...
================================================
Example:
Scene=Scene 2, Layer=Presentations, Frame=485: Line 1: Mouse events are permitted only for button instances
on (press, release) {
================================================
When I play my movie, the "Buttons" that I created do act like real buttons (my mouse changes on MouseOver) but when I click them, nothing happens...
Why would this happen? I have other buttons in my movie, on other pages that link just fine and I used the same code... Why isn't it working now?
Thanks!!!
Dan
Trouble Adding Duplicated Movieclips To Array
whats up everybody,
once again its almost time to choke the young'ns. I'm on my last nerve and someone or something is gonna catch the wrath.
i have a question or problem that seems easy enough to handle. i've been trying to store my duplicated movie clips inside an array so i can access the x and y positions later. i have duplicate about 20 movie clips and need to have their names stored in an array while they're being duplicated. here's what my code looks like so far:
var intervalID;
intervalID = setInterval(checkLoadStatus, 100);
function checkLoadStatus() {
if(Title.loaded){
clearInterval(intervalID);
//split artist string into array
aArtists = Title.artists.split(",");
aPhotos = Title.photos.split(",");
// initialize stars with Title data
star_amount = aArtists.length;
trace("XXstar_amount = " + star_amount);
//declare arrays
a_Stars = new Array(star_amount);
a_centerCheck = new Array(star_amount);
for (i=0; i<star_amount; i++){
a_Stars[i] = duplicateMovieClip("star", "star" + i, 1+i );
//set length of array
a_Stars[i] = this["star" + i];
//set boolean values to check for position
a_centerCheck[i] = false;
}
star._visible = false;
trace("AAthe elements in a_Stars: " + a_Stars[1]._name);
trace("ZZthe elements in a_centerCheck: " + a_centerCheck[5]);
}
}
the problem is that flash is not storing the elements of the array. on my trace command a_Stars array keeps coming up empty while a_centerCheck displays its elements all fine. stars(the duplicated movie clip) is a child so the target is i believe to be ok. (but is probably wrong also - i just don't know).
any help, as always, is greatly appreciated.
thanks
erase
Loop Trouble
I want to assign an action to a button that say:
Go forward in increments of 4 frames until the value of the variable "moving" is not equal to 1.
I then assign the following frame action to make the playhead stop:
moving=0;
stop;
Here's the code I'm attaching to the button:
on (release) {
tellTarget ("_root") {
if (moving==0) {
moving = 1;
}
now_frame = _currentframe;
do {
gotoAndStop (now_frame + 4);
now_frame = now_frame + 4;
} while (moving==1);
}
}
When I run the movie, the playhead doesn't move, and the movie gets stuck in the loop, since the "moving" doesn't change from 1 until the playhead reaches that frame action.
can anyone tell me why the playhead is not moving? This code works when I take it out of the loop, but of course, it only moves forward once.
Still Having Loop Trouble
I have a bunch of flash movies named
"movie1.swf","movie2.swf"(and so on)
that I am loading into a target movie clip
(named Target).
I was using this code to load them in, one after the other.
on (release){
num=num+1;
loadMovie("movie"+num+".swf", Target);
}
What code could I add, so that when
"num" reaches a certain point(num=56), it loops back
to movie one?
I tried using
on (release){
for (num=1; num<56; num++){
loadMovie("movie"+num+".swf", Target);
}
but it didn't work
For Loop Trouble
hi
can anyone tell me how i can put this below in a "for" loop? i can't get it to work, thanks:
swf1.numrx = 1;
swf2.numrx = 1;
swf3.numrx = 1;
i tried this and it doesn't work:
for (i=1; i<=3; i++) {
set(swf+i.numrx, 1);
}
thanks for your help!
Loop Trouble....
I've been working with flash using SWiSH 2.0. My problem is that all the flash movies I've made loop automatically. How do i cut this off? I know I can stop the preview from looping, but when I export as .SWF the .SWF file loops. Any clue how to stop the loopage?
For Loop Trouble
using flashMX2004 AS 2
Code:
for(i=1;i<14;i++){
pos[i, 1] = _root.poku[i]._x + _root.poku._x
pos[i, 2] = _root.poku[i]._y + _root.poku._y
}
Ok well anyway i've got a MC "poku" in the root and inside this mc there are 14 points, empty MCs with numbers from 1 to 14 as their instance names. Now i have this array POS to hold all their positions on the ROOT (that's why i'm adding the _x and _y of their parent mc to the point's _x and _y).
Well it should work right? but then when the loop is over, every POS has the same value (pos[1, 1) = 233, pos[2, 1) = 233, pos[3, 1) = 233). I don't know what the problem is.
Can you guys help me? Thanks.
Trouble With While Loop
Hey, I'm getting some errors when I try and run this while loop. Here is the code that I have, assuming that "ball" is an mc, as well as "l1-3". Also, "MakeBallFall" is a function.
code:
onClipEvent (load) {
fallSpeed = 2;
sideSpeed = 2;
currentY = _root.ball._y;
ballH = 17.5;
}
onClipEvent (enterFrame) {
i=currentY - ballH/2;
while(i<=_root.maze.l1-3._y) {
_root.MakeBallFall(fallSpeed);
}
}
When I run this, I get the following message:
Quote:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 10: ')' expected
while(i<=_root.maze.l1-3._y) {
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 11: Statement must appear within on/onClipEvent handler
_root.MakeBallFall(fallSpeed);
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 12: Unexpected '}' encountered
}
Total ActionScript Errors: 3 Reported Errors: 3
None of these errors make any sense....All help would be greatly appreciated.
Thanks in advance
Trouble With For Loop?
Seems simple enough. I want to fade something in with action script. What (probably obvious thing) am I missing? Thanks in advance. :
function water(){
var i:Number =0;
onEnterFrame=function(){
for (i=0; i<40;i++){
blank2_mc._alpha=i;
}
}}
_root.onEnterFrame = function(){
_root.water();
}
Trouble With For Loop And Xml.
Hi!
I have this code that I insert every item in a XML file into an array.
Code:
private function onXMLLoaded(event:Event):void
{
xmlPic = new XML(xmlLoader.data);
for (var i:uint = 0;i < 5;i++)
{
thumbs.push(xmlPic.pic[i].@url);
}
loadThumbs();
}
I know that I have 5 items(I am just testing). If I change 5 for xmlPIC.length it wont show me anything. If I leave 5 on the for loop I have the results I want.
What is wrong?
Having Trouble Adding Action Script To Button Symbol
Hello everyone:
I am hoping someone will read this as I am a developer in 'dires straits' with Flash ( a newbie). My problem regards a layer called "button" which has already been converted to symbol and turned into an invisible button. The problem lies when I try to use the selection tool to select it so that I can add action script to it. Instead of the actions dialogue box saying "actions-button", it says "actions-frame", and as a result, the action script doesn't work. I don't know what to do, it should be simple to select it but something is wrong. If you feel a need to help a developer in need, you can email me at support@tahutiwebsites.com, and I can e-mail you the file so that you can help. Thanks, or you can call me at 310-867-5167
Corinna
Adding A Loop To This Array
Can anyone help? I want the first image in the sequence to reappear after the last.
(Flash 8)
var NumberOfImages = 13;
var LocationToImages = "places/";
var FileType = ".jpg";
var MyImageWidth = 600;
var MyImageHeight = 511;
var x = 0;
MyImagesHolder._visible = false;
var MyArray = new Array();
var i = 0;
MyArray[i] = LocationToImages+i+FileType;
i++;
}
_global.Next = function() {
MessageDisplay = "";
x = x+1;
if (x<=NumberOfImages) {
loadMovie(MyArray[x], _root.MyImagesHolder);
_root.preloaderloader.gotoAndPlay(2);
} else {
x = NumberOfImages;
trace("No more images available");
}
};
_global.Previous = function() {
MessageDisplay = "";
x = x-1;
if (x>=0) {
loadMovie(MyArray[x], _root.MyImagesHolder);
_root.preloaderloader.gotoAndPlay(2);
} else {
x = 0;
trace("No more images available");
}
};
ButtonNext._visible = false;
ButtonPrev._visible = false;
stop();
[F8] Help Adding An Action To A For Loop
Ive been trying to figure this out for hours and it is driving me crazy. I need to add a different gotoAndPlay action to each instance of 'a'. I can figure out how to add the same gotoAndPlay action to each one but how to I add a different action to each? Any help would be much appreciated.
code:
_global.t_depth = 1;
t_mcs = [t_ele, t_u, t_c, t_a, t_s, t_m, t_o, t_t, t_t2, t_t2b, t_a2];
for (a=0; a<t_mcs.length; a++) {
t_mcs[a].scaleTo(50, 1, "easeOutElastic");
t_mcs[a].onRollOver = function() {
this.scaleTo(100, 0.5, "easeOutElastic");
t_depth += 1;
this.swapDepths(t_depth);
};
t_mcs[a].onRelease = function() {
variable = t_mcs[a];
_root.gotoAndPlay("variable");
};
t_mcs[a].onRollOut = t_mcs[a].onReleaseOutside=function () {
this.scaleTo(50, 1, "easeOutElastic");
};
}
Adding A Loop Delay
Code:
function buttonsUp(items, topic, xvalue) {
numMenuItems = items;
for (i=0; i<numMenuItems; i++) {
duplicateMovieClip("_root.blob", "blob"+i, i);
_root["blob"+i]._y = (460)-(i*_root.blob._height);
_root["blob"+i]._x = xvalue;
_root["blob"+i].text = _root[topic+(i)];
_root["blob"+i].onPress = function() {
trace(topic+this.text);
_root.away();
loadMovieNum("caseStudies.swf", 5);
};
}
}
Is there any way for me to add a delay between each increment in the loop, ie so that the next movie would duplicate a split second later than teh one before for example.
Adding OnEnterFrame To A Loop
I am placing via actionscript an entire grid of squares to fill the screen.
They are placed on stage through a For loop.
I would like each movieClip added to obtain a function (as you would use onClipEvent() if the movie Clip was already on the stage) ..
But as these clips are being dynamically added - how or where would I add the function in the code?
Code:
sw = Stage.width/2;
sh = Stage.height/2;
h = 22;
t = 10;
for(i=0; i< t; i++){
var xPos:Number = i*22;
_root.attachMovie("wave","_mc"+[i],this.getNextHighestDepth(),{_x:sw+xPos,_y:sh}) };
So I would like EACH attached _mc to have an OnEnterFrame Event occurance ... Where could I add the intended function ... ie: this._x = _root._xmouse;
Thanks!!!
Adding Text From XML Using For Loop
Cant seem to add all the <name>gallery name </name> that I have in my XML.
I only end up adding the one with the last iteration of [l].
Obviously Im doing something wrong, and Im not that good with for loops, so Im really hoping that someone with better knowledge than me can help me out with this!
ActionScript Code:
function loadwork(event:Event):void { workList = xml.item.name; workMenu.defaultTextFormat = myFormat; workMenu.wordWrap = true; workMenu.mouseEnabled = false; for (var l:int=0; l < workList.length(); l++) { workMenu.x = 10; workMenu.y = l * 30 + 240; workMenu.text = workList[l]; } addChild(workMenu); }
Thats how far Ive come using tutorials, going crazy now
Anyways, thanks in advance to any and all help in this matter!
Regards
/rundevo
Trouble Changing While To For Loop
my script starts with this
Code:
level1 = [[0, 0, 0], [1, 0, 0], [0, 0, 1]];
thisArray = level1;
width = thisArray[0].length;
height = thisArray.length;
// initialise variables
j = 0;
a = 0;
// set up new array
rightArray = [];
tempRight= [];
tempLeft=[]
this follows on from the above script and works fine - when the output is traced
Code:
while (j<width) {
i = height;
b = -1;
tempRight = [];
while (i>0) {
i--;
b++;
// create new array from data
rightArray[a][b] = thisArray[i][j];
// trace ("rightArray["+a+"]["+b+"]"+" should be "+thisArray[i][j]);
tempRight[b] = thisArray[i][j];
}
rightArray[a] = tempRight;
j++;
a++;
}
i tried to change the above code to a for loop this is what i have - when this is traced it is wrong and i can't figure out why
Code:
for(j=0;j<width;j++){
b=0
tempRight=[]
for(i=height;i>0;i--){
tempRight[b]=thisArray[i][j]
b++
}
rightArray[a]=tempRight
a++
}
testing the output
Code:
// testing
trace ("thisArray = "+thisArray);
trace ("rightArray = "+rightArray);
if you think you can help you'll have to get the code by pressing the reply with quote link below this post
thanks
[Edited by Trickman on 04-07-2002 at 05:49 AM]
Having Trouble With A Loop, Please Assist
Hi, and thanks in advance for any suggestions.
I'm having difficulty with a loop that I am working on which is supposed to check a list of predefined variables with variables that are defined by the user.
here is the code :
Code:
for (var i = 1; i < 61; i++) {
set ("answer","_level1.answer" + i);
correctanswer = _level1.answer+i.split('|');
for (var j = 0; j <= correctanswer.length; j++) {
if (correctanswer[j] == _root.exam+i) {
_level0.carrier.VTscore = _level0.carrier.VTscore++;
}
}
}
This loop should be going thru this process :
1. take the value of "_level1.answer(1 thru 60)" and assign it to the variable "answer" for each iteration of the initial loop
2. take the value of the "answer" variable and put it into an array deliniated by the '|' symbol.
3. check each array value for the array 'correctanswer' against the predetermined answer contained in the variable '_root.exam(1 thru 60)
4. Add 1 to the _level0.carrier.VTscore variable if the array 'correctanswer' has a matching answer to the variable '_root.exam' for this instance of the loop, numbered similarly to the instance of the array
5. add one to the first counter to continue the loop.
This chunk of code executes without any errors, but I"m having difficulty :
a) getting the value of the variables to move from the variables to the array
b) incrementing the variable number (_level1.answer1 moving to _level1.answer2 to _level1.answer3 etc etc)
Any suggestions? (this must be flash5 compatible)
[MX04] For Loop Trouble... Please Help.
hello everyone.
(please excuse my english)
im writing the codes of a dinamic page display of comments section, on wich page i have 10 coments on each page. the initial part goes all right. but when i press the buttom to the link of the final page it just doesnt show anything. can you please take a look on my code:
Code:
stop();
traedata = new LoadVars();
traedata.load("http://www.marttells.com/swf/comentarios.php");
traedata.onLoad = function(success){
currentcuadro="cuadro2";
total = traedata.registros;
totalpag = traedata.registros/10;
redondo = int(totalpag);
decimal = totalpag - redondo;
if(decimal > 0){
totalpag = int(totalpag+1);
}
if(decimal < 0){
totalpag = redondo;
}
_root.conte.attachMovie("vacio","empty",10003);
cordenadax = 4.3;
cordenaday = 5.2;
_root.conte.empty._x = cordenadax;
_root.conte.empty._y = cordenaday;
if(total < 10 && total !== undefined){
for(n=0; n<total; n++){
if(currentcuadro=="cuadro1"){
currentcuadro="cuadro2";
}else{
currentcuadro="cuadro1";
}
_root.conte.empty.attachMovie(currentcuadro,"coment"+n,100+n);
_root.conte.empty["coment"+n]._y = _root.conte.empty["coment"+n]._y + (_root.conte.empty["coment"+n]._height * n);
_root.conte.empty["coment"+n].aut.text = traedata["autor"+n]+":";
_root.conte.empty["coment"+n].coment.text = traedata["comentario"+n];
_root.conte.empty["coment"+n].fecha.text = traedata["fecha"+n];
}
}
if(total >= 10 && total !== undefined){
for(o=0; o<10; o++){
if(currentcuadro=="cuadro1"){
currentcuadro="cuadro2";
}else{
currentcuadro="cuadro1";
}
_root.conte.empty.attachMovie(currentcuadro,"coment"+o,100+o);
_root.conte.empty["coment"+o]._y = _root.conte.empty["coment"+o]._y + (_root.conte.empty["coment"+o]._height * o);
_root.conte.empty["coment"+o].aut.text = (traedata["autor"+o])+":";
_root.conte.empty["coment"+o].coment.text = traedata["comentario"+o];
_root.conte.empty["coment"+o].fecha.text = traedata["fecha"+o];
}
}
ultimosdatos = (total - (totalpag * 10));
if(ultimosdatos < 0){
ultimosdatos *= -1;
}if(ultimosdatos > 0){
ultimosdatos = 10 - ultimosdatos;
}if(ultimosdatos == 0){
ultimosdatos = 10;
}
ultimoboton = totalpag - 1;
for(i=0; i<totalpag; i++){
_root.paginas.attachMovie("pag","pagi"+i,20+i);
_root.paginas["pagi"+i].nopag.text = i+1;
anchopaginas = _root.paginas["pagi"+i]._width * totalpag;
_root.paginas["pagi"+i]._x = _root.paginas["pagi"+i]._x - anchopaginas + (_root.paginas["pagi"+i]._width * i);
_root.paginas["pagi"+i].iniciofor = (_root.paginas["pagi"+i].nopag.text * 10)-10;
_root.paginas["pagi"+i].finalfor = _root.paginas["pagi"+i].iniciofor + 10;
if(i !== ultimoboton){
_root.paginas["pagi"+i].onPress = function(){
_root.conte.empty.removeMovieClip();
_root.conte.attachMovie("vacio","empty",10001);
_root.conte.empty._x = cordenadax;
_root.conte.empty._y = cordenaday;
for(p=this.iniciofor; p<this.finalfor; p++){
if(currentcuadro=="cuadro1"){
currentcuadro="cuadro2";
}else{
currentcuadro="cuadro1";
}
_root.conte.empty.attachMovie(currentcuadro,"coment"+p,500+p);
_root.conte.empty["coment"+p]._y = _root.conte.empty["coment"+p]._y + (_root.conte.empty["coment"+p]._height * p);
_root.conte.empty["coment"+p].aut.text = traedata["autor"+p]+":";
_root.conte.empty["coment"+p].coment.text = traedata["comentario"+p];
_root.conte.empty["coment"+p].fecha.text = traedata["fecha"+p];
}
}
}
//*************** TROUBLE PART **************************
if(i == ultimoboton){
_root.paginas["pagi"+ultimoboton].onPress = function(){
_root.conte.empty.removeMovieClip();
_root.conte.attachMovie("vacio","empty",10005);
_root.conte.empty._x = cordenadax;
_root.conte.empty._y = cordenaday;
for(m=this.iniciofor; m<total; m++){
if(currentcuadro=="cuadro1"){
currentcuadro="cuadro2";
}else{
currentcuadro="cuadro1";
}
_root.conte.empty.attachMovie(currentcuadro,"coment"+m,1000+m);
_root.conte.empty["coment"+m]._y = _root.conte.empty["coment"+m]._y + (_root.conte.empty["coment"+m]._height * m);
_root.conte.empty["coment"+m].aut.text = traedata["autor"+m]+":";
_root.conte.empty["coment"+m].coment.text = traedata["comentario"+m];
_root.conte.empty["coment"+m].fecha.text = traedata["fecha"+m];
}
}
}
}
}
is that i cannot have two for loops on the same statement? please help...
[CS3] Actionscript 2 While Loop Trouble
I'm having trouble getting a while loop to work. I am creating a rock, paper, scissors, game where i need the computer to select a random number between 1 and 3. can someone take a look at my script and give me an idea of where i've went wrong? i want to learn and fix the problem, i'm just not sure of where i've messed up. any help would be greatly appeciated.
Trouble With A Loop Statement
The code below stops when I get to the if statement. I can see the data all come in fine when I trace it, but there is something wrong with my if statement because it never resolves and should. Any observations would be appreciated - I have been looking at it too long and can't get to work.
Attach Code
showcase = new Array("Showcase1","Showcase2","Showcase3","Showcase4","Showcase5",
"Showcase6","Showcase7","Showcase8","Showcase9","Showcase10");
exData.onData = function (ourstring) {
//-- create booth array, split string --//
var temp = ourstring.split("|");
var pair = new Array(2);
booth = new Array();
//-- create multidimensional array --//
for(i = 0; i < temp.length; i++){
pair = temp[i].split("=");
booth[pair[1]] = pair[0];
for (j = 0; j < showcase.length; j++) {
scCont = "sc" + (j + 1);
if (booth[pair[1]] == showcase[j]) {
scCont.company = booth[pair[0]];
trace("Success - entered if statement");
break;
}
}
}
exData.load("flashVars.php");
Trouble With Loop (simple I Think)
Hi,
I have been stuck on this same problem a number of times and would really like to figure out the solution, which i have no doubt is simple once you know, but it currently eludes me!
Basically I want to assign a function on a number of buttons named "disc1","disc2" etc. I want them to have a mouseDown function that sets a global variable to 1,2,3 etc based on the disc number.
This is what i thought would work but obviously it doesn't!
for (i=1;i<5;i++)
{
name="disc"+i;
[name]onMouseDown = function(){
activeDisc=i;
}
}
How should I do this instead?
Thanks for any help
Trouble With Variables + Loop (while)
Im a newbie to write scripts
I m trying to make a Loop using While of this information
Working no loop>>>>>>>>>>>>>>>
Code:
//variables coming from PHP
members = 2;
ramo1 = "automotivo";
pos1x = 500;
pos1y = 150;
empresa1 = "Sosokar Veculos";
meuid1 = 2;
ramo2 = "alimento";
pos2x = 330;
pos2y = 80;
empresa2 = "Super Food";
meuid2 = 1;
_root.moldura.mapa.attachMovie(ramo1, obj1, 1);
obj1._x = _pos1x;
obj1._y = _pos1y;
obj1.onRollOver = function() {
setProperty("obj1.empresa_txt", _visible, "1");
obj1.empresa_txt = empresa;
};
obj1.onRollOut = function() {
setProperty("obj1.empresa_txt", _visible, "0");
obj1.empresa_txt = "";
};
obj1.onPress = function() {
setProperty("_root.infos", _visible, "1");
_root.infos.ncliente = meuid;
_root.infos.gotoAndStop(2);
}
};
<<<<<<<<<<<<< End of Working
//---------------------------------------------------------------
Not Working and Crashing>>>>>>>>>>>>>>>
i=1;
while (i <= members){
set("_ramo"+i, eval ("ramo"+i));
set("_pos"+i+"x", eval ("pos"+i+"x"));
set("_pos"+i+"y", eval ("pos"+i+"y"));
set("_empresa"+i, eval ("empresa"+i));
set("_meuid"+i, eval ("meuid"+i));
//---------------------------------------------------------------
_root.moldura.mapa.attachMovie("ramo"+i, "obj"+i, 1);
set("obj"+i+"._x", eval ("_pos"+i+"x"));
set("obj"+i+"._y", eval ("_pos"+i+"y"));
set (btvar ,eval("obj"+i)); // I think this is wrong
btvar.onRollOver = function() {
setProperty("obj"+i+".empresa_txt", _visible, "1");
set("obj"+i+".empresa_txt", eval ("_empresa"));
}
btvar.onRollOut = function() {
setProperty("obj"+i+".empresa_txt", _visible, "0");
btvar.empresa_txt = "";
};
btvar.onPress = function() {
setProperty("_root.infos", _visible, "1");
set("_root.infos.ncliente",eval ("meuid"+i));
_root.infos.gotoAndStop(2);
i = i + 1;
} // End of While
};
<<<<<<<<<<<<< End Not Working and Crashing
Thanks all
Trouble Adding Dynamically Named Elements To An Array Immediate Help Is Needed
OK, here we go... if someone can help me figure this out, I will have successfully completed my site in time for the deadline today at noon...
-- I have an array located at "_parent.emptyWindows"
-- "_parent[this._name]" gives me the name of the current MC and the value I want to add to array "emptyWindows"
-- I'm trying to add an element in this manner:
Code:
_parent.emptyWindows[_parent[this._name]] = _parent[this._name];
That is not working, but not even this is working for me:
Code:
_parent.emptyWindows["bird"] = "bird";
Here I've given an explicit value and name for the element to be added to the array, but obviously something is wrong in my context and I just am NOT finding it.
Any guesses???
Much appreciation,
The Dust
Adding Sound Loop To Movie
hello,
i wanted to add a sound loop to my movie that automatically starts playing. A tutorial on here sais: make a new layer, with the keyframe selected go to modify - frame and there you can do something... but in the modify dropdown there is no such thing as 'frame'. So that didn't help much.
Flash help sais:
With the new sound layer selected, drag the sound from the Library panel onto the Stage. The sound is added to the current layer.
You can place multiple sounds on one layer or on layers containing other objects. However, it is recommended that each sound be placed on a separate layer. Each layer acts as a separate sound channel. The sounds on all layers are combined when you play the SWF file.
In the Timeline, select the first frame that contains the sound file.
Select Window > Properties and click the arrow in the lower right corner to expand the Property inspector.
In the Property inspector, select the sound file from the Sound pop-up menu.
Select an effect option from the Effects pop-up menu:
I drag the sound to the stage from my labrary, but i dond see such options in my properties inspector, and yes i have expanded the window. might be because i am using flash 8 But someone please help me.
tnx, Snuurtje
|