MX: OnRelease Defined In For Loop -- Always The Same
Hey All,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...Here's the abridged code:var xmlPeopleList:XML = new XML();xmlPeopleList.ignoreWhite = true;xmlPeopleList.onLoad = function(bSuccess:Boolean) { if (bSuccess) { var xnRoot:XMLNode = this.firstChild; var xnPeople:XMLNode; for (var i:Number = 0; i < xnRoot.childNodes.length; i++) { xnPeople = xnRoot.childNodes[i]; _level0.attachMovie("hitArea","p"+i+"_mc",_level0. getNextHighestDepth()); eval("p"+i+"_mc")._width = eval("p"+i+"_txt")._width; eval("p"+i+"_mc")._height = eval("p"+i+"_txt")._height; eval("p"+i+"_mc")._x = eval("p"+i+"_txt")._x; eval("p"+i+"_mc")._y = eval("p"+i+"_txt")._y; eval("p"+i+"_mc")._alpha=20;// ----- Here's the problem area ----- // eval("p"+i+"_mc").onRelease = function():Void { getURL("mailto:"+xnPeople.attributes.email); } } }};xmlPeopleList.load("xml/people.xml");Any help would be appreciated.Thanks!Steve
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 03-07-2005, 08:36 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
MX: OnRelease Defined In For Loop -- Always The Same
Hey All,
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...
Here's the abridged code:
var xmlPeopleList:XML = new XML();
xmlPeopleList.ignoreWhite = true;
xmlPeopleList.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
var xnRoot:XMLNode = this.firstChild;
var xnPeople:XMLNode;
for (var i:Number = 0; i < xnRoot.childNodes.length; i++) {
xnPeople = xnRoot.childNodes[i];
_level0.attachMovie("hitArea","p"+i+"_mc",_level0. getNextHighestDepth());
eval("p"+i+"_mc")._width = eval("p"+i+"_txt")._width;
eval("p"+i+"_mc")._height = eval("p"+i+"_txt")._height;
eval("p"+i+"_mc")._x = eval("p"+i+"_txt")._x;
eval("p"+i+"_mc")._y = eval("p"+i+"_txt")._y;
eval("p"+i+"_mc")._alpha=20;
// ----- Here's the problem area ----- //
eval("p"+i+"_mc").onRelease = function():Void {
getURL("mailto:"+xnPeople.attributes.email);
}
}
}
};
xmlPeopleList.load("xml/people.xml");
Any help would be appreciated.
Thanks!
Steve
For Loop Button Defined Cannot Use HitTest
here's a section the code:
for (var i = 0; i<this.poss.length; i++) {
prof++;
_root.attachMovie("bouton", "b"+this.poss[i].x+this.poss[i].y, prof);
_root["b"+this.poss[i].x+this.poss[i].y]._x = INITPOSX+this.poss[i].x*TAILLEPIONX+this.poss[i].x*PAS;
_root["b"+this.poss[i].x+this.poss[i].y]._y = INITPOSY+this.poss[i].y*TAILLEPIONY+this.poss[i].y*PAS;
//this controls the bloodly rules
/*
_root["b"+this.poss[i].x+this.poss[i].y].onPress = function() {
trace("this works");
};0
*/
if (_root["b"+this.poss[i].x+this.poss[i].y].hitTest(_root.slider)) {
trace("hahahahahahahah");
clicked();
}
}
all i want to do is instead of onPress I want to use the keyBoard buttons using addListener. the _root.slider is a highlighter. why the hitTest is not working? When i highlight the object nothing happens. how do i solve this?
raskol
Loop In OnRelease
here what I am tying to do
ActionScript Code:
playMenu = ["AP","MP","SP","TP"]
mc.onRelease = function(){
for(ch =0; ch<playMenu.length; ch++){
getMenu = playMenu[ch]
if(!MSC){
trace([getMenu])
mc.gotoAndStop(2)
MSC = true;
}else {
mc.gotoAndStop(1)
MSC = false}
}}
Q: When I take the loop out of onRelease then mc button works fine, but i can't trace the array and if put the loop inside the onRelease event then button doesn't work and I can trace the array.
Some I am missing here, I don't know can some body let me know whats wrong.
Thanks
OnRelease In For Loop
This is an old problem, and I seem to remember that there was some way to fix it, but not the way.
Code:
for(i=1;i<8;i++)
{
for(o=1;o<6;o++)
{
_root.createEmptyMovieClip(("btn"+i+o), (i*10+o));
temp2=eval("btn"+i+o);
temp3=eval("pic"+i+o);
temp2.hitArea = temp3;
temp2.onRelease = function()
{
loadMovie(fold+eval(grade)[picnum-(5-o)-(7-i)*5]+".jpg", _root.transclip.pic);
...
}
...
}
}
Basically the problem is that each time you click any of the items, it returns the same i and o values, whereas I want it to return the i and o values respective to which clip was pressed.
For Loop With .onRelease
Can anyone tell me why this isn't working? The "i" value always ends up on 3 for all 3 buttons.
Thanks,
g
for (i=1; i<=3; i++) {
t = this["button" + i + "_mc"];
t.onRelease = function () {
_root.panelSwitch (i);
}
}
For Loop In OnRelease()
How can I set the variable in currItem.onRelease = function() according to the for loop? Cause, what it does is actually on click on any of the buttons, it will return me the last value of the loop. Meaning if on click on any of the buttons say if there are 8 buttons, and button1 has var = 1, button2 var =2 and so on, I clicked on any of the buttons, it returns var = 8 for all. How can I make it such that on click button1 return 1, button5 return 5 and so on?
for (var i = 0; i<numBtns; i++)
{
currItem = currMenu.attachMovie("menuBtn","btn" + i + "_mc", i + 1);
currMenuTitle = menuTitle.attachMovie("menuNameMC","title",0);
currMenuTitle._x = 100;
currMenuTitle._y = 100;
currMenuTitle.menuName.text = recData.MuscleDesc0;
currItem._x = x;
currItem._y = y + i*currItem._height;
currItem.trackAsMenu = true;
btnName = eval("recData.Name"+i);
currItem.btnName.text = btnName;
currItem.onRelease = function()
{
myVar = i;
}
}
Why Can't Add Btn.onRelease In A Loop?
Hello, experts
I'm tring to add a onRelease event into every button I have, code like
Quote:
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
Quote:
button1.onRelease = function(){gotoPage(0)};
button2.onRelease = function(){gotoPage(1)};
button3.onRelease = function(){gotoPage(2)};
button4.onRelease = function(){gotoPage(3)};
button5.onRelease = function(){gotoPage(4)};
any help would be appriciated!
Need Some (onRelease, For Loop) Help
Hi,
i just tried to post this in the forum and my IE crashed, so forgive me if i double post. im trying to get this script to call different results from my onRelease depending on what button has been pressed. you will need a movieclip in your library with the linkage "button" and a textbox inside it called myText. Any help with this would be greatly appreciated.
stop();
/* Format XML text (Might not be necessary for this project)
targetClip.myText.html = true;
targetClip.myText.wordWrap = true;
targetClip.myText.multiline = true;
targetClip.myText.label.condenseWhite = true;
*/
/* Apply CSS
playlistStyle = new TextField.StyleSheet();
playlistStyle.load("playlist.css");
targetClip.myText.styleSheet = playlistStyle;
*/
// Parse XML
songPlaylist = new XML();
songPlaylist.ignoreWhite = true;
songPlaylist.load("playlist.xml");
songPlaylist.onLoad = function(success) {
// XML Variables
var playlist = songPlaylist.firstChild;
var songs = playlist.childNodes;
var songCount = songs.length;
//
if (success) {
createPlaylist(songCount, songs);
} else {
trace("XML file did not load, please refresh your browser.");
}
};
//
// create buttons for xml
createPlaylist = function (songCount, songs) {
for (i=0; i<songCount; i++) {
// Variables (XML attributes)
var myArtist = songs[i].attributes.artist;
var myTitle = songs[i].attributes.title;
var myURL = songs[i].attributes.url;
// Attach button movieclips
targetClip = this.attachMovie("button", i, i);
// Position Clips
targetClip._x = 10;
targetClip._y = 5+(i*25);
// Populate myText
targetClip.myText.text = myArtist+" - "+myTitle;
// Event Handlers and Mouse Events
targetClip.onRollOver = onRollOverHandler;
targetClip.onRollOut = onRollOutHandler;
targetClip.onRelease = onReleaseHandler;
}
};
// Events
onRollOverHandler = function () {
this.gotoAndStop("rollOver");
};
onRollOutHandler = function () {
this.gotoAndStop("rollOut");
};
onReleaseHandler = function () {
// should trace back an index number relative to the button released.
};
-----
(Here's the accompying xml files called playlist.xml)
<?xml version="1.0" encoding="ISO-8859-1"?>
<playlist>
<song artist ="King Tubby" title ="Hi-Grade Dub" url ="/songs/song1.mp3"/>
<song artist ="Scientist" title ="Ganga Dub" url ="/songs/song2.mp3"/>
<song artist ="Massive Attack" title ="Karmacoma" url ="/songs/song3.mp3"/>
<song artist ="Sly & The Family Stone" title ="Sexy Situation" url ="/songs/song4.mp3"/>
<song artist ="Leeroy Brown" title ="Metro Pigs" url ="/songs/song5.mp3"/>
</playlist>
Need Some (onRelease, For Loop) Help
Hi,
i just tried to post this in the forum and my IE crashed, so forgive me if i double post. im trying to get this script to call different results from my onRelease depending on what button has been pressed. you will need a movieclip in your library with the linkage "button" and a textbox inside it called myText. Any help with this would be greatly appreciated.
stop();
/* Format XML text (Might not be necessary for this project)
targetClip.myText.html = true;
targetClip.myText.wordWrap = true;
targetClip.myText.multiline = true;
targetClip.myText.label.condenseWhite = true;
*/
/* Apply CSS
playlistStyle = new TextField.StyleSheet();
playlistStyle.load("playlist.css");
targetClip.myText.styleSheet = playlistStyle;
*/
// Parse XML
songPlaylist = new XML();
songPlaylist.ignoreWhite = true;
songPlaylist.load("playlist.xml");
songPlaylist.onLoad = function(success) {
// XML Variables
var playlist = songPlaylist.firstChild;
var songs = playlist.childNodes;
var songCount = songs.length;
//
if (success) {
createPlaylist(songCount, songs);
} else {
trace("XML file did not load, please refresh your browser.");
}
};
//
// create buttons for xml
createPlaylist = function (songCount, songs) {
for (i=0; i<songCount; i++) {
// Variables (XML attributes)
var myArtist = songs[i].attributes.artist;
var myTitle = songs[i].attributes.title;
var myURL = songs[i].attributes.url;
// Attach button movieclips
targetClip = this.attachMovie("button", i, i);
// Position Clips
targetClip._x = 10;
targetClip._y = 5+(i*25);
// Populate myText
targetClip.myText.text = myArtist+" - "+myTitle;
// Event Handlers and Mouse Events
targetClip.onRollOver = onRollOverHandler;
targetClip.onRollOut = onRollOutHandler;
targetClip.onRelease = onReleaseHandler;
}
};
// Events
onRollOverHandler = function () {
this.gotoAndStop("rollOver");
};
onRollOutHandler = function () {
this.gotoAndStop("rollOut");
};
onReleaseHandler = function () {
// should trace back an index number relative to the button released.
};
-----
(Here's the accompying xml files called playlist.xml)
<?xml version="1.0" encoding="ISO-8859-1"?>
<playlist>
<song artist ="King Tubby" title ="Hi-Grade Dub" url ="/songs/song1.mp3"/>
<song artist ="Scientist" title ="Ganga Dub" url ="/songs/song2.mp3"/>
<song artist ="Massive Attack" title ="Karmacoma" url ="/songs/song3.mp3"/>
<song artist ="Sly & The Family Stone" title ="Sexy Situation" url ="/songs/song4.mp3"/>
<song artist ="Leeroy Brown" title ="Metro Pigs" url ="/songs/song5.mp3"/>
</playlist>
For Loop And OnRelease
I've tried a couple things so far to figure this out without any success. Please let me know if you see any quick fixes for this.
Thanks,
Saveth
Code:
var booths:Array = new Array();
for(var i=1; i<15; i++){
booths[i] = "booth_" + i + "_mc";
}
for(var i=1; i<15; i++){
container_mc.booths[i].id = i;
container_mc.booths[i].onRelease = function () {
trace(booths[this.id]);
}
}
OnRelease In For-loop.
I have a lot of movieclips named a1 ... a45 and would like to create onReleases on them all.
I've tried:
for (i=1; i<46; i++) {
("a"+i).onRelease = function() {
getURL(i+".jpg", "_blank");
};
}
but it does not seems to work. Any ideas?
For Loop In OnRelease()
How can I set the variable in currItem.onRelease = function() according to the for loop? Cause, what it does is actually on click on any of the buttons, it will return me the last value of the loop. Meaning if on click on any of the buttons say if there are 8 buttons, and button1 has var = 1, button2 var =2 and so on, I clicked on any of the buttons, it returns var = 8 for all. How can I make it such that on click button1 return 1, button5 return 5 and so on?
for (var i = 0; i<numBtns; i++)
{
currItem = currMenu.attachMovie("menuBtn","btn" + i + "_mc", i + 1);
currMenuTitle = menuTitle.attachMovie("menuNameMC","title",0);
currMenuTitle._x = 100;
currMenuTitle._y = 100;
currMenuTitle.menuName.text = recData.MuscleDesc0;
currItem._x = x;
currItem._y = y + i*currItem._height;
currItem.trackAsMenu = true;
btnName = eval("recData.Name"+i);
currItem.btnName.text = btnName;
currItem.onRelease = function()
{
myVar = i;
}
}
MC Button Loop Won't OnRelease
I have a loop to create clip buttons w/jpg images on face && load same jpgs onRelease into main viewer clip, ala Photo Gallery. But, the button movieclips won't onRelease. No action at all...
code:
for(i=1;i<3;++i)
{
var mc = "mc"+i; // button mc clip names
var images:Array = new Array(["../images/"+i+".jpg"]); //1.jpg, 2.jpg - 72px square
//-- create base mc & then another mc -----------------
_root.createEmptyMovieClip("base",i);
_root[base].createEmptyMovieClip(mc,i+4);
//-- set mc location
_root[base][mc]._x = 100;
_root[base][mc]._y = i*80;
//-- load button jpg images -----
_root[base][mc].loadMovie(images);
///////////////////////// works up to this point ////////////////////////
/////// displays 2 images, but can't make into buttons...////////////////
// -- make mc into buttons and load jpgs into main_mc holder -------
_root[base][mc].onRelease = function()
{
_root.main_mc.loadMovie(images);
};
}
For Loop Works For All But OnRelease
i am making a basic picture viewer....and trying to better understand for loops. i have the 7 thumbnails programatically generated and positioned. The onRollOver, and onRollOut effects work fine for each. The only thing i am not understanding is how to make each thumbnail upon onRelease unique...in other words, i have to write the onRelease functions seperately for each thumbnail in order to bring a new large picture to the stage....is there a way to do this within the "for" loop- or at least more dynamically?:
Code:
function loadImages(myXML) {
var mcImage:MovieClip;
// Load the four images.
for (var i = 0; i<=7; i++) {
frames[i]._visible=false
mcImage = this.createEmptyMovieClip("mcImage"+i, this.getNextHighestDepth());
mcImage.createEmptyMovieClip("mcHolder", mcImage.getNextHighestDepth());
mcImage._alpha = 30;
mcImage.onRollOver = function() {
upAlpha(this);
};
mcImage.onRollOut = function() {
downAlpha(this);
};
mcImage0.onPress = function() {
loadBigImage(0);
};
mcImage1.onPress = function() {
loadBigImage(1)
};
mcImage2.onPress = function() {
loadBigImage(2)
};
mcImage3.onPress = function() {
loadBigImage(3)
};
mcImage4.onPress = function() {
loadBigImage(4)
};
mcImage5.onPress = function() {
loadBigImage(5)
};
mcImage6.onPress = function() {
loadBigImage(6)
};
mcImage7.onPress = function() {
loadBigImage(7)
};
var mclLoader:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
var mclLoader:MovieClipLoader = new MovieClipLoader();
mclLoader.addListener(mclListener);
//this listerner will always refrence the clip immediately loaded
mclListener.onLoadInit = function(mcClip:MovieClip) {
if(nX==undefined){
nX=Stage.width/2-(mcClip._width +200);
nY=20;
}
mcClip._parent._x=nX;
mcClip._parent._y=nY;
nX+= mcClip._width+10;
if (mcClip._x>Stage.width){
//define method to start second row
}
};
mclLoader.addListener(mclListener);
mclLoader.loadClip("images/"+myXML.firstChild.childNodes[i].attributes.thumb,mcImage.mcHolder);
}
}
function loadBigImage(index) {
var bigImageX:Number;
var bigImageY:Number;
var bigImageLoader:MovieClipLoader= new MovieClipLoader;
var bigImageListener:Object= new Object
bigImageListener.onLoadInit=function (mcCurrentBigImage:MovieClip):Void{
mcCurrentBigImage._alpha=80;
/*if(bigImageX==undefined){
bigImageX= Stage.width/2- (mcCurrentBigImage._width)/2
bigImageY= Stage.height/4-50;
}
mcCurrentBigImage._x=bigImageX;
mcCurrentBigImage._y=bigImageY;*/
}
bigImageLoader.loadClip("images/"+myXML.firstChild.childNodes[index].attributes.picture, imageTank);
bigImageLoader.addListener(bigImageListener);
}
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success:Boolean) {
if (success) {
loadImages(this);
}
};
myXML.load("images/images.xml");
FOR LOOP OnRelease Problem
I have found several sites about this, but I can't seem to figure out the answer and implement it into my code. I know it's something simple somewhere, but I'm not a programmer by nature and I'm stuck.
I am trying to make a drag and drop template that will pull randomly from a text file or MySQL db later. I have hard coded this and it works fine, but there are 24 MCs in this app (12 goals and 12 movers) and I know there is a way to FOR LOOP through this.
I have the for loop set up and most of it works fine. Things are draggable, things stop dragging when released, text boxes are populated, the movers are scattered around the stage on startup. The problem is only the highest value of [i] is assigned. So the mover MC named mover12_mc is the only one that matches the goal. Actually all the draggable movers are named mover12_mc, but their text is correct. For now I am only matching numbers 1-1, 2-2, etc. Later it will be months or weekday names to be put in order. This hang up has caused me to stop several apps since I am sick of hard coding them.
I have narrowed it down to a parent child delegation instance, I think. I found a great tutorial on senocular.com, but as I said I still can't fully match it to my code. Any suggestions would be greatly appreciated.
var moverXloc:Number = 200;
var goalXloc:Number = 50;
var goalBaseYloc:Number = 10;
var totalDiff:Number = 40;
var numBoxes:Number = 13; //one extra
var orderNums:Number = 1;
// loops through numBoxes variable and changes each text box to 1 + the base.
for (i=1; i<numBoxes; i++)
{
showMnums = eval("mover"+i+"_mc.order_thing");
showMnums.text = i; // orderNums + i;
showGnums = eval("goal"+i+"_mc.order_num");
showGnums.text = i; // orderNums + i;
moverName = eval("mover"+i+"_mc");
moverName._x = 160 + Math.floor(Math.random()*(245-160+1));
moverName._y = Random(450); // they all start in random places
// functions for clicking each mover box
moverName.onPress = function () {
this.startDrag();
// each one is draggable, no problems here
}
goalName = eval("goal"+i+"_mc");
//
moverName.onRelease = function () {
trace(moverName);
this.stopDrag();
if (moverName.hotSpot_mc.hitTest(goalName.hotSpot_mc) ) {
moverName._x = goalXloc;
moverName._y = 10;
this.enabled = false;
// ALL the draggable things end up being named as the highest value of i.
// in this case they are all named mover12_mc
} // closes the IF loop
} // closes the eval-movername function
} // closes FOR loop
Thanks in advance.
Defining OnRelease In A Loop.
So I'm building a dynamic menu where the button actions change for each item that is listed. Now I think I could do this while writing classes, but I'm rushing to get it done, I'd rather just script functions for it. However, when I run a for loop, it sets all values of all buttons (see code) to the value+1 of i. Thus, each button has the same action, and unless I manipulate i-- doesn't work. Anyway, my real question is whether LIFE cereal is a healthy cereal or a sugary one.
Second to that, I need to know how I would do this.
for(i=1;i<someOtherVariable;i++) {
_root.["myButton"+i].onRelease = function() {
//a bunch of functions that use i to opperate correctly
}
}
Can you help me?
Attach Code
for (i=1; i<=newNum; i++) {
_root.MenuBox["Option"+i] = _root.NCRlv["NEWS_TitleF"+i];
_root.MenuBox["button_"+i].onRelease = function() {
_root.mainOutOfTheWay("article_F_1.swf");
_root.newIDV = _root.NCRlv["NEWS_idV"+i];
_root.test2.text = _root.NCRlv["NEWS_idV"+i];
_root.loadNews(_root.newIDV);
};
}
MC Button Loop Won't OnRelease
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...Any help appreciated!
for(i=1;i<3;++i)
{
var mc = "mc"+i; // button mc clip names
var images:Array = new Array(["../images/"+i+".jpg"]); //1.jpg, 2.jpg - 72px square
//-- create base mc & then another mc -----------------
_root.createEmptyMovieClip("base",i);
_root[base].createEmptyMovieClip(mc,i+4);
//-- set mc location
_root[base][mc]._x = 100;
_root[base][mc]._y = i*80;
//-- load button jpg images -----
_root[base][mc].loadMovie(images);
///////////////////////// works up to this point ////////////////////////
/////// displays 2 images, but can't make into buttons...////////////////
// -- make mc into buttons and load jpgs into main_mc holder -------
_root[base][mc].onRelease = function()
{
_root.main_mc.loadMovie(images);
};
}
FOR Loop OnRelease Problems
I have found several sites about this, but I can't seem to figure out the answer and implement it into my code. I know it's something simple somewhere, but I'm not a programmer by nature and I'm stuck.
I am trying to make a drag and drop template that will pull randomly from a text file or MySQL db later. I have hard coded this and it works fine, but there are 24 MCs in this app (12 goals and 12 movers) and I know there is a way to FOR LOOP through this.
I have the for loop set up and most of it works fine. Things are draggable, things stop dragging when released, text boxes are populated, the movers are scattered around the stage on startup. The problem is only the highest value of [i] is assigned. So the mover MC named mover12_mc is the only one that matches the goal. Actually all the draggable movers are named mover12_mc, but their text is correct. For now I am only matching numbers 1-1, 2-2, etc. Later it will be months or weekday names to be put in order. This hang up has caused me to stop several apps since I am sick of hard coding them.
I have narrowed it down to a parent child delegation instance, I think. I found a great tutorial on senocular.com, but as I said I still can't fully match it to my code. Any suggestions would be greatly appreciated.
var moverXloc:Number = 200;
var goalXloc:Number = 50;
var goalBaseYloc:Number = 10;
var totalDiff:Number = 40;
var numBoxes:Number = 13; //one extra
var orderNums:Number = 1;
// loops through numBoxes variable and changes each text box to 1 + the base.
for (i=1; i<numBoxes; i++)
{
showMnums = eval("mover"+i+"_mc.order_thing");
showMnums.text = i; // orderNums + i;
showGnums = eval("goal"+i+"_mc.order_num");
showGnums.text = i; // orderNums + i;
moverName = eval("mover"+i+"_mc");
moverName._x = 160 + Math.floor(Math.random()*(245-160+1));
moverName._y = Random(450); // they all start in random places
// functions for clicking each mover box
moverName.onPress = function () {
this.startDrag();
// each one is draggable, no problems here
}
goalName = eval("goal"+i+"_mc");
//
moverName.onRelease = function () {
trace(moverName);
this.stopDrag();
if (moverName.hotSpot_mc.hitTest(goalName.hotSpot_mc) ) {
moverName._x = goalXloc;
moverName._y = 10;
this.enabled = false;
// ALL the draggable things end up being named as the highest value of i.
// in this case they are all named mover12_mc
} // closes the IF loop
} // closes the eval-movername function
} // closes FOR loop
Thanks in advance.
MC Button Loop Won't OnRelease
I have a loop to create clip buttons w/jpg images on face && load same jpgs into main viewer clip. Problem is, the buttons won't respond to onRelease...
for(i=1;i<3;++i)
{
var mc = "mc"+i; // button mc clip names
var images:Array = new Array(["../images/"+i+".jpg"]); //1.jpg, 2.jpg - 72px square
//-- create base mc & then another mc -----------------
_root.createEmptyMovieClip("base",i);
_root[base].createEmptyMovieClip(mc,i+4);
//-- set mc location
_root[base][mc]._x = 100;
_root[base][mc]._y = i*80;
//-- load button jpg images -----
_root[base][mc].loadMovie(images);
///////////////////////// works up to this point ////////////////////////
/////// displays 2 images, but can't make into buttons...////////////////
// -- make mc into buttons and load jpgs into main_mc holder -------
_root[base][mc].onRelease = function()
{
_root.main_mc.loadMovie(images);
};
}
Brand New Problem With A Loop And Onrelease
for(x=0; x<map.length; x++){
for(y=0; y<map[x].length; y++){
temp=createEmptyMovieClip("tile"+x+y, k)
if(map[x][y]==1){
square(temp, 0x999999, 80)
}
else if(map[x][y]==0){
square(temp, 0x999999, 10)
}
temp._x=x*10
temp._y=y*10
temp.onRelease=function(){
_root.i=temp._x
}
k++
}
}
when all the mc's from this loop are made, all their on release functions only use the last x value in the loop. i thought each different temp would use its respective x, but it doesnt. they all use the same one. i think it may have something to do with the temp var and what it does but im not sure. how could temp._x use a unique x value every time ( i know cuz the mc's r spaced evenly when i publish the movie) but the buttons all have one value of x. can anyone help me make the values unique?
Possible? OnRelease In A Loop, Array Of Buttons
Anyone know how to do this?
I've got 26 buttons that all perform the same function calls. I want to put them in a loop. I saved them into an array.
**** 26 of these ****
matButton0_btn.onRelease = function() {
loadMySelected(0);
setMyColors();
}
matButton1_btn.onRelease = function() {
loadMySelected(1);
setMyColors();
}
matButton2_btn.onRelease = function() {
loadMySelected(2);
setMyColors();
}
**** here's my array ****
var aMatButton:Array = new Array(
matButton0_btn, matButton1_btn, matButton2_btn... etc.
}
**** here's what I'm trying to do ****
this.onEnterFrame = function() {
for(var i:Number; i < aMatButton.length; i++) {
aMatButton[i].onRelease = function() {
loadMySelected(i);
setMyColors();
}
}
}
**** result ****
doesn't work
loop works outside of onEnterFrame but then only last button registers (which makes sense)
Any ideas???
[Flash 8] OnRelease In A FOR LOOP Problem
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.
Danielthelion suggested I post this here.
Any leads or sites would be great.
Thanks
Assign Button OnRelease In For() Loop
I am trying to do some dynamic button assignment when loading a XML file in the form of (it might not be pretty code, but its just for testing)
ActionScript Code:
var picList:XML = new XML();
picList.ignoreWhite = true;
var urls:Array = new Array();
var captions:Array = new Array();
var thumb:Array = new Array();
var whichPic:Number;
picList.onLoad = function(){
var photos:Array = this.firstChild.childNodes;
for(i=0;i<photos.length;i++){
urls.push(photos[i].attributes.url);
captions.push(photos[i].attributes.caption);
thumb.push(photos[i].attributes.thumb);
}
loadPicture(urls[0])
description.text = captions[0];
whichPic = 0;
//Thumbnails---------------------------
for(i=0;i<photos.length;i++){
k=i+1;
_root["thumb"+k].loadMovie(thumb[i]);
_root["thumbBut"+k].onRelease = function(){setPicture(i)};
}
}
picList.load("pics.xml");
where I have some functions that handle the effects etc. when loading the pictures (that is the loadPicture(), and setPicture() functions).
My trouble is that none of the buttons actually work when using this procedure (all buttons try to load a picture with index photos.length+1 i.e. non existent), but if I instead define the buttons actions seperately as
ActionScript Code:
_root.thumbBut1.onRelease = function(){setPicture(0)};
the buttons work as intended.
Assigning OnRelease To Movies In Loop
Hi, I need help with actionscript.
I'm creating an XML-driven image gallery based on the tutorial here ....
http://www.kirupa.com/web/xml/examples/portfolio.htm
The script counts the number of images, loops according to a set limit of thumbs for each menu page, creates the appropriate number of pages, thumbs and a menu for the page numbers. Everything works fine except the assignment of onRelease to the buttons for the page number menu. This part ....
item_mc.onRelease = function(){
currentPage._visible = true
}
currentPage is being overwritten every time the script loops, so it always ends up making the final page of thumbs visible no matter which button is clicked. What mistake am I making? What's the trick to get the onRelease function to assign and increment to produce the correct action for each button?
And I haven't thought of a way to turn off the pages that aren't selected yet.
Can you help?
thanks
mark
Here's the full script so far ....
// load variables object to handle loading of text
var description_lv = new LoadVars();
description_lv.onData = function(raw_text){
description_txt.text = raw_text;
}
function cgstills(cgstills_xml){
var portfolioPictures = cgstills_xml.firstChild.childNodes;
var currentPage = 0
// thumb spacing
var thumb_spacing = 40;
//total number of items
var item_total = portfolioPictures.length
//items per menu page
var item_number = 3
//calculate page total
var page_total = Math.floor(item_total / item_number) + 1
//trace (page_total)
var page_number = 0
// current thumbnail (keeps track of total thumbs processed)
var currentItem = 0
// temp page button spacing
var btn_spacing = 50
// start creating pages
for (page_number = 1; page_number <= page_total; page_number++){
currentPage = menu_mc.createEmptyMovieClip("page"+ page_number, page_number);
// start creatingthumbs
for (i = 0; i < item_number; i++){
var currentPicture = portfolioPictures[currentItem];
var currentThumb_mc = currentPage.createEmptyMovieClip("thumbnail_mc"+currentItem, i);
currentThumb_mc._x = i * thumb_spacing;
currentThumb_mc.createEmptyMovieClip("thumb_container",0);
currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
currentThumb_mc.title = currentPicture.attributes.title;
currentThumb_mc.image = currentPicture.attributes.image;
currentThumb_mc.description = currentPicture.attributes.description;
currentThumb_mc.onRollOver = currentThumb_mc.onDragOver = function(){
info_txt.text = this.title;
}
currentThumb_mc.onRollOut = currentThumb_mc.onDragOut = function(){
info_txt.text = "";
}
currentThumb_mc.onRelease = function(){
image_mc.loadMovie(this.image);
description_lv.load(this.description);
}
// increment thumb total
currentItem++
} // end of thumbs
var item_mc = page_mc.attachMovie("item","item"+ page_number, page_number);
item_mc._y = page_number * btn_spacing;
item_mc.btn_txt.text = page_number
// hide current page
currentPage._visible = false;
// add script to item_mc btns
item_mc.onRelease = function(){
currentPage._visible = true
}
} // end of pages
// page1 visible
_level0.menu_mc.page1._visible = true;
} // end of cgstills
// xml object for xml content (defines sources for selections)
var cgstills_xml = new XML();
cgstills_xml.ignoreWhite = true;
cgstills_xml.onLoad = function(success){
if (success)
cgstills(this);
//trace(this);
else trace("Error loading XML file"); // trace error
}
// load
cgstills_xml.load("cgstills.xml");
Page 2 - MC Button Loop Won't OnRelease
Heya, you can use loadVars to load the image text data into flash:
PHP Code:
//
// if the text file was like this:
// txtImgs=AB_050906_Castle.jpg,AB_050806_Castle2.jpg,H_050806_beachGirls.jpg,S_050806_campTent.jpg
//
var lvImgs = new LoadVars();
lvImgs.onLoad = function(s)
{
if(s)
{
// This will split the long string into an array of individual file names
_root.arrImgs = this.txtImgs.split(",");
createImageButtons();
}
else
{
trace("Error: Couldnt load text file");
}
}
// This is pretty much what was there before except its all been pushed into a function
function createImageButtons()
{
_root.createEmptyMovieClip("base", 1);
for(i = 1; i < 3; ++i)
{
var imgButton = _root.base.createEmptyMovieClip("mc" + i, i);
var img = imgButton.createEmptyMovieClip("img", 0);
imgButton._x = 100;
imgButton._y = i * 80;
imgButton.imgFile = _root.arrImgs[i];
img.loadMovie(imgButton.imgFile);
imgButton.onRelease = function()
{
_root.main_mc.loadMovie(this.imgFile);
};
}
}
// You can use this later on to search through all the image path data. You'll probably want to modify this function to do exactly what you want.
// call it like this: search("bob", "050806", "campTent");
// or: search("bob", undefined, "campTent");
// you dont need to enter all fields to do a successfull search
function search(sname, sdata, sevent)
{
var arrTmp = [];
for(var i = 0; i < _root.arrImgs.length; i++)
{
arrTmp = _root.arrImgs[i].substring(0, _root.arrImgs[i].length - 4).split("_");
if(arrTmp[0] == sname || arrTmp[1] == sdata || arrTmp[2] == sevent)
{
trace("Found Match");
}
}
}
// This starts the text file loading. When thats complete the onLoad function near the top is called. If the load was successful then the createImageButtons function is called.
lvImgs.load("imagetextfilename.txt");
Attach OnRelease To Multiple Buttons With For Loop
i have 40 mc's on stage that are used like buttons, with rollovers etc.. I want to dynamically attach a sound effect onRelease to all 40 mc's using a for loop, i have this actionscript but the trace is not working:
code:
for (var i = 1; i<=40; i++) {
trace("button"+i);
("button"+i).onRelease= function() {
trace("yes"+i);
};
}
Creating OnRelease Code With Arrays And A Loop
I feel stupid for asking this, but I have no idea why this is not working.
buttonLINKS = [1,2,3,4];
buttonsArray = [navigation.menu.A,
navigation.menu.B,
navigation.menu.C,
navigation.menu.D];
And this is what I wrote....
Code:
for (i=0;i<buttonsArray.length;i++) {
buttonsArray[i].onRelease = function() {
loadThis(buttonLINKS[i]);
}
}
Attach OnRelease To Multiple Buttons With For Loop
i have 40 mc's on stage that are used like buttons, with rollovers etc.. I want to dynamically attach a sound effect onRelease to all 40 mc's using a for loop, i have this actionscript but the trace is not working:
ActionScript Code:
for (var i = 1; i<=40; i++) {
trace("button"+i);
("button"+i).onRelease= function() {
trace("yes"+i);
};
}
Attatching MC.onRelease Event Handler Via Loop
I'm trying to attatch an onRelease event handler at runtime to a bunch of MC's that are added via an xml doc. here's the totally lame why i've got it working at the mo:
ActionScript Code:
scrollclip.emptyMC.im1.onRelease = function() {
imagePos = 0
trace("this is the first")
loadImage(imagePos);
}
scrollclip.emptyMC.im2.onRelease = function() {
imagePos = 0.5
loadImage(imagePos);
}
scrollclip.emptyMC.im3.onRelease = function() {
imagePos = 1
loadImage(imagePos);
}
and here's what i'm trying to get to work...although i've tried a bunch of different conitations with no luck:
ActionScript Code:
ThumbsV = total_amount_of_MCs
for(var q = 1; q < ThumbsV; q ++){
scrollclip.emptyMC["im" + q].onRelease = function() {//these have already been added to the stage.
imagePos = scrollclip.emptyMC["im" + (q-1)].imagePos + 0.5
loadImage(imagePos);
}
}
if anyone can help or even shed light on this pain in the ass - it would be awesome!!
For Loop Issues While Creating OnRelease Events
I am developing an XML slideshow that has horizontal scrolling. I have a FOR loop (seen below) that populates a movie clip that lists the page numbers.
Code:
for(i=1;i<=totalPages;i++) {
bar.numbersHolder.attachMovie("numberField", 'nf'+i, 50+i, {_x: xval,_y:0});
bar.numbersHolder['nf' + i].numberValue.text = i;
bar.numbersHolder['nf' + i].line._visible = false;
bar.numbersHolder['nf' + i].hidden23._alpha = 0;
// I know the following is incorrect
bar.numbersHolder['nf' + i].onRelease = function() {
setPage(i);
}
xval += 15;
//trace(i);
}
However, I know the onRelease function doesn't work properly. When the user clicks on the movie clip that value of "i" is not the value associated with the movie clip, but rather the value left after the FOR Loop is completed. I am not sure how to handle this. I thought of using variable variables, but I just ran into the same problem.
Any ideas?
Loop Variable Not Working Inside OnRelease Function
Hello,
I've been lurking around these boards for quite a while and have found them to be invaluable help when I'm stuck on a problem, since someone has usually already had the same frustration as I have, and I can usually get the answer I need just from reading other posts... but not this time.
I'm having a problem with a photo album I am making in Flash. I have successfully gotten the thumbnails to load and display correctly by using a "for" loop (as seen below) but I run into trouble when I try to make the thumbnails clickable. It seems as though the "onRelease" function that I apply to each thumbnail MovieClip cannot read the "i" variable used in the for loop.
My code is as follows:
ActionScript Code:
/////////////////////////////////////////////////////////
archiveIn = new LoadVars();
archiveIn.load("readArchives.php");
archiveIn.onLoad = function(success) {
if (success) {
numOfDirs = archiveIn.numOfDirs;
archiveDir = archiveIn.archive.split("|");
archiveDir.reverse();
width = archiveIn.thumbWidth.split("|");
width.reverse();
height = archiveIn.thumbHeight.split("|");
height.reverse();
firstClipPositionX = 0;
firstClipPositionY = 0;
highestThumb = 0;
// Create all the thumbnail clips in a loop.
for (i=0; i<numOfDirs; i++) {
createEmptyMovieClip("archiveThumb"+i, _root.getNextHighestDepth());
_root["archiveThumb"+i].createEmptyMovieClip("holder", this.getNextHighestDepth());
_root["archiveThumb"+i].holder.loadMovie("weeks/"+archiveDir[i]+"/001_thumb.jpg");
_root["archiveThumb"+i].createTextField("week", _root.getNextHighestDepth(), 0, height[i], width[i], 20);
--HERE IS WHERE THE PROBLEM LIES----------------------------------
_root["archiveThumb"+i].onRelease = function() {
getURL("viewer.php?dir="+archiveDir[i], "_blank");
};
The "archiveDir[i]" returns "undefined."
----------------------------------------------------------------------------
weekFormat = new TextFormat();
weekFormat.font = "Arial";
weekFormat.size = 10;
weekFormat.align = "center";
_root["archiveThumb"+i].week.text = "Week "+archiveDir[i];
_root["archiveThumb"+i].week.setTextFormat(weekFormat);
_root["archiveThumb"+i]._x = firstClipPositionX+10;
_root["archiveThumb"+i]._y = firstClipPositionY+10;
firstClipPositionX = Math.round(_root["archiveThumb"+i]._x)+Math.round(width[i]);
if (height[i]>highestThumb) {
highestThumb = height[i];
}
if ((i+1)%5 == 0) {
firstClipPositionX = 0;
firstClipPositionY = Math.round(_root["archiveThumb"+i]._y)+Math.round(highestThumb)+10;
}
}
}
};
/////////////////////////////////////////////////////////
Everything works beautifully except for the onRelease function. If anyone out there has any advice for me, that would be great (or a solution... that would be even better ). At any rate, I'd really appreciate some help.
Thanks!
James
Button With 2 Functions? Onrelease=true, Onrelease=false
I have a button that uses a function to set the visibility of an mc. BUT it's called with an 'onrelease' and I would like the button to change the visibilty back to false on the next onrelease. Understand?
Here's my code:
list_btn.onrelease = function() {
playlist._visible = true;
}
Now I want to press the same button and have the mc (playlist) go back to false. I tried using some 'if' statements but just couldn't seem to get it right. My brain is just not working today.
Need some help please!
IF (a = Defined){}
hello friends,
I guess this is a really basic question. But I have been roaming the forums and just don't seem to be searching with the right keywords. Here it goes: I know that there is 'undefined' what would be the oposit of that? 'Defined' obviousely but there is no statement like that, as far as I can see...
anyone?
V
How Is The ( Bit3) Defined
In the script below; each frame1 has a --symbol, (entity)--
This is true for all except the test test sysmbols. Where do the Parentheses get defined; (bit3) or (shadow6) for example)? How do I change the values inside, not the name?
circs
frame 1
circ1, (bit3)
circ2, (bit4)
circ3, (bit5)
circshadows
frame 1
circ1s, (shadow3)
circ2s, (shadow4)
circ3s, (shadow5)
testshadow
frame 1
test shadow
test
frame 1
test
pic
frame 1
pic, (bit6)
picshadow
frame 1
picshadow, (shadow6)
[Edited by Zlac on 10-18-2001 at 03:45 AM]
Defined Variable
i can i ask flash if a variable has been defined yet? and if false then define it?
Undefined... Yet Defined?
Hey guys,
It's been a really long time since I've used flash, and I've come across a strange little issue which I have no idea how to fix.
Basically I have a MovieClip with an instance name of "block" and a button. When I do this on the MovieClip:
Code:
onClipEvent(load) {
trace(this._name);
}
It works fine and traces out 'block' to output. Also works with _root.name and such.
Here's the tricky part... when I add
Code:
trace(block._name);
trace(_root.block._name);
to the frame in which 'block' sits, it returns undefined!
Same thing if I try to access the movieclip through the button. It seems like it's not defined.. but it itself is telling me that it is. Is there something I'm missing? Thanks.
Xml Is Undefined After Being Defined?
I recently tried converting a procedural xml app to an OOP XML based app and ran into a problem.
In my constructor I assign my class instance XML var to new XML(). In another public function I assign its onLoad event handler to a private function that does my business tasks. I then load my xml file. and get a bunch of "undefined" references.
The code worked fine before but I wanted to wrap it up and make it reusable in other projects by putting it into a class.
it looks similar to the following
Code:
public function className(){
xmlvar = new XML()
}
public function loadData(xmlurl){
xmlvar.ignreWhite = true;
xmlvar.onLoad = businessFn;
xmlVar.load(xmlurl);
}
private function businessFn(loaded){
if(loaded){
// should do business but xmlvar is undefined
} else {
//output error
}
}
If Array Is Defined
How do I check if an array is defined or if it's length is over 0.
When I do:
if (arrayname.length == 0) { }
I get an error, as do I for:
if (arrayname == undefined) {}
I just need to check if anything has been put in the array thus far.
But know that I am checking this in frame 2 and at the end of the code there is a button that sends them back to frame 1 which reloads some variables. I think the reloading wipes out the array and I need it to stay alive.
DetectFlashVer Not Defined
We have a page in which we are using the Flash detector kit to identify if user has proper flash version to display our flash banners. We receive the message "DetectFlashVer not defined". We are utilizing this technique on other pages in our site and it works fine, but just not on this one page.
One item to note is that when I copy the javascript file AC_OETags.js to the root directory and change the reference to it in the code from "/wsfunctions/AC_OETags.js" to "/AC_OETags.js" it works fine. Not that this matters or not, but page is using ajax, not for flash purposes.
Has anyone encountered this and if so, what is cause and fix?
FLV Controllers - DEFINED ?
Hi,
I'm experimenting with flash video and have 3 streaming files on
my server, progressively coded.
1.flv
2.flv
3.flv
i have a shuffle array so that it plays one of the above files
on start up of the main.swf
THE BIG QUESTION
once that FLV file has played back in its entirity how do
i then get it to automatically play the next FLV in sequence ?
Edited: 03/19/2008 at 01:34:11 AM by wAyStead
Variable Png Is Not Defined.
Hi,
I am migrating project from AS2. I have removed most of the compiler and run time errors, but I have no clue about this error. I can't track it.
ReferenceError: Error #1065: Variable png is not defined.
Any ideas what might be causing it?
Any replies would be greatly apriciated. Thanx
Check If Var Is Defined
Hello all,
I'm displaying a variable into a textbox, but sometimes it's value is unset (loading delay)
I'm using loadVariables so the .onLoad won't work..
How can I check if a variable already has a value?
Can A Variable Be Defined By What It Isn't?
I've created a number of MCs titled btn1, btn2, etc... for an XML MP3 player. Each MC lies behind a track name, derived from the XML file. Once clicked, the player skips to that particular song, and the corresponding MC beneath changes to a darker color to show which song is playing.
Fairly simple, but because I am also using forward and backward buttons, I am defining the MC names through a variable number.
When the forward button is pressed for example, I have it add one to the variable, and perform this function: eval("btn"+i).gotoAndPlay(2) (along with the other functions to play the next song). This does the trick in terms of getting the next button to highlight for the corresponding song.
But what I would like to do is also have a single function that tells every other button to go back to it's original state. Is there a way to define this somehow by saying
"everything that is not" eval("btn"+i).gotoAndStop(1)?
I hope that makes sense. I have the feeling there's probably something fairly rudimentary that I'm missing here. I am very grateful for anyone's help on this matter!
Thank you!
aaron
Check If Var Is Defined
Hello all,
I'm displaying a variable into a textbox, but sometimes it's value is unset (loading delay)
I'm using loadVariables so the .onLoad won't work..
How can I check if a variable already has a value?
NavigatToURL Is Not Defined.
im trying to get around firefoxs and ie7 pop up blocker. I keep getting
Error #1065: Variable URLNavigater is not defined.
at main/runOnce()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Code:
package
{
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.*;
import flash.display.stage.*;
import flash.events.*;
import flash.geom.ColorTransform;
import flash.utils.Dictionary;
import com.zorked.URLNavigator;
import flash.events.Event;
import org.papervision3d.core.proto.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
public class main extends Sprite
{
private var container :Sprite;
private var scene :MovieScene3D;
private var camera :Camera3D;
private var planeByContainer :Dictionary = new Dictionary();
private var paperSize :Number = 0.5;
private var cloudSize :Number = 500;
private var rotSize :Number = 360;
private var maxAlbums :Number = 10;
private var num :Number = 0;
var myTimer:Timer = new Timer(1000, 1);
// ___________________________________________________________________ stage
public var iFull :SimpleButton = new SimpleButton();
// ___________________________________________________________________ main
public function main()
{
stage.quality = StageQuality.MEDIUM;
init3D();
addChild( iFull );
this.addEventListener( Event.ENTER_FRAME, loop );
myTimer.addEventListener(TimerEvent.TIMER, runOnce);
}
public function runOnce(event:TimerEvent):void {
URLNavigater.ChangePage("http://www.google.com", "_blank");
}
private function init3D():void
{
container = new Sprite();
addChild( container );
container.x = 320;
container.y = 240;
scene = new MovieScene3D( container );
camera = new Camera3D();
camera.zoom = 5;
camera.extra =
{
goPosition: new DisplayObject3D(),
goTarget: new DisplayObject3D()
};
camera.extra.goPosition.copyPosition( camera );
}
private function createAlbum()
{
var material:MovieAssetMaterial = new MovieAssetMaterial( "Album" );
material.doubleSided = true;
material.lineColor = 0xFFFFFF;
material.movie.gotoAndStop( num % material.movie.totalFrames );
material.updateBitmap();
var plane :Plane = new Plane( material, paperSize, 0, 2, 2 );
// Randomize position
var gotoData :DisplayObject3D = new DisplayObject3D();
gotoData.x = Math.random() * cloudSize - cloudSize/2;
gotoData.y = Math.random() * cloudSize - cloudSize/2;
gotoData.z = Math.random() * cloudSize - cloudSize/2;
gotoData.rotationX = Math.random() * rotSize;
gotoData.rotationY = Math.random() * rotSize;
gotoData.rotationZ = Math.random() * rotSize;
plane.extra =
{
goto: gotoData
};
scene.addChild( plane, "Album" + String( num ) );
var container:Sprite = plane.container;
container.buttonMode = true;
container.addEventListener( MouseEvent.ROLL_OVER, doRollOver );
container.addEventListener( MouseEvent.ROLL_OUT, doRollOut );
container.addEventListener( MouseEvent.MOUSE_DOWN, doPress );
planeByContainer[ container ] = plane;
num++;
}
private function doPress(event:Event):void
{
var plane:Plane = planeByContainer[ event.target ];
plane.scaleX = 1;
plane.scaleY = 1;
myTimer.start();
var target :DisplayObject3D = new DisplayObject3D();
target.copyTransform( plane );
target.moveBackward( 350 );
camera.extra.goPosition.copyPosition( target );
camera.extra.goTarget.copyPosition( plane );
plane.material.lineAlpha = 0;
};
private function doRollOver(event:Event):void
{
var plane:Plane = planeByContainer[ event.target ];
plane.scaleX = 1.1;
plane.scaleY = 1.1;
plane.material.lineAlpha = 1;
};
private function doRollOut(event:Event):void
{
var plane:Plane = planeByContainer[ event.target ];
plane.scaleX = 1;
plane.scaleY = 1;
plane.material.lineAlpha = 0;
};
private function loop(event:Event):void
{
if( num < maxAlbums )
createAlbum();
update3D();
iFull.x = 640 + (stage.stageWidth - 640)/2;
iFull.y = 480 + (stage.stageHeight - 480)/2;
}
private function update3D():void
{
var target :DisplayObject3D = camera.target;
var goPosition :DisplayObject3D = camera.extra.goPosition;
var goTarget :DisplayObject3D = camera.extra.goTarget;
camera.x -= (camera.x - goPosition.x) /32;
camera.y -= (camera.y - goPosition.y) /32;
camera.z -= (camera.z - goPosition.z) /32;
target.x -= (target.x - goTarget.x) /32;
target.y -= (target.y - goTarget.y) /32;
target.z -= (target.z - goTarget.z) /32;
var paper :DisplayObject3D;
for( var i:Number=0; paper = scene.getChildByName( "Album"+i ); i++ )
{
var goto :DisplayObject3D = paper.extra.goto;
paper.x -= (paper.x - goto.x) / 32;
paper.y -= (paper.y - goto.y) / 32;
paper.z -= (paper.z - goto.z) / 32;
paper.rotationX -= (paper.rotationX - goto.rotationX) /32;
paper.rotationY -= (paper.rotationY - goto.rotationY) /32;
paper.rotationZ -= (paper.rotationZ - goto.rotationZ) /32;
}
scene.renderCamera( this.camera );
}
}
}
Here is the Zorked url file im trying to import:
Code:
package com.zorked {
import flash.external.ExternalInterface;
import flash.net.*;
public class URLNavigator {
/**
* Utility function to wrap up changing pages. Avoids over-aggressive popup blockers.
* @param url The URL to change to. Either a String or a URLRequest
* @param window The target browser window/tab, generally _self, _top, or _blank
* @usage URLNavigater.ChangePage("http://www.google.com", "_blank");
*/
public static function ChangePage("http://www.google.com":*, "_self":String = "_self"):void {
var req:URLRequest = "http://www.google.com" is String ? new URLRequest("http://www.google.com") : "http://www.google.com";
if (!ExternalInterface.available) {
navigateToURL("http://www.google.com", "_self");
} else {
var strUserAgent:String = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
if (strUserAgent.indexOf("firefox") != -1 || (strUserAgent.indexOf("msie") != -1 && uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) >= 7)) {
ExternalInterface.call("window.open", req."http://www.google.com", "_self");
} else {
navigateToURL("http://www.google.com", "_self", "_self");
}
}
}
}
}
and here is the screenshot of where i placed the zorked file. test.fla is the fla file im working with. Also, main imports correctly. I just cant seem to get zorked imported correctly or im not calling the function correctly.
It's been killing me for a while. I would love any help possible.
Go To Scene Defined By Variable?
Hi guys,
I have a variable named 'profile' and I'm trying to set a gotoAndPlay function to go to whatever scene 'profile' holds as its value. How am I able to do this? Fairly new to ActionScript
HTML Defined Vars.
Is it possible to define variables in the HTML file that the Flash movie is embedded in, that the Flash movie can read? I have an ASP script that generates an HTML file and some variables. I need the flash movie that is embedded in the HTML file be able to read the variables. Thanks.
User Defined Text
Can anyone point me in the direction of a tutorial on how to : I want the user to be able to enter text into an entry box and then define colour and apply it to the design the have coloured.
User Defined Text
Can anyone point me in the direction of a tutorial on how to : I want the user to be able to enter text into an entry box and then define colour and apply it to the design they have coloured.
|