Path Problem In Loop
I have three movie clips on stage that I want to fill with dynamically loaded jpegs and then resize jpegs so they fit the movie clips.This is what I came up with: Code: var maxWidth = 150;var maxHeight = 100;var i:Number;for (i = 1; i < 4; i++) { var container = "button"+i+".emptyMC" var thumbloader = new MovieClipLoader(); thumbloader.loadClip("img"+i+".jpg",container); thumbloader.onLoadInit = function(ctnr:MovieClip, i:Number) { trace(container); if (container._width>=200) { var ctnrWidth = container._width; scalePercent = (ctnrWidth>maxWidth) ? maxWidth*100/ctnrWidth : scalePercent; container._xscale = scalePercent; } if (container._height>=100) { var ctnrHeight = container._height; scalePercent = (ctnrHeight>maxHeight) ? maxHeight*100/ctnrHeight : scalePercent; container._yscale = scalePercent; } };} It attaches pictures like it should only the resizing part doesnt work. The value of container is stuck with "button3.emptyMC" and the only way I can get this code to work is if I change everything that is in red with actual path (button1.emptyMC).What am I doing wrong?Thanks
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-08-2008, 04:53 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Path Names In For Loop
i have variables r1,r2,r3 and r4. I want to use these vars in my for loop as below.
_root.a1.r1;
_root.a1.r2;
...
To do this I am trying to do
for (i=1, j=53 ; i<5 ; i++, j += 20) {
setProperty ("_root.a1"+("r"+i), _y, j);
}
but it doesnt work... What is the problem?
For Loop Path Addressing
Hi,
I'm wondering how to use paths in a for loop and insert the index in the path. Example:
for (i=1; i<=108; i++) {
_root._level0.instance1.instance[i+1]._alpha = 50;
_root._level0.instance1.instance[i+2]._alpha = 50;
etc...;
}
The above syntax doesn't work for me... is there another operator that will evaluate a statement and construct the path?
Thanks
Some For Loop; Variables And Path Problem
Hello
i have this peace of code :
//this put me 3 textfields with three différent prices.
that's what i want.
PHP Code:
for (i=0; i<3; i++) {
_root.createEmptyMovieClip("test_mc"+i, i);
test_mc.createTextField("price", 14, 0, 170, 80, 20);
test_mc.price.text = "some dynamic set price"
//myClip is a button or an Movie clip with button behavior.
//and this puts me 3 different button/Movie clip
//and that's what i want.
var new_mc = test_mc.attachMovie("myClip", "bt"+i, i);
new_mc._x = 0;
new_mc._y = 190;
trace (new_mc)
trace (new_mc._parent.price.text)
// this the result of those to trace and that is ok
_level0.test_mc0.bt0
pice 1
_level0.test_mc1.bt1
price 2
_level0.test_mc2.bt2
price 3
// now if i do this with any button it gives me the same result
new_mc.onRelease = function () {
trace
trace (new_mc._parent.prix.text)
}
//this is the result of that trace and that is not what i want at all
last price
_level0.test_mc2.bt2
} // and of the "for" loop
So i was wondering if anyone as a solution mybe i have to figure a way of putting the "new_mc.onRelease " part outside of the for loops.
Please help me me me
Worked Out Path Now Just Need .reverse To Loop So It Goes Back More Than ONE Frame
Heres what I have
a movie called reverse with 3 keyframes
on keyframe1 I have stop()
on keyframe2 I have _level0.welcome.prevFrame();
on keyframe3 I have _level0.welcome.prevFrame();gotoandPlay(2);
I have placed this in a movie called welcome on the last keyframe because thats the one I want played backwards.
on the button I have on (release) {
gotoAndStop;
_level0.welcome.reverse.play();
}
Can anyone explain why the movie is only going back ONE frame?
Using Eval Function And Variable In A Path (target Path)
Hello,
I have to reprogram some of my website and it calls to conjugate strings in a way that's beyond my understanding. Please help me with some suggestions. Kind regards.
the original code is:
code:
if (_global.useCount<10) {
//hide
var diff = 10-_global.useCount;
for (diff; diff>0; diff--) {
eval(String(11-diff))._visible = false;
}
}
There are buttons named 1 to 10 and this turns off the ones that are not used. Now I want to nest those buttons in subclip "buttonsRow", instead of having them on main timeline. How do I rewrite that code to make it work with new path?
I have already tried the "associative array" method, but it don't really know how to pack the whole eval function in there. I've tried many combinations, like:
code:
this.buttonRow[eval(String(11-diff))]_visible = false;
//or
this.buttonRow["eval(String(11-diff))"]_visible = false;
//or
buttonRow[eval(String(11-diff))]._visible = false;
//or
buttonRow["eval(String(11-diff))"]._visible = false;
//or
buttonRow[eval(11-diff)]._visible = false;
// or
buttonRow[8]._visible = false;
//the last one at least turns off button 8, lol
Some of those return syntax error and some just don't work. Anyone have any ideas? Thank you again.
Cannot Export An Avi Of Motion Along A Path When Path Is Specified With Action Script
Hello!
I have the following problem: I am using Flash 8 Professional to produce a series of avi files showing the motion of a dot along different paths. Whenever I use the drawing tools to draw the path everything is all right: I can export both a swf and an avi file showing the motion. The problems start when I use action acript to specify the path: then a swf can be exported, but not an avi file (Flash acts as if it is exporting but the avi file produced shows only a stationary dot). Can anybody help me?
_root.path="http://www.sitename.com/path/FlashSite/"; Script Issue While Online
Hi there,
I inserted _root.path="http://www.sitename.com/path/FlashSite/"; in the beginning of my action script (2.0). This script accessing contents from an access database, which is working fine, when I tested from my local system folder. But no content from database is displaying while it tested from my localserver (127.0.0.1/path/FlashSite) or from online server.
From a search I found it might be the issue with "Network Access Warning". Is there any other reason? If this is the reason, then how can I resolve it?
For example, how should I replace this -
setTimeout( function(){ _root.content01.content02.gotoAndStop("cont_a");}, 1000 );
Thanks in advance
Shine
Variable Path Name --> Path=_root
instName="inst1";
path="_root";
Element.prototype.setVisible = function(){
[path+"."+instName]._visible=true;
}
I am trying to build a variable path to an instance. Normally I would do something like this[var]._x, but this doesn't work with _root.
Any ideas?
_root.path="http://www.sitename.com/path/FlashSite/"; Problem While Online
Hi there,
I inserted _root.path="http://www.sitename.com/path/FlashSite/"; in the beginning of my action script (2.0). This script accessing contents from an access database, which is working fine, when I tested from my local system folder. But no content from database is displaying while it tested from my localserver (127.0.0.1/path/FlashSite) or from online server.
From a search I found it might be the issue with "Network Access Warning". Is there any other reason? If this is the reason, then how can I resolve it?
For example, how should I replace this -
setTimeout( function(){ _root.content01.content02.gotoAndStop("cont_a");}, 1000 );
Thanks in advance
Shine
Wrong Path Given, What Path To Use?, And Why?
Since the beginning of my Flash time, i never solved the 'giving path' problem in Action Script.
Most of the time my paths work, but sometimes they only work in an empty .fla file and not in my homepage.fla file with the code in another scene.
This time it's the code in the timeline (layer: actions, frame 2, scene: control_panel_sc, .fla file: homepage.fla):
stop();
ccbTime.addItem("tidfme2");
I tried naming the path to:
this.ccbTime.addItem("tidfme2");
super.ccbTime.addItem("tidfme2");
_root.ccbTime.addItem("tidfme2");
_parent.ccbTime.addItem("tidfme2");
_global.ccbTime.addItem("tidfme2");
_level.ccbTime.addItem("tidfme2");
_leven0.ccbTime.addItem("tidfme2");
this._root.ccbTime.addItem("tidfme2");
even adding the scene name to it:
this._root.control_panel_sc.ccbTime.addItem("tidfm e2");
etc. (thus the above paths again + scene name)
All paths above don't work, meaning, i can't see the value in a component ComboBox, though in an empty .fla file i do see this value.
Because you can't help me out without actually seeing the .fla file, i uploaded it:
(every link is the same file, so just choose one URL).
http://pcxpert.dyndns.org/homepage.fla
http://pcxpert.dyndns.org/homepage.zip
http://www.uploading.com/?get=YQ0G1UIC zip version
http://www.uploading.com/?get=VWE6WZKO .fla version
http://members.lycos.nl/johnwhello/homepage.fla
http://members.lycos.nl/johnwhello/homepage.zip
ftp://pcxperting:flash@pcxpert.dyndns.org/homepage.fla
ftp://pcxperting:flash@pcxpert.dyndns.org/homepage.zip
Also, you're authorized to change any file at ftp://pcxperting:flash@pcxpert.dyndns.org (the future pcxperting.com that is made by and made for pcxperts)
How Do I Define The Greatest _x Position Based On A Loop, Assuming I Know The Last Element Of The Loop?
Hello,
This may be complicated,
I've a loop that creates emptyMovieClips
then I use one function to onRollOver _xscale them += 10
Now I want to move another movieClip based on the greatest _x position of my previously _xscaled elements, how do I do that?
example
for (var i = 0; i<my_array.length; i++) {
_root.menu_.createEmptyMovieClip("btn"+i, i+1);
}
//
_root.menu_["btn"+i].onRollOver = function() {
this._xscale += 10;
//
MY_DRAGER._x = HIGHT._x;
}
Can this be done?
Thanks,
I Would Like My Sound Loop To Continously Loop Without Looping Over Itself When I Repeat My Images.
I have a sound loop moving along with my flash images. When the flash images finish and I send it back to frame 1, my sound doubles. How can I play my sound loop once, but allow my images to continously loop.
Is there away to just run one loop of sound, and let the image aspect continue to loop.
I would like my sound loop to continously loop without looping over itself when I repeat my images.
Make One Element Loop Without Making Enitre Movie Loop?
i'm trying to make one element continue looping without making the entire movie loop... here's what i mean..
i have a layer that i've name actions which i've asigned a stop(); to at the end of the animation. but i want the red pulsating dot to continue looping/ animating ... to give you an even better idea, here's the swf file...
http://www.push1.com/roster_art_gal.swf
cheers!
LoadVars In A For Loop Not Executing .load Function Until For Loop Completed?
Ok so I have a simply for loop: ID[i] is a global array
Code:
for (i=0;i<12;i++)
{
var loadInfo:LoadVars = new LoadVars();
loadInfo.onLoad=function(success:Boolean)
{
if (success)
{
trace("whatever:"+loadInfo.myname);
}
else
{
trace("Nope");
}
loadInfo.load(ID[i]+".txt");
}
the problem I'm having is that the function doesn't execute until the for loop completes and then it executes 12 times in a row. Output is 'whatever: undefined' 11 times and then 'whatever: Bobble' (which corresponeds to the last .myname value as it should). Why is this? And how can I fix it? To be continued...
~NH
Loop Inside Loop... Why Doesn't Work Properly?
In order to cause a delay, I have put a loop inside another loop. Here it is:
for (a=1; a<6; a++) {
for (b=1; b<10000; b++) {
}
}
Flash delays to show the page but in the end I just see both variables with the maximun value. The point was to see variable "a" growing with delay. What have I done wrong?
Thank you
Function Inside For Loop; How To Give It Parameters Of The Loop
Hey!
This is the code:
Code:
for (i=0; i<5; i++) {
_root.createEmptyMovieClip("temp"+i, 1+i);
_root["temp"+i].beginFill(0xFF0000, 20 + (20*i));
_root["temp"+i].moveTo(0+(60*i), 0+(67*i));
_root["temp"+i].lineTo(100+(60*i), 0+(61*i));
_root["temp"+i].lineTo(100+(64*i), 100+(65*i));
_root["temp"+i].lineTo(0+(55*i), 100+(80*i));
_root["temp"+i].endFill();
_root["temp"+i].onRelease = function() {
trace("button Number = " +i);
}
}
So I made butttons and assigned each one an onRelease function. But each one needs to have assigned a variabile by the value "i" in the for loop.
When I write it like this the function itself is defined only after I click it and it ofcourse asigns all the buttons the same "i", the last value of "i" in the for loop.
How do I do it so I get first button with variable 1, second with 2,... ?
Thx.
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class) ...
Loop Help: XML Attribute Doesnt Stay On Each Object Of The Loop
Hi, i'm working on a gallery that loads thumbnails from an xml file into 3 columns and when you click on a thumbnail it opens a new window with the fullsized image in.
I have modified code from a gallery tutorial to load the thumbnails from a xml file. They are going in 3 columns at the moment (I don't understand why but they are) but only the last image has a hand cursor when you rollover it, and then when you click on it, it traces "undefined" into the output box.
I have put
Code:
trace(images_arr[i].attributes.fullsize);
just below the bit where it loads the thumbnails and it traces the right path from the xml file for each image.
Can someone help me get it to trace the right path from the xml file when you click on ALL the thumbnails, not just the last one.
Thank you so much in advance!
Code:
function GenerateThumbs() {
images_arr = images_xml.firstChild.childNodes;
gap = 10;
this.createEmptyMovieClip("thumb_mc",100000);
thumb_mc._y = 10;
thumb_mc._x = 10;
for (var i = 0; i<images_arr.length; i++) {
trace('generating thumbs'+i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_mc", i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_tmp_mc", 300);
this.thumb_mc["thumb"+i+"_mc"]._x = ((i%3)*(67+gap));
this.thumb_mc["thumb"+i+"_mc"]._y = Math.floor(i/3)*(67+gap);
this.thumb_mc["thumb"+i+"_mc"].loadMovie(images_arr[i].attributes.thumb);
this.thumb_mc["thumb"+i+"_tmp_mc"].no = i;
this.thumb_mc["thumb"+i+"_tmp_mc"].onEnterFrame = function() {
var _mc = this._parent["thumb"+this.no+"_mc"];
var l = _mc.getBytesLoaded();
var t = _mc.getBytesTotal();
if ((l>=t) && (t>1) && (_mc._width>1)) {
_mc.onRelease = function() {
trace(images_arr[i].attributes.fullsize);
};
}
};
}
}
var images_xml = new XML();
images_xml.ignoreWhite = true;
images_xml.onLoad = function(success) {
if (success) {
GenerateThumbs();
} else {
trace("Error loading XML file");
}
};
images_xml.load("gallery.xml");
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class)
Though i'm wondering if there's an easier way than timers to be able to do something like that, like C's sleep() function for example.
My Sound Loop Is Repeating Itself Ontop Of Previous Loop
Here is a link to a movie that I am working on:
LINK-
http://blue-title.com/v2/
My client says that when you first start the movie, the loop starts fine but when he clicks on one of the three buttons at the bottom (Home, Florida, Alabama) the initial first loop continues to play and a new loop is beginning to repeat while the first one is still playing.
It works fine for me in Firefox and Safari on a Mac.
Any solutions?
Todd Temple
Movie Clips In For Loop Onlydisplaying In 1st Loop
Hi there! I'm new at this so excuse if I'm being stupid.
I'm creating a game which I'm looping through an array and inside the loop I'm playing clips. The clips display only the first time the loop is being run. Here is the actionscript. PLEASE SOMEONE HELP ME... I'M DESPERATE!!!
code:
on (release) {
var myClips = new Array("Fletter", "Lletter", "Aletter", "Mletter", "Eletter");
var myClipsNewName = new Array("mov2", "mov3", "mov4", "mov5", "mov6");
var myClipsValue = new Array (10, 11, 12, 13, 14);
var cnt = 0;
for (var t = 0; t<4; t++) {
for (var i = 0; i if (cnt == -1) {
cnt = 0;
}
var temp = myClips[cnt];
attachMovie(myClips[cnt],myClipsNewName[cnt], myClipsValue[cnt]);
updateAfterEvent();
trace(myClips[cnt]);
if (i == Total-1) {
myClips.splice(cnt, 1);
myClipsNewName.splice(cnt,1);
myClipsValue.splice(cnt,1);
if (cnt == myClips.length) {
cnt = 0;
}
break;
}
cnt = cnt+1;
if (cnt == myClips.length) {
cnt = 0;
}
}
}
}
edit: jbum added as tags
Mp3 Sound Loop Bad. Wav Loop Good.
I have a soundloop which is a WAV file
and it works just fine when i loop it in flash
But when i convert it to an MP3 file...for osme weird reason theres a little less than 1 second pause when it starts again...you can tell its a loop...not smooth
But in WAV format its fine.
Its weird..ive used two different softwares to convert my wav file.
ive used Creative Wave Studio, Ive used a dedicated third party MP3-WAV convertor.
same results...the mp3 has bad looping.
any ideas?
[MX04] Loop Loop Whoops
Hi,
I know this might be really simple but I'm having a problem with my movie continuing to loop even though I've put the stop() function anywhere and everywhere I can think of. Basically, I have some mc's in Frame 1 which perform some calculations in AS. At the end of one of the calculations, I have _root.gotoAndStop(2) (which I'm assuming is telling the playhead to move on to the next frame in the main timeline).
I've put in key frames in the second frame for the same mc's to perform some different calculations which are dependent on variables from Frame 1's calculations. After running through the calculations, the movie won't stop looping and I can't figure out why.
Can anyone suggest a course of action? Thanks in advance.
Stop Loop And Replay Loop
Okay on my stage I have a start(MC) and a stop(MC) and a clear(MC) these will be used as buttons. I also have a dynamic text box that shows my output.
I am making it so when you click start it will start counting from 0 to whenever you hit the stop button, I have changed my fps to 1 so it doesn't crash my computer, And this is where I am running into trouble. Here is my code.
var myTimer = 0;
startBtn.onPress = function() {
this.onEnterFrame = function() {
myTimer = myTimer + 1;
//trace(myTimer);
this._parent.myTxt.text = myTimer;
}
}
stopBtn.onPress = function() {
trace(myTimer);
this.myTimer.onEnterFrame = stop();
}
I would also like it so when you hit start again it picks up where it left off.
Please any help would be greatly appreciated.
Thanks
T
Loop Within A Loop (creating 2 Columns)
Hello. I have the following loop, which works just fine:
ActionScript Code:
yGutter = 30;
xGutter = 28;
numPerRow = 1;
for (t = 0; t < vars.countEmployees; t++)
{
thumbCont.duplicateMovieClip("thumbCont" + t, 2000 + t);
this["thumbCont" + t]._y = thumbCont._y + yGutter * Math.floor(t / numPerRow);
this["thumbCont" + t]._x = thumbCont._x + xGutter * t - xGutter * numPerRow * Math.floor(t / numPerRow);
this["thumbCont" + t].tID = t;
this["thumbCont" + t].gotoAndStop(2);
mainCont.duplicateMovieClip("mainCont" + t, 3000 + t);
} // end of for
you can see this here:http://www.metapps.com/testing/index_email.html
I need to make 2 more columns, same as the first, with the rest of the info from the php file. Right now I have a "LIMIT 0,10" on the MYSQL request so there are only 10 rows. Ultimately there will be three rows with 30 employees.
How would I write this loop?
thanks
XML Nested Loop - Access The Loop Later... But How?
Hello all. I need help desperately, I'm very novice with this kinda stuff. Basically, I have data organized by date in an XML file. I'm trying to make a website application that will allow the user to click on a date (in a text field) to see another textfield populate with all the data under that particular date.
So far, all the information loads into the textboxes at the same time. How can I get it to only load information under a particular date when somebody clicks on that date?
Before I started this project, I was convinced I could do this by manipulating the [j] (see code below) in the myFunc2 function. Currently, it's set up to increment blank_mc._y by whatever value is returned by [j]. But for some reason this doesn't work. I feel that if I could atleas get this part to work - I could probably do the rest.
Any help is greatly appreciated. PS - I'm not sure I even need a nested loop for this...
AS code:
Code:
function loadXML(loaded) {
if (loaded) {
var nodes = this.firstChild;
for (j=0; j<nodes.childNodes.length; j++) {
groups = nodes.childNodes[j];
var info = groups.childNodes;
for (i=0; i<info.length; i++) {
var word2 = groups.childNodes[i].childNodes[0].firstChild.nodeValue;
var url2 = groups.childNodes[i].childNodes[1].firstChild.nodeValue;
_root.myText.htmlText +="<A HREF="asfunction:MyFunc,"+url2+" ">"+word2+"
</A>";
}
_root.myGroup.htmlText +="<A HREF="asfunction:MyFunc2,"+[j]+" ">"+groups.attributes.title+"
</A>";
}
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("links.xml");
function MyFunc2 (blarg) {
//trace (blarg);
//trace (blank_mc._y);
blank_mc._y = blarg;
}
function MyFunc (arg) {
loadMovie(arg, holder_mc);
};
XML Code:
Code:
<?xml version="1.0" ?>
<products>
<group1 title="January">
<item>
<one>foo</one>
<two>foo.swf</two>
</item>
<item>
<one>beans</one>
<two>beans.swf</two>
</item>
<item>
<one>spiders</one>
<two>spiders.swf</two>
</item>
</group1>
<group2 title="February">
<item>
<one>foo2</one>
<two>foo2.swf</two>
</item>
<item>
<one>beans2</one>
<two>beans2.swf</two>
</item>
<item>
<one>spiders2</one>
<two>spiders2.swf</two>
</item>
</group2>
</products>
GrRR Loop, Loop,loop
Hi ! I would like to know why when I goto publishing or otherwise. That when the program is run that the "loop" is always in the on mode. I have looked under preferences and I don't see it in there either. Can this thing be turned off somewhere by using scripts? Cause the last program I played with was supposed to "play and stop". It does work before the last frame is seen and then jumps over it when that script is activated. But then restarts the whole movie process all over again. But,now if I play the movie myself and I go and right click on the movie and turn off the loop it worksd just fine ... How do you turn that thing OFF????
ANYBODY KNOW??? HeLP!!
[Edited by Coke1bear on 12-26-2001 at 02:52 PM]
AS3 - Path Problem ? Var In Path Problem Not Working
hitrect1_mc.buttonMode = true;
hitrect2_mc.buttonMode = true;
hitrect3_mc.buttonMode = true;
hitrect4_mc.buttonMode = true;
hitrect1_mc.addEventListener(MouseEvent.CLICK , cl1);
hitrect2_mc.addEventListener(MouseEvent.CLICK , cl1);
hitrect3_mc.addEventListener(MouseEvent.CLICK , cl1);
hitrect4_mc.addEventListener(MouseEvent.CLICK , cl1);
function cl1 (e:MouseEvent):void{
xa=e.currentTarget.name.charAt(7);
for (i=1;i<=xa;i++){
targets = "bar"+String(i)+"s_mc";
trace (targets);
soundrect_mc.targets.gotoAndStop(2);
}
well it traces bar1s_mc if it's exact as the code.
if i remove soundrect_mc.targets.gotoAndStop(2); it traces all targets.all 4 of them.How do i make flash recognize "targets" as a path to a movie clip ?
SIMPLE LOOP-D-LOOP
I have a tween that is 20 frames long nested in a MC.
Is there a way to set it to loop a specific amount of times and then stop? Similiar to the sound loop option?
Does someone have a little code or something to point me in the right direction?
Thanks!
Loop De Loop Need To Stop
Dear Helper People
I am trying to make a movie using the The Matrix Bitstream Effect
http://flashkit.com/tutorials/Specia...52/index.shtml
but I want to goandplay 10 times then stop.
Could you please tell me how I can set it so it goes through the frames 10 times then stops.
Well since I have you hear I would also like to ask.
I am also using the DOS Text Typer Effect
http://www.were-here.com/forum/tutor...sor/index.html
Why is it when I try to insert pictures to desplay on the screen, the pic moves along with the word.
How can I desplay it and not have it move.
-Thanks
MP3 Loop Script Won`t Loop
Hello guys ... I have this thing thats drivemin me nuts :s I am writing a MP3 player script but it won`t loop my sound ... and I have no idea whats wrong with it. ( I can stop the sound and play it but its not looping ) Maybe some1 could take a glance at it and give me hint woots wrong? Thank You
var mySound:Sound = new Sound();
mySound.loadSound("track1.mp3", true);
this.mc_stop.onRelease = function() {
curPlaybackPos = mySound.position;
mySound.stop();
}
this.mc_play.onRelease = function() {
mySound.start((curPlaybackPos/1000), 9999);
};
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
Running A Loop Within A Loop
can this be done?
so that:
this is stage 1 of loop_a (this is stage 1 of the loop_b)
this is stage 1 of loop_a (this is stage 2 of the loop_b)
this is stage 1 of loop_a (this is stage 3 of the loop_b)
this is stage 2 of loop_a (this is stage 1 of the loop_b)
this is stage 2 of loop_a (this is stage 2 of the loop_b)
this is stage 2 of loop_a (this is stage 3 of the loop_b)
and so on...
iv attempted it and the loop within the other works, but the main one does not
For Loop In For Loop Problem
in the first frame of my movie i set an array called printframes. there i list three frame labels on my main time line that i want to print. on each of those frames resides a movie clip that has its own "printframes" array, again listing frames of its own time line that i want to print.
now, i have a button who's script is as follows:
ActionScript Code:
for(Array in _root.printframes){
T1 = _root.printframes[Array];
_root.gotoAndStop([T1]);
pj.addPage(_root, {xMin:0,xMax:1024,yMin:0,yMax:768},null);
trace("current frame in main time line is "+[T1]);
for(var prop in _root){
if (typeof _root[prop] == "movieclip"){
trace("movie found= "+ [prop]);
for(Array in _root[prop].printframes){;
T2 = _root[prop].printframes[Array];
trace("found secondary movie clip's printframe, adding page," + [T2]);
_root[prop].gotoAndStop([T2]);
pj.addPage(_root, {xMin:0,xMax:1024,yMin:0,yMax:768},null);
}
}
}
}
this script is working fine accept for on huge dilema...
the first time it finds a movie with its own "printframes" array it sees the array and does what i want it to do. how ever once it sees that secondary printframes array,
when it gets to a frame of the main timeline that has a new movie clip, it sees that movie but not its "printframes" array.
can anyone tell me why?
i have attached the actual fla and would really appreciate anyones help. i am guessing that after each it finds the secondary printframes array and does what i want it to do i have to clear the array somehow.. i don't know.. my brain is fried...
Problem With A For...in Loop In A For...in Loop
Hello,
I want to do a for...in loop in another for...in loop, but can't seem to make it work properly.
I need to search a key term (var recherche) in an array (repertoire) of arrays (lettre1-lettre28).
The first solution I came up with simply doesn't work (code at the end of this message), the "lettre" variable doesn't seem to be recognize. The code works fine if I put an index there, though. And if I trace the "lettre" variable, it just comes up with "0".
In the second solution, only the lenght of the first array is being considered, so it is a problem cause the arrays don't have the same lenght and therefore not all the table is searched.
The third solution works fine, but I don't like it, if only because it generates tons of "undefined" and I'd like to keep the relative variables so that if I want to adapte the piece to another language with different letters, I can.
Here is the code:
Code:
//tableaux pour loger les différentes letters de l'alphabet
var lettre1:Array = new Array ("a", "A", "à", "À");
var lettre2:Array = new Array ("b", "B");
var lettre3:Array = new Array ("c", "C", "ç", "Ç");
var lettre4:Array = new Array ("d", "D");
var lettre5:Array = new Array ("e", "E", "é", "É", "è", "È", "ê", "Ê", "ë", "Ë");
var lettre6:Array = new Array ("f", "F");
var lettre7:Array = new Array ("g", "G");
var lettre8:Array = new Array ("h", "H");
var lettre9:Array = new Array ("i", "I", "î", "Î", "ï", "Ï");
var lettre10:Array = new Array ("j", "J");
var lettre11:Array = new Array ("k", "K");
var lettre12:Array = new Array ("l", "L");
var lettre13:Array = new Array ("m", "M");
var lettre14:Array = new Array ("n", "N");
var lettre15:Array = new Array ("o", "O", "ô", "Ô");
var lettre16:Array = new Array ("p", "P");
var lettre17:Array = new Array ("q", "Q");
var lettre18:Array = new Array ("r", "R");
var lettre19:Array = new Array ("s", "S");
var lettre20:Array = new Array ("t", "T");
var lettre21:Array = new Array ("u", "U", "û", "Û", "ù", "Ù", "ü", "Ü");
var lettre22:Array = new Array ("v", "V");
var lettre23:Array = new Array ("w", "W");
var lettre24:Array = new Array ("x", "X");
var lettre25:Array = new Array ("y", "Y");
var lettre26:Array = new Array ("z", "Z");
var lettre27:Array = new Array ("æ", "Æ");
var lettre28:Array = new Array ("œ", "Œ");
//tableau-répertoire pour loger l'ensemble des possibilités
var repertoire:Array = new Array;
for (var i:Number = 1; i < 29; i ++) {
repertoire.push(["lettre" + i]);
};//fin
var recherche:String = "k";
//solution 1
for (var colonne in repertoire) {
//trace("colonne : " + repertoire[colonne]);//repertoire[colonne] = noms des colonnes
//lettre = index des différentes lettres
for (var lettre in _root.repertoire[colonne]) {
trace(_root[repertoire[colonne]][lettre]);
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
//solution 2
for (var colonne in repertoire) {
//trace("colonne : " + repertoire[colonne]);//repertoire[colonne] = noms des colonnes
//lettre = index des différentes lettres
for (var i:Number = 0; i <= _root.repertoire[colonne].length; i ++) {
trace(_root[repertoire[colonne]][i]);
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
//solution 3
for (var colonne in repertoire) {
//lettre = index des différentes lettres, repertoire[colonne] = noms des colonnes
for (var i:Number = 0; i < 10; i ++) { //for...in avec _root[repertoire[colonne]] ne prend la mesure que de la première colonne rencontrée
trace(_root[repertoire[colonne]][i]);
if (_root[repertoire[colonne]][i] == recherche) {
trace("yeah!");
};
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
Anyone has a clue as to what can be done or what mistake I am making?
Thanks,
Victoria
Loop Inside Loop -- What's Going On?
Let's say I have this little tracer code that lists a display object container's children, and those children's children.
Maybe it would look like this:
ActionScript Code:
var target_mc = this;
for (var i:uint = 0; i < target_mc.numChildren; i++){
trace (' | ' +i+'. name:' + target_mc.getChildAt(i).name + ' type:' + typeof (target_mc.getChildAt(i))+ ' ' + target_mc.getChildAt(i));
if(target_mc.getChildAt(i).hasOwnProperty("numChildren")) {
trace(' children:');
for(var j:uint = 0; j < target_mc.getChildAt(i).numChildren; j++) {
trace(' | ' +j+'. name:' + target_mc.getChildAt(i).getChildAt(j).name + ' type:' + typeof (target_mc.getChildAt(i).getChildAt(j))+ ' ' + target_mc.getChildAt(i).getChildAt(j));
}
}
}
Edit: had an i where a j should have been, my bad
Anyways, if you want a little for loop to trace the children of an object and any children of that object, well here you go.
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
The Loop That Just Dosn't Loop...
After some more testing I have "the attached"...
I have moved the code onto the first frame but something is wrong...
When you click the button, it only works onces and then stops... if you keep on clicking the button the MCs get there, but they should get there in 1 click and not 17.....
Anyone know why???? :confused: :confused:
PS. the code looks very long for what it does....mmmm I need a code cleaner lol... :o
Translate 'while' Loop To 'for' Loop
hi.
i'm create a grid-like structure and am trying to translate my old loop:
Code:
while (dayCount <= lastDay) // creates 30 text fields
to a 'for' loop where I can increment the position of each duplicated text field by i * a specified width.
the thing is that i can't figure out how to do that with my while loop. but i can do it with a 'for' loop. that's why i'm trying to change it.
earlier in my code i use this 'for' loop to lay out the row above where i want to start....
Code:
for(var i:Number = 0; i < numCols; i++){
_root.createTextField("dayHeadings" + i, i, indColWidth*i, startSecRowYPos, indColWidth, colHeight);
_root["dayHeadings"+i].border = true;
_root["dayHeadings"+i].text = dayHeadings[i];
}
anyone have any ideas?
thanks to anyone for helping out. fumeng.
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
First Loop 1 Sec, Next Loop 10 Sec, Have Code
I have this code in the last frame
Code:
stop();
var loop = true;
var timer = setInterval(makeLoop, 10000);
function makeLoop()
{
if(loop)
{
loop = false;
clearInterval(timer);
Play();
}
}
How can i put something in the first frame, so that the first loop take 1 sec, and then the code above will kick in instead of the code in the first frame?
btw, im a newbie.
EDIT:
i know that i can create a varible in the first frame like:
Code:
If (xx) {
} else {
make first loop 1 sec
xx = true;
}
For Loop Inside Of A For Loop?
Could someone please tell me why this code does not work?:
Code:
if (_root.aw3.getItemAt(count).Search == "Search") {
_root.wnd2 = Window.getWindowsByName();
for (var i = 0; i<_root.wnd2.length; i++) {
_root.searchMe = _root.wnd2[i].caption;
_root.searching = _root.aw3.getItemAt(count).Label;
_root.splitArray = _root.searchMe.split(_root.searching);
if (_root.splitArray.length>1) {
trace("Found a match from string!");
}
}
The Loop That Just Dosn't Loop...
After some more testing I have "the attached"...
I have moved the code onto the first frame but something is wrong...
When you click the button, it only works onces and then stops... if you keep on clicking the button the MCs get there, but they should get there in 1 click and not 17.....
Anyone know why???? :confused: :confused:
PS. the code looks very long for what it does....mmmm I need a code cleaner lol... :o
Translate 'while' Loop To 'for' Loop
hi.
i'm create a grid-like structure and am trying to translate my old loop:
Code:
while (dayCount <= lastDay) // creates 30 text fields
to a 'for' loop where I can increment the position of each duplicated text field by i * a specified width.
the thing is that i can't figure out how to do that with my while loop. but i can do it with a 'for' loop. that's why i'm trying to change it.
earlier in my code i use this 'for' loop to lay out the row above where i want to start....
Code:
for(var i:Number = 0; i < numCols; i++){
_root.createTextField("dayHeadings" + i, i, indColWidth*i, startSecRowYPos, indColWidth, colHeight);
_root["dayHeadings"+i].border = true;
_root["dayHeadings"+i].text = dayHeadings[i];
}
anyone have any ideas?
thanks to anyone for helping out. fumeng.
Does My For Loop Kill My While Loop?
In the code below i get results in tracing the ary array outside the while loop but not inside.
As I see it I just process the ary array to times. I don't see how they conflict?
ActionScript Code:
var i:Number = 0;
var n:Number = this.submenus.length;
// submenus will be an array contain the submenu nodes
ary = []
for (i = 0; i < n; ++i){
ary.push(this.submenus[i].attributes.nr)
}
ary.sort( function() { return random(2)? 1 : -1; });
trace(ary)// getting the correct randome arry output
while (i < n)
{
trace(ary[i])// get nothing.. not even "undefined"
}
hmmmmm.....?
Help On For Loop, I Get An Infinite Loop
Last edited by iliad2b : 2005-07-21 at 16:03.
Can anyone tell me what is wrong with my for loop?
Code:
var id:Array = new Array;
var comment:Array = new Array;
var _size:Number = 5;
var titleBar:Array = new Array;
for (var i:Number = 0; i <= _size - 1; i++)
{
titleBar.addItemAt(i, {ID: id[i]});
for (var j:Number = 0; j == i; j++)
{
titleBar.addItemAt(j, {Coments: comments[j]});
commentList_dg.dataProvider = titleBar;
commentList_dg.getColumnAt(0).width = 45;
commentList_dg.getColumnAt(0).textAlign = "center";
commentList_dg.setStyle("alternatingRowColors", Array(0xEAEFF2, 0xF8FAFB));
commentList_dg.hScrollPolicy = "auto";
commentList_dg.rowHeight = 80;
}
}
for some reason, it goes into an infinite loop.
Path
hi all,
i have an mc(1) on the main timeline and another mc(2) inside mc(1); what would the path be to control mc(2) from within mc(1)? i tried things like:
mc1 and mc2 = instance names of mc(1) and mc(2)
_root.mc1.mc2.gotoAndPlay(2);
or simply
mc2.gotoAndPlay(2);
none of these work;
i appreciate any help here.
thx
Path?
Ok, I've been trying this for hours now...still can't get it working...
Let's suppose I have a holder MC placed in _root.othermc.HolderMC and now I'm loading an external swf (my.swf, located on a different domain than Holder MC) into this Holder. What do the LOADED and the TOTAL vars below have to look like ?!?!?
Holder.loadMovie("http://www.whatever.com/my.swf");
Holder._x = 0;
Holder._y = 0;
this.onEnterFrame = function() {
LOADED = Holder.getBytesLoaded();
TOTAL = Holder.getBytesTotal();
PERC = LOADED/TOTAL*100;
Please.....anyone...
[Edited by Natsurfer on 08-09-2002 at 03:28 PM]
|