This Code Is Right, BUT Doesn't Work
I know this code works, since I used it in another movie. But this time it keeps returning 'undefined' everytime you press the buttons, thus not displaying the images as required.
Code:
stop();
//
displayImage = function () {
trace(this._parent.target);
_parent.loader.loadMovie('resources/gallery/'+this._parent.target+'.jpg');
};
//
galleryXML = new XML();
galleryXML.ignoreWhite = true;
galleryXML.onLoad = function(OK) {
if (OK) {
//
xmlData = galleryXML.firstChild.childNodes;
for (i=0; i<xmlData.length; i++) {
xmlTemplate = loader.attachMovie('template', 'id'+i, i);
xmlTemplate._x = i*xmlTemplate._width;
//
xmlTemplate.imageHolder.loader.loadMovie('resources/gallery/'+xmlData[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild+'_thumb.jpg');
xmlTemplate._global.maxPos = i;
//
xmlTemplate.target = xmlData[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild;
xmlTemplate.imageHolder.button.onRelease = displayImage;
}
} else {
trace('ERROR');
}
};
galleryXML.load('content/gallery.xml');
I tried everything, took me hours of tweaking, changing names, _parents, tracing but I still don't see a problem, what could be wrong?
KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 02-28-2008, 07:52 PM
View Complete Forum Thread with Replies
Sponsored Links:
Why Doesn't This Code Work?
Here's what I have. This is for a standalone Flash projector
//on frame 1
frame = ["page1", " page2" ,"page3", " page4"];
//on frame 2
loadVariablesNum (whatever + ".txt", 0);
//on frame 3
if (frame=="page1") {
gotoAndPlay (5);
}
if (frame=="page2") {
gotoAndPlay (6);
}if (frame=="page3") {
gotoAndPlay (7);
}
if (frame=="page4") {
gotoAndPlay (8);
}
//on frames 5, 6, 7, 8 respectively I have:
frame="page1";
stop ();
frame="page2";
stop ();
frame="page3";
stop ();
frame="page4";
stop ();
I have a button that has on it:
on (release) {
fscommand ("save", "whatever.txt");
{
The .txt file is being saved. What I want to happen is after the .txt file is saved and the variable set, the next time you open the projector file, it will start at "page1" or whatever page the variable was set at. But of course, this ain't working. Is there something wrong with how I've set this up?
View Replies !
View Related
Code Doesn't Work
My code doesn't work. I have two frames this script is put in frame one while frame two has a gotoAndPlay(1).
myclip has an instant name star.
code:
------------------------------------------------------------------------
xStage = 640;
yStage = 480;
stargroup=new Array()
for (i = 0; i < 50; i++) {
duplicateMovieClip("star","star"+i,i);
stargroup = eval("star" + i);
stargroup._x = Math.floor((Math.random() * xStage);
stargroup._y = Math.floor((Math.random() * yStage);
}
View Replies !
View Related
Why Doesn't This Code Work
Code:
for (i=0; i<numOptions-1; i++) {
duplicateMovieClip("_level0.newmenu.buttonMC", "subMenu"+i, i);
menuna = sub[i].attributes.title;
set("_level0.newmenu.subMenu"+i+".menuname", menuna);
subMenu[i].onRollOver = function() {
_level0.isay = sub[i].attributes.over;
setProperty("_level0.imcbaloon", _visible, true);
};
_level0.newmenu[subMenu[i]].onRollOut = function() {
_level0.isay = "";
setProperty("_level0.imcbaloon", _visible, false);
};
_level0.newmenu[subMenu[i]].onPress = function() {
actionscript(sub[i].attributes.click);
};
setProperty("_level0.newmenu.subMenu"+i, _y, optiony);
setProperty("_level0.newmenu.subMenu"+i, _x, optionx);
optiony = optiony+18;
}
everything except for the on functions work.
View Replies !
View Related
Code That Should Work, But Doesn't
I'm trying to create a line of dots that will 'ripple' as it is created. The dots are small (3x3 px). For some reason, the first handful stop at different (sequential) frames of the animation, then the rest are fine. Using a for loop to create them all at once works fine; none of them get stuck. Here's the code for the master MC containing the dot:
onClipEvent (load) {
dot._x=0;
dot._y=-171;
n=2;
}
onClipEvent (enterFrame) {
if (n<=92) {
dot.duplicateMovieClip("dot" + n,n);
this["dot" + n]._y=-171;
if (n%2==0) {
this["dot" + n]._x=n/2*6;
} else {
this["dot" + n]._x=-Math.floor(n/2)*6;
}
n++;
}
}
And the code on the dot itself:
onClipEvent (load) {
acc=4;
decay=1.3;
xfin=_xscale;
_xscale=250;
_yscale=250;
}
onClipEvent (enterFrame) {
x=_xscale;
dx = (dx+(xfin-x)/acc)/decay;
x+=dx;
_xscale=x;
_yscale=x;
}
Any ideas?
B
View Replies !
View Related
Why Doesn't This Code Work In MX?
I just started using MX, and This code from an old flash 5 script is not working. Can someone tell me why?
In flash 5 it creates a new bullet by attaching Sbullet from the library with a random size, and rotation, then waits a random amount of frames before it creates another bullet.
In Flash 7 it does nothing.
I am guessing that I have used some code that is no longer supported.
Thanks, Rubbersharkman
function newbullet1F() {
bulletcount += 1;
if (bulletcount>5) {
bulletcount = 1;
}
if (bulletwait>1) {
p1.gun._visible=1;
this.removeMovieClip("bullet"+bulletcount);
this.attachMovie("Sbullet", "bullet"+bulletcount, bulletcount+2000);
gunheatupF(1);
this["bullet"+bulletcount]._xscale = 100+random(100);
this["bullet"+bulletcount]._x = p1._x+45;
this["bullet"+bulletcount]._y = p1._y+p1.gun._y+(p1._rotation*.75);
this["bullet"+bulletcount]._rotation = (p1._rotation+random(5)-2);
bulletwait = random(3);
if (_root.bar1.gunheat._width>100) {
bulletwait -= 5 + random(5);
}
} else {
bulletwait += 1;
if (bulletwait<0) {
p1.sound.gun1.stop();
p1.gun._visible=0;
}
}
}
View Replies !
View Related
Why Doesn't This Code Work?
Why doesn't this code work in Flash?
I copy and paste it from a script generator into my flash MX expert mode actionscript box and I get all sorts of errors. It works where at the script generator but not in flash???
on (release){
getURL
("javascript:NewWindow=window.open("http://www.backyardadventures.com/search.phpse=ny','locator','width=510,height=480,l eft=500,top=200,toolbar=No,location=No,scrollbars= Yes,status=No,resizable=No,fullscreen=No');NewWind ow.focus(); void(0);");
}
View Replies !
View Related
Code Just Doesn't Work
I really don't know what's wrong with this code. But appearently the onLoad isn't triggered!!
The movies are created correctly though. because the trace gives the desired result...
Really annoying this one! Can anybody help?
Thanks
ActionScript Code:
for (var i=0; i<smallPics.length; i++)
{
_root.thumbs_mc.attachMovie("thumbs", "tn"+i, depthCount);
depthCount++;
var tn = _root.thumbs_mc["tn"+i];
trace (tn);
tn.loadMovie(smallPics[i]);
tn.onLoad = addLoaded;
}
function addLoaded():Void
{
thumbsLoaded++;
debug_txt.text = thumbsLoaded;
if (thumbsLoaded == smallPics.length) positionThumbs;
}
View Replies !
View Related
My Code Doesn't Work :/
For some reason this doesn't work. I know it's a lot of code to look through, but Ive spent all day trying to make it work and I've had no success
It should cycle through this for every tile that needs to be displayed and then move drawmapx and drawmapy to the next tile. (it gets an interval of 1 millisecond)
I'm trying to make it so it doesn't load the image every time. It has to save the strings of the images with a MC containing the loaded image beside them in an array like this:
imagesLoadedSoFar[0][x] contains the string
imagesLoadedSoFar[1][x] contains the MC with the loaded image
This is my exact code:
ActionScript Code:
var drawmapx:Number=-1;//(because the first line displays only 1 tile for some reason)
var drawmapxmax:Number=0;
var drawmapy:Number=0;
var drawmapymax:Number=0;
var drawMapIntervalID:Number;
var pausex:Boolean=false;
//var buff_mc:MovieClip;
var lastImg:String="";
var aaa:Array=new Array();
var bbb:Array=new Array();
var imagesLoadedSoFar:Array=new Array(aaa,bbb);
// imagesLoadedSoFar[0][x] - str of filename imagesLoadedSoFar[1][x] - MC
function drawmap1(){
trace("loading:::: "+currentMap[drawmapx][drawmapy].image_str);
n=0;
yep=0;
while(n<imagesLoadedSoFar[0].length){
if (imagesLoadedSoFar[0][n]==currentMap[drawmapx][drawmapy].image_str){
trace("activated on "+n);
duplicateMovieClip("imagesLoadedSoFar[1][n]", "mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy), mapHolder_mc.getNextHighestDepth());
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._x",drawmapy*50);
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._y",drawmapx*50);
yep=1;
n=imagesLoadedSoFar[0].length;
trace("IF1!!!");
}
n++;
trace("while"+n);
}
if (yep!=1){
createEmptyMovieClip("buff_mc",mapHolder_mc.getNextHighestDepth())
loadMovie(currentMap[drawmapx][drawmapy].image_str,buff_mc);
imagesLoadedSoFar[1].push(buff_mc);
imagesLoadedSoFar[0].push(currentMap[drawmapx][drawmapy].image_str);
buff_mc._x=100;
duplicateMovieClip("buff_mc", "mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy), mapHolder_mc.getNextHighestDepth());
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._x",drawmapy*50);
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._y",drawmapx*50);
yep=0;
trace(buff_mc);
trace(eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)));
trace("IF2!!!");
buff_mc.removeMovieClip();
}
trace("-0-"+imagesLoadedSoFar[0].length+"-1-"+imagesLoadedSoFar[1].length);
trace(imagesLoadedSoFar.join(",|"));
//working, but much slower (on complicated maps) code:
/*if(currentMap[drawmapx][drawmapy].image_str!=lastImg)
{
mapHolder_mc.createEmptyMovieClip("t_"+String(drawmapx)+"_"+String(drawmapy),mapHolder_mc.getNextHighestDepth());
loadMovie(currentMap[drawmapx][drawmapy].image_str,eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)));
trace(eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)));
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._x",drawmapy*50);
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._y",drawmapx*50);
lastImg=currentMap[drawmapx][drawmapy].image_str;
buff_mc=eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy));
}
else{
duplicateMovieClip(buff_mc, "mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy), mapHolder_mc.getNextHighestDepth());
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._x",drawmapy*50);
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._y",drawmapx*50);
}*/
if (drawmapx==drawmapxmax&&pausex==false){
drawmapxmax++;
drawmapy=0;
pausex=true;
}
else if (drawmapy==drawmapymax){
drawmapymax++;
drawmapx=-1;
pausex=false;
}
if (drawmapx<drawmapxmax){
drawmapx++;}
else if (drawmapy<drawmapymax){
drawmapy++;}
//ignore this - it was written for the old inefficient code
if (drawmapx==50 && drawmapy==50) {
mapHolder_mc.createEmptyMovieClip("t_"+String(drawmapx)+"_"+String(drawmapy),mapHolder_mc.getNextHighestDepth());
loadMovie(currentMap[drawmapx][drawmapy].image_str,eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)));
trace(eval("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)));
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._x",drawmapy*50);
set("mapHolder_mc.t_"+String(drawmapx)+"_"+String(drawmapy)+"._y",drawmapx*50);
clearInterval(drawMapIntervalID);
}
}
View Replies !
View Related
Why Doesn't This Code Work?
ActionScript Code:
on (release) { this.onEnterFrame = function() { current = 7; if (current<12) { gotoAndPlay(current); current += 1; } else { delete this.onEnterFrame; gotoAndPlay(1); } };}
This script is put on a button on the 7th frame, is supposed to play the movie till the frame 12 and then go and play the movie from frame 1. Or is it? It's not working... Any help?
View Replies !
View Related
Code Doesn't Work As It Should .... Help
I'm trying to make a scroller for a photo gallery and the problem is that the code below should work properly but it doesn't!!!
when I "release" the mouse button after pressing over a thumbnail, instead of giving me it's specific "i" it gives me "i" max +1 (in this case 37)... no matter on what thumbnail i press.
Does anyone have an explanation for this?
//////////////////////////////////////////////////////////////////////////////
var thumbWidth:Number=30;
var thumbInterspace:Number=10;
var myPics:Array=Array(36);
//filmStrip is an empty movieClip on stage
for (var i:Number = 1; i<=myPics.length; i++) {
filmStrip.attachMovie("pic"+i, "thumb"+i, filmStrip.getNextHighestDepth());
filmStrip["thumb"+i]._x = (i-1)*(thumbWidth+thumbInterspace);
filmStrip["thumb"+i]._y = 10;
filmStrip["thumb"+i].onRelease=function() {
//code here
trace(i);
}
}
View Replies !
View Related
Why Doesn't This Bit Of Code Work?
As the header said, why doesn't this work?
I want to use it as a login screen in flash to my ftp.
//This goes in frame actions
function Login(user, pass, servers) {
var cusername = user:String;
var cpassword = pass:String;
var cserver = servers:String;
if (cusername == undefined) {
status = "Please enter your username";
} else {
if (cpassword == undefined) {
status = "Please enter your password";
} else {
if (cserver == undefined) {
status = "Please enter the server";
} else {
address = "ftp://"+cusername+":"+cpassword+"@"+cserver;
getURL = (address, _blank);
username = "";
password = "";
}
}
}
}
for the connect button:
on (Release) {
_root.login(username, password, server);
}
View Replies !
View Related
Why Doesn't This Code Work?
ActionScript Code:
on (release) { this.onEnterFrame = function() { current = 7; if (current<12) { gotoAndPlay(current); current += 1; } else { delete this.onEnterFrame; gotoAndPlay(1); } };}
This script is put on a button on the 7th frame, is supposed to play the movie till the frame 12 and then go and play the movie from frame 1. Or is it? It's not working... Any help?
View Replies !
View Related
[AS]same Code But One Doesn't Work
this one doesn't work
ActionScript Code:
init();
function init(){
spring = 0.4;
friction = 0.95;
vx = 0;
vy = 0;
targetX = _xmouse;
targetY = _ymouse;
}
function onEnterFrame(){
ax = (targetX - ball._x)*spring; //different line here
ay = (targetY - ball._y)*spring; //different line here
vx += ax;
vy += ay;
vx *= friction;
vy *= friction;
ball._x += vx;
ball._y += vy;
}
this one works....
ActionScript Code:
init();
function init(){
spring = 0.4;
friction = 0.95;
vx = 0;
vy = 0;
}
function onEnterFrame(){
ax = (_xmouse - ball._x)*spring; //different line here
ay = (_ymouse - ball._y)*spring; //different line here
vx += ax;
vy += ay;
vx *= friction;
vy *= friction;
ball._x += vx;
ball._y += vy;
}
WHY?! it's the same except I use _xmouse and _ymouse directly in the formula, but the first one I defined it at the beginning....
View Replies !
View Related
Why Doesn't This Preload Code Work?
I want to preload only 50% of the totalframes but I want the preload bar to go all the way to 100% so the user thinks everything downloaded.
Here's my code...and the loader bar stretches all the way to 200% and then doesn't even start the movie.
Code:
framesloaded = _framesloaded;
totalframes = _totalframes/2;
percentloaded = Math.floor(framesloaded/totalframes)*100;
pload = percentloaded+"% completed";
loadbar._width = percentloaded*wscale;
if (percentloaded == 100) {
gotoAndPlay("Scene 1", 1);
}
Any ideas??
View Replies !
View Related
Can You Help? Why Doesn't This Work In NN6.2 (very, Very, Small Code)
Hello,
Works fine in IE6+. All I want to do is make it work in NN6.2 (I have the Flash plugin installed in NN). I don't care about previous browsers.
Also, I can't find what will be the behavior if the browser does not have the proper plugin installed (given the html code provided). I do not need the user to be prompted to download the plugin. Is there a way to just let it "gracefully" ignore this if I want to? I combed the Flash site and for all intents and purposes my code should work. Please help.
Thank you
http://www.business2web.com/test/clicks.zip
View Replies !
View Related
My SharedObject Code Doesn't Appear To Work.... At All
For saving
Code:
on(press) {
nso = SharedObject.getLocal("newSharedObj");
nso.data.trackURL = _root.trackURL;
nso.flush();
}
for loading
Code:
on(press) {
nso = SharedObject.getLocal("newSharedObj");
trackdisplay = nso.data.trackURL;
}
I've stripped it down to basic's in case you're wondering.
I've tested with a simple displaying of text, which should have been saved, but wasn't. It just doesn't seem to be storing the data or something.
Please, any help would be extremely ...helpful
Thanks,
-Luke
View Replies !
View Related
My Code Doesn't Work With Flash 7 And Above.
I've got some preloader code that works when I expeort in Flash 6... but doesn't work for any higher.
The code is:
PHP Code:
this.onEnterFrame = function()
{
loading = getBytesLoaded();
total = getBytesTotal();
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
myLoadMovie.loadBar._width = per * 5;
if (percent>99)
{
gotoAndStop(2);
}
}
Originally... I did want to export in Flash 6 and had been developing in using this setting... but unfortunately, becuase of some minor features missing in Flash 6 player... I need to expeort in Flash 7...
But: I can't!
What am I doing wrong?
Thanks.
OM
View Replies !
View Related
Options Code Doesn't Work
ok, i am new to actionscript, just started learning yesterday, and i was making an options box, i want to make it so when you click on a button, it switches some dynamic text from "OFF" to "ON" this is what i have so far:
Code:
on (release) {
if (btn_ops_1_set.text="ON"){
btn_ops_1_set.text="OFF";
}else{
btn_ops_1_set.text="ON";
}
}
}
when i hit the button, nothing happens.
also, how do you set a button's visibility to 0, i've tried this:
Code:
onClipEvent (load) {
this._visible=0;
btn_ops_one._visible=0;
}
and that sets the clips visibility to 0 but the button is still visible.
any help?
View Replies !
View Related
EmbedFonts Doesn't Work With My Code
I've made a little something with some XML/flash-integration using the Kirupa-tutorial here: http://www.kirupa.com/developer/mx2004/thumbnails.htm
This is what I made:
http://www.scandesigns.dk/frb/fact.html
Now I have a problem with the embedFont. But only in my scrollfield. I guess, it is because I use createTextfield but I can't figure out what the problem is. The odd thing is, that I can change the size of my text (in the scroll), but when I use embedFonts, the font is not shown. And when I change my font in my "list_fmt"-textFormat, to a library Font-symbol (with linkage), the wrong font is shown.
What I want, is to embed another font than Verdana, in my scroll-content.
This is my code. I know it's a lot, but if any of you guys, could look over it, I would be happy, happy, happy. I've spent a lot of time, trying to figure this out myself.
Code:
System.useCodepage = true;
var main_fmt:TextFormat = new TextFormat();
main_fmt.color = 0x000000;
main_fmt.font = "mainFont";
main_fmt.size = 12;
main_fmt.bold = false;
var main_bold:TextFormat = new TextFormat();
main_bold.color = 0x000000;
main_bold.font = "mainBold";
main_bold.size = 12;
main_bold.bold = true;
var list_fmt:TextFormat = new TextFormat();
list_fmt.color = 0x000000;
list_fmt.font = "verdana";
list_fmt.size = 12;
list_fmt.bold = true;
var heights:Number = 0;
function assignFormat(minTxt, format) {
minTxt.multiline = true;
minTxt.wordWrap = true;
minTxt.embedFonts = true;
minTxt.selectable = false;
minTxt.border = false;
minTxt.setTextFormat(format);
}
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
name_txt = [];
main_txt = [];
thumbnails = [];
soundtexts = [];
sounds = [];
questions = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
name_txt[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
main_txt[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
soundtexts[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
sounds[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
questions[i] = xmlNode.childNodes[i].childNodes[6].firstChild.nodeValue;
thumbnails_fn(i);
}
} else {
content = "file not loaded!";
}
}
function nextImage() {
clicked = true;
if (p<total-1) {
++p;
if (loaded == filesize) {
picture.loadMovie(image[p], 1);
var _loc2 = new mx.transitions.Tween(picture, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 1, true);
nameTxt.text = name_txt[p];
assignFormat(nameTxt, main_bold);
mainTxt.text = main_txt[p];
assignFormat(mainTxt, main_fmt);
lyd.lydTxt.text = soundtexts[p];
assignFormat(lyd.lydTxt, main_fmt);
picture_num();
if (sounds[p]) {
mySound= "mp3/"+sounds[p];
FAQlyd = new Sound(this);
FAQlyd.loadSound(mySound, true);
FAQlyd.stop();
}
lyd.onRollOver = function() {
this._alpha = 80;
};
lyd.onRollOut = function() {
this._alpha = 100;
};
lyd.onRelease = function() {
FAQlyd.start(0, 99);
};
}
}
}
function thumbnails_fn(k) {
scroller.myContent.thumbnail_mc.createEmptyMovieClip("t"+k, scroller.myContent.thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc.pictureValue = k;
target_mc.createTextField("my_txt", 10, 15, -5, 200, 100);
target_mc.my_txt.autoSize = true;
target_mc.my_txt.text = questions[k];
target_mc.my_txt.multiline = true;
target_mc.my_txt.wordWrap = true;
// target_mc.my_txt.embedFonts = true;
target_mc.my_txt.selectable = false;
target_mc.my_txt.border = false;
target_mc.my_txt.setTextFormat(list_fmt);
target_mc._y = heights;
heights = heights+target_mc._height+22;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails [k], "scroller.myContent.thumbnail_mc.t"+k);
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("online.xml");
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha = picture._alpha+10;
}
}
};
stop();
Both the "mainFont" and "mainBold" TextFormats works, with no problems.
View Replies !
View Related
What Doesn't Work With This Code? (preloading)
Hello all
I'm having trouble with this. Does anyone see a reason why this here wouldn't wait until the MC is loaded?
This is the code for one menu button
Code:
st_btn.onRelease = function(){
//four menu buttons - active goes down, others up
ss_btn.slideTo(ss_btn._x, 99, 1, "easeInOutExpo");
ps_btn.slideTo(ps_btn._x, 99, 1, "easeInOutExpo");
bt_btn.slideTo(bt_btn._x, 99, 1, "easeInOutExpo");
st_btn.slideTo(st_btn._x, 135, 1, "easeInOutExpo");
//movieClipLoader is the thing I load my MCs into
movieClipLoader.slideTo((718/2)+67, 160+(430/2)+440, 1, "easeInOutExpo");
//stageLoader is the onEnterFrame thing that should check loading progress
_root.createEmptyMovieClip("stageLoader",1001);
stageLoader.onEnterFrame = function(){
if(movieClipLoader._y==160+(430/2)+440){
if(!_root.movieClipLoader.sprecherin){
movieClipLoader.attachMovie("sprecherin","sprecherin",1000);
}
_root.kbLoaded = _root.movieClipLoader.sprecherin.getBytesLoaded();
_root.kbTotal = _root.movieClipLoader.sprecherin.getBytesTotal();
if(_root.kbLoaded==_root.kbTotal){
_root.movieClipLoader.slideTo((718/2)+67, 160+(430/2), 1, "easeInOutExpo");
delete this.onEnterFrame;
}
}
}
}
When I click it should shoot down the current movieclip, wait for the next one to load and then shoot that one back up.
Hope it's clear. If it's not then please don't ignore this, just ask! I need help.
View Replies !
View Related
My Code Doesn't Work With Flash 7 And Above.
I've got some preloader code that works when I expeort in Flash 6... but doesn't work for any higher.
The code is:
PHP Code:
this.onEnterFrame = function()
{
loading = getBytesLoaded();
total = getBytesTotal();
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
myLoadMovie.loadBar._width = per * 5;
if (percent>99)
{
gotoAndStop(2);
}
}
I got this code from this website.
Originally... I did want to export in Flash 6 and had been developing in using this setting... but unfortunately, becuase of some minor features missing in Flash 6 player... I need to expeort in Flash 7...
But: I can't!
What am I doing wrong?
Thanks.
OM
View Replies !
View Related
Code Doesn't Work In 7 But Works In 6?
Hi, I just got MX 2004 and wanted to use some of the new features in 7 with my project however when I tested my movie by changing the publishing settings to version 7 instead of 6, it no longer works. Does anyone know why something works in 6 and not 7? Are there that many changes in 7? I'm still using Actionscript 1 not 2 in both cases so that wouldn't be an issue. Any help is appreciated. Thanks.
View Replies !
View Related
Tutorial Help Code Doesn't Work
I have been programming in Flash since 2003. I am currently using AS2 but am trying to learn AS3. I am going through the Help section on AS3 and doing the Example: Creating a basic application. I know that Flash Help files are chock full of syntax errors and have come over plenty over the years, but this one I can't figure out.
I won't paste the code in here because it's the exact same as in the Help section, the second half where it says "To update the Greeter.as file:" for the class file and for the fla, "To modify the application using the Flash authoring tool:"
If you follow the directions in this example and copy and paste the code as is, then compile, it results in an error code 1119 (which I looked up but that didn't help me resolve this).
Any help would be greatly appreciated!
Thanks!
View Replies !
View Related
A Simple Code Doesn't Work
Inside a movie clip (on a button), i have this:
on (release) {
if (passwordFld == "practice") {
_root.gotoAndStop("level1", 1);
}
}
and it doesn't want to move to that frame. If i put trace or mouse hide or anything else, it works. It just won't move to the chosen frame!! Why?! (scene name is ok!)
View Replies !
View Related
Code Inspector : Can You Please Tell Me Why This Doesn't Work?
Here's the code :
Code:
//1. This is for navigation
myXml = new XML();
myXml.ignoreWhite = true;
myXml.onLoad = function(success) {
if (success) {
buildingNav();
//trace("XML loaded");
} else {
trace("XML not loaded");
}
};
myXml.load("01_about.xml");
function buildingNav(){
buttArray = myXml.firstChild.childNodes;
for (var i = 0; i<buttArray.length; i++) {
var n = navigation.attachMovie("btnMC", "btnMC"+i, i);
rangeButton = buttArray[i];
n._y = Math.round(0 + ((n._height+2)*i));
n._x = 0;
n.name = rangeButton.attributes.name;
n.label_txt.text = n.name;
but = this[topNavArray[i]];
but.i = i;
n.onRollOver = function() {
var myColor = new Color(this.bg);
myColor.setRGB(0xECEAE8);
};
n.onRollOut = function() {
var myColor = new Color(this.bg);
myColor.setRGB(0xFFFFFF);
};
n.onRelease = function() {
setButtons(this.i);
};
}
}
function setButtons(b) {
buttArray = myXml.firstChild.childNodes;
for (var j = 0; j<buttArray.length; j++) {
bt = this[buttArray[j]];
if (j != b) {
bt.enabled = true;
var myColor = new Color(bt.bg);
myColor.setRGB(0xFFFFFF);
} else {
bt.enabled = false;
var myColor = new Color(bt.bg);
myColor.setRGB(0xECEAE8);
//myColor.setRGB(0xFFFFFF);
}
}
}
buildingNav();
Why the following does not work?
Code:
n.onRelease = function() {
setButtons(this.i);
};
Thanks a lot for your help
View Replies !
View Related
Um, My Lame Code Doesn't Work
What else is new?
Code:
//first make an array that stores 8 frames (a square rotating 90 degrees. I put each frame //on the stage just to show that by some miracle I got that part to work)
var currentRotation = 0
var frames = new Array()
var frameNum = 0
for (var i=0; i<8; i++){
var sq = new Sprite()
sq.graphics.beginFill(0x000000)
sq.graphics.drawRect(0,0,16,16)
sq.rotation += currentRotation
currentRotation += (90/8)
frames[i] = sq
stage.addChild(frames[i])
frames[i].x = i*50
}
//now I want to repeatedly loop through these 8 frames in 1 spot on the stage (ie. //animate the frames continuously). Doesn't work though.
stage.addEventListener(Event.ENTER_FRAME, playIt)
var container = new Sprite()
stage.addChild(container)
function playIt(e){
container.graphics.clear
container.addChild(frames[frameNum])
frameNum+=1
if (frameNum == 8){
frameNum = 0
}
}
View Replies !
View Related
A Simple Code Doesn't Work
Inside a movie clip (on a button), i have this:
on (release) {
if (passwordFld == "practice") {
_root.gotoAndStop("level1", 1);
}
}
and it doesn't want to move to that frame. If i put trace or mouse hide or anything else, it works. It just won't move to the chosen frame!! Why?! (scene name is ok!)
View Replies !
View Related
Preload Code Doesn't Work Why?
I am using thise code to load 15 images but its not working. Maybe someone can spot whats wrong. Here is the code in action: http://s91931107.onlinehome.us/preloader/
The orange light turns on too fast to have preloaded all 15 images and when i go directly to the path of the image it still has to load (so the preload didnt work). The fifteenth image is the only one that appears instantly when i link directly to it...
http://s91931107.onlinehome.us/prelo...ingsintro4.jpg
http://s91931107.onlinehome.us/prelo...ngsintro15.jpg
I put on a trace on the getbytestotal for emptyMC and it said 0, so that may be the problem
Anyway, here ya go:
this.onLoad = function() {
for (i=1; i<16; i++) {
allimages.createEmptyMovieClip("holder"+i, 1+i);
emptyMC = "holder"+i;
section = "weddingsintro";
image = section+i+".jpg";
allimages.loadMovie(image, emptyMC);
allimages._alpha = 0;
trace (i + "loaded");
allimages[emptyMC].onEnterFrame = function() {
if (this.getBytesLoaded() == this.getBytesTotal()) {
this.loaded = true;
}
}
}
}
this.onEnterFrame = function() {
var completed = 0;
for (i=0; i<16; i++) {
if (allimages["holder" + i].loaded == true) {
completed++;
trace (i + "completed");
}
}
if (completed == 15) {
DONE.play();
}
}
View Replies !
View Related
Macs And Flash.. On Some Of Them This Code Doesn't Work... Help...
Hey
I'm trying to make a scrollabale menu. I'm quite a beginner, so I found this code and it works well on PCs, but a lot of imacs can't deal with it... it wouldn't scroll.
Those computers have flash 5 installed, but wouldn't play some flash 5 syntaxes (even dots) so if somebody can help me convert this to 4 syntax, I'll virtually kiss his/hers toes...
if (_ymouse<60) {
textSpeed = (_xmouse-center)/14;
textPos = Math.round (textPos-textSpeed);
if (textPos<upStop) {
textPos = upStop;
}
if (textPos>downStop) {
textPos = downStop;
}
nav._x = textPos;
}
Thnks!!!!
View Replies !
View Related
_root Code Doesn't Work In Scene 2
I have a preloader that has a progress bar using the following code....
loadedBytes = _root.getBytesLoaded();
totalBytes = _root.getBytesTotal();
if (loadedBytes < totalBytes){
percentageOutput = int((loadedBytes / totalBytes) * 100);
_root.progressBar._xscale = percentageOutput;
gotoAndPlay("preloading_loop");
}
else{
gotoAndPlay("start_movie");
}
This code works great on Scene 1 (the maintimeline), which is what _root refers to...
My question is this, how do I alter this code to make it work in a Scene 2 movie (in the same FLA).
I want to be able to work in ONE FLA file and export separate scenes as swf's that will be loaded into the main timeline (swf). For each of these, I want a progress bar preloader using the above code. It seems the only way I can achieve this is to have separate FLA's for each swf, which I want to avoid if I can. How do I target the Scene 2 stuff (and additional scenes). I can't use _root, I've tried, which means to me that it's exclusive to the maintimeline (Scene 1) in ANY fla file.
Thanks for any help!
View Replies !
View Related
Ext. Movie Loaded, But Code Doesn't Work
I have this movie ,www.kreativdesigns.com/soccer it loads the player roster movie dynamically, and the player roster movie loads the bios dynamically. if you click on this one www.kreativdesigns.com/soccer/player.swf you'll notice that you can scroll, and click on the first player (jimmy ivacic) and it loads his 'bio' fine. But on the original page www.kreativdesigns.com/soccer i am not able to scroll, and it loads the movie into the wrong place.
View Replies !
View Related
The Loop Code I Wrote Doesn't Seem To Work
I am trying to right a loop, but it doesn't seem to be working. Can anyone help?
What I want the loop to do is loop 16 times producing 16 lines of code that look like this.
cat1questions.data.question1 = question1.text = "Add Question In Admin";
cat2questions.data.question1 = question2.text = "Add Question In Admin";
cat3questions.data.question1 = question3.text = "Add Question In Admin";
cat4questions.data.question1 = question4.text = "Add Question In Admin";. . . and so on n so on
Here is the loop code I created. When I do a trace the loop works fine, but I haven't got the proper syntax to produce the lines of code that I need.
function onResetQuestions() {
var textStr = "";
var questStr = "";
var i = 0;
while (++i <= 16) {
textStr = "cat" + i + "questions.data.question1" + questStr;
questStr = "question" + i + ".text";
textStr = questStr = "Add Question In Admin";
test.text = textStr = questStr = "Add Question In Admin";
}
Thanks for any help!
View Replies !
View Related
[F8] Sorting Variables, Why Doesn't This Code Work?
Okay, It may seem like a post a lot of questions but I answer twice as many.
I've run into the simplest problem. I'm storing a high score list with cookies from flash. I don't want to, but I have to do it this way. I know the list will only be on the one computer. I have no problem saving and loading, I do have problem sorting the variables into the proper descending order. Here's my code:
Code:
on (release) {
sort = new Array();
for (i=0; i<=10; i++) {
sort[i] = _root["SCORE"+i];
}
do {
sorted = true;
for (i=0; i<=10; i++) {
if (sort[i]>sort[i+1]) {
temp = sort[i];
sort[i] = sort[i+1];
sort[i+1] = temp;
sorted = false;
}
}
} while (sorted == false);
var my_so:SharedObject = SharedObject.getLocal("highScore");
for (i=0; i<=9; i++) {
my_so.data["SCORE"+i] = _root["SCORE"+i];
trace(my_so.data["SCORE"+i]);
}
if (_root.die=0) {
gotoAndPlay("END", 1);
} else if (_root.die=1) {
gotoAndPlay("END2", 1);
}
}
This sorts the variables, but not in order. I'm sure it's easy, I'm just overlooking it. Any help welcome.
Thanks.
Flash 8 professional, AS2
View Replies !
View Related
Button Code Being A Pain In The A...why Doesn't This Work...?
Code:
var gallery="galleryone";
var button="tabone";
buttons.tabtwo.buttontwo.onRelease = function() {
_root.galleries[gallery].gotoAndPlay(2);
buttons[button].gotoAndPlay(22);
buttons.tabtwo.gotoAndPlay(2);
gallery = "gallerytwo";
button = "buttontwo";
};
buttons.tabone.buttonone.onRelease = function() {
_root.galleries[gallery].gotoAndPlay(2);
buttons[button].gotoAndPlay(22);
buttons.tabone.gotoAndPlay(2);
gallery = "galleryone";
button = "buttonone";
};
Ok- so the idea is that when you click a button it plays the movies assigned to the variables gallery & button to the frames mentioned.
Then the variables are changed and then when another buttons is clicked it does the same - 'except it doesn't - it does it once then sits there ;(
I have to use variables because there's a lot more buttons..but i don't understand why it doesn't work - it seems such a simple and obvious thing to try and do - why is it so HARD???
help me...
:
View Replies !
View Related
Fscommand Exec Code Doesn't Work
Hi,
I'm running the following code:
var vipersLaunch = "launchVipers.bat";
fscommand("exec", vipersLaunch);
I've got a subdirectory called "fscommand" in the directory from which my original file executes and I've got the launchVipers.bat file located there. I've tested the .bat file and it works when I click on it directly.
I am using mdm (ugh!) to compile my swf into an exe file so I'm executing the fscommand from within an exe file. Does this make a difference? I've been reading on forums and it seems like everyone has the same syntax as me and their code works...whereas mine does not. Could it be mdm that's screwing it up? Any thoughts?
UPDATE:
I found the following info in ZINC v2.5 help docs, maybe this explains the behavior because I have the launch exe code in a "if" condition.
FSCommands have certain rules and procedures which must be followed for correct usage with Macromedia Actionscript. These requirements and limitations are listed below:
· FSCommand Execution Order
The SWF Format is engineered to execute all native actionscript first, and then execute FSCommands. Even if your FSCommands are placed at the top of your code, they will still be executed last.
· FSCommands in Loops
FSCommands will not work in standard actionscript loops such as IF, FOR and WHILE. This is due to the point mentioned above. Instead of Loop statements, you must use either Frame-by-Frame looping methods, or the SetInterval Statement.
· FSCommands and Variables
By default, FSCommands will ALWAYS return and read values (variables) to the _root of your SWF movie, even if the FSCommand is executed within a Movie Clip. You must be sure to target variables correctly.
Any help is greatly appreciated...
thanks!!
Jason
View Replies !
View Related
FormattedText Sample Code Doesn't Work.
Hi -
In the supplied sample files with flash 8 (Samples & Tutorials/Samples/Actionscript/Loadtext) there's a sample called "formattedText.fla". It's exactly what I need... but it doesn't work more than once. After one test of the file, without changing anything, when I test again I get the unformatted text.
To get it to work again - *get this* - I have to close the file and then open it and try again. It looks great...once.
I would really love this to work. I've attached the "factory" code. Please try it more than once.
TIA some expert input on this.
JL
Attach Code
//****************************************************************************
//Copyright (C) 2005 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//****************************************************************************
//Handle the UIScrollBar - instance in library
this.createClassObject(mx.controls.UIScrollBar, "my_sb", 20);
// Set the target text field for the scroll bar.
my_sb.setScrollTarget(my_txt);
// Size it to match the text field.
my_sb.setSize(16, my_txt._height);
// Move it next to the text field.
my_sb.move(my_txt._x + my_txt._width, my_txt._y);
//Note: Download the TXT and CSS files to look at their structure. Use the URLs below.
//load text
function loadMyText(evt) {
var loadit_lv:LoadVars = new LoadVars();
loadit_lv.load("http://www.helpexamples.com/flash/text/sampletext.txt");
loadit_lv.onLoad = function(success:Boolean) {
if (success) {
my_txt.text = this.content;
} else {
trace("Could not load text file.");
}
};
}
loadMyText();
//apply stylesheet
var flash_css = new TextField.StyleSheet();
flash_css.load("http://www.helpexamples.com/flash/text/styles.css");
flash_css.onLoad = function(success:Boolean) {
if (success) {
my_txt.styleSheet = flash_css;
} else {
trace("Could not load CSS file.");
}
};
View Replies !
View Related
Att: Geniuses .. Please Help Me Figure Out Why This Code Doesn't Work
this code is on a frame inside an MC i have and it performs the loadMovie fine as well as the preloader but when i try to apply an onPress function to the container clip with the loaded movie (jpg) in it ..... it doesn't work. the lil hand doesn't come up and the actions in the onPress script are not performed
any assistance is greatly appreciated
thanks
PHP Code:
this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 1001);
with (container) {
loadMovie(_root.picture);
_x = 225;
_y = -46;
_xscale = 25;
_yscale = 25;
_visible = false;
}
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent*100)+"%";
loadBar._width = getPercent*160.5;
if (l>0 && l>=t) {
container._visible = 1;
delete loadText;
loadBar._visible = 0;
delete this.onEnterFrame;
}
}
MovieClip.prototype.scale = function(finX, finY) {
this.speed = 5;
this.endX = finX;
this.endY = finY;
this.onEnterFrame = function() {
this._xscale += (this.endX-this._xscale)/this.speed;
this._yscale += (this.endY-this._yscale)/this.speed;
}
}
container.onPress = function() {
if (_root.picsize == 0) {
scale(25, 25);
_root.picsize = 1;
} else if (_root.picsize == 1) {
scale(100, 100);
_root.picsize = 0;
}
}
View Replies !
View Related
Old Color Change Code Doesn't Work In 7, 8
in older versions of flash, to change colors i used:
Code:
onClipEvent (load) {
colorObj = new Color(_root.player);
}
onClipEvent (enterFrame) {
colorOBJ.setTransform({ra:100, rb:(_root.colrb), ga:100, gb:(_root.colgb), ba:100, bb:(_root.colbb)});
}
where _root.colrb are variables that change.
it seems in flash 7 and 8 this doesnt work for some reason. I've noticed that some things such as hitTest, are case sensitive in 7 and 8, but not in 5, where i often wrote it just as hittest. is there something im missing here in terms of case? or do i just have to write the code completely different in 7, 8.
View Replies !
View Related
My Code For Reusable Preloader Doesn't Work
Hey plp!!
guys i need a little help here,im trying to create an advert box that loads different files from urls contained in an external xml src.
The code for the XML loading works well, but the rest of the code does not seem to work.
what im trying to archieve is:
1. get the list of urls from the XML file
2. trigger the loading of these files as soon as the xml file is loaded
3. loop among these files (5 in total), in a given period of time,
4. Each time they are loaded ,the loading bar should show the progress
here is my code (sorry its not organised ) :
Code:
_root.start_load_advert = function() {
load_advert_int = setInterval(load_advert, 10000);
};
load_advert = function () {
if (current_advert == undefined || current_advert == 6) {
current_advert = 1;
}
mcLoader.loadClip(_root["advert"+current_advert].url,container);
current_advert++;
};
function loadXML(loaded) {
if (loaded) {
i = 0;
while (i<=5) {
new_name = "advert"+(i+1);
_root[new_name] = new Array();
_root[new_name].url = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_root[new_name].link = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
i++;
}
load_advert();
} else {
trace("file not loaded!");
; ;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://agmitre.vze.com/laconic/adver..._advert_db.xml");
var container:MovieClip = this.createEmptyMovieClip("container", _root.getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
B = bytesLoaded;
A = bytesTotal;
percentage = (B/A)*100;
loader._width = (percentage/100)*580;
clearInterval(load_advert_int);
trace(percentage);
};
listener.onLoadInit = function(target:MovieClip):Void {
mc_width = container._width;
mc_height = container._height;
container._x = (590-mc_width)/2;
container._y = (590-mc_height)/2;
removeMovieClip(sub_container);
container.duplicateMovieClip("sub_container",_root.getNextHighestDepth());
_root.start_load_advert();
};
mcLoader.addListener(listener);
loader._x = 5;
loader._alpha = 10;
stop();
NB:The code for the progress bar works when loading a single file using
mcLoader.loadClip("URL",container);
THX ALOT
AG
View Replies !
View Related
Random Code Doesn't Work In Firefox, But Ok In IE?
I have this code so my file randomly starts at frame 2 or 3.
In IE everthing's fine, but in Firefox I just get a blank browser.
Just the same in Netscape.
Code:
function randRange(min, max){
var randomNum= Math.round(Math.random()*(max-min))+min;
return randomNum; }
{
var say; say = randRange(2,3); gotoAndStop(say);
}
Can somebody help and tell me what's wrong?
View Replies !
View Related
Why Doesn't This Code Work - Simple _global Test
Hi,
I am new here and wanted to post a simple test I did that is stumping me.
I tried several different ways of writing a variable but _global does not work.
in a new flash file I entered this on frame 1:
dataContent1 = "string";
_root.dataContent2 = "string2";
_global.dataContent3 = "string3";
trace("dataContent1 =" + dataContent1);
trace("dataContent2 =" + dataContent2);
trace("dataContent3 =" + dataContent3);
what gets traced is:
dataContent1 =string
dataContent2 =string2
dataContent3 =_level0.dataContent3
what am I doing wrong with the global variable.
View Replies !
View Related
[CS3] Simple Color Change Code Doesn't Work.
i'm using AS3....i'm trying to change the color of a movie clip after i select a color from the color picker component. when i uncomment the two added lines i get errors. am i just really bad at syntax? i have no idea. this is the ONLY code in the file....i'm close to a deadline on this and i'm at a wall. if someone could guide me i'd REALLY appreciate any help i can get.
i uploaded the flash file here just in case:
http://www.zshare.net/download/929868106ef550/
the code is as follows:
import fl.events.ColorPickerEvent;
var tempColor = "0x003366";
var aBox:MovieClip = new MovieClip();
drawBox(aBox, 0xFF0000); //draw a red box
addChild(aBox);
aCp.addEventListener(ColorPickerEvent.CHANGE,chang eHandler);
function changeHandler(event:ColorPickerEvent):void {
drawBox(aBox, event.target.selectedColor);
tempColor = aCp.selectedColor.toString();
trace("- " + aCp.selectedColor);
trace("+ ", event.target.hexValue);
//testXc = new Color(_root.testX);
//testX.setRGB("0x" + event.target.hexValue);
}
function drawBox(box:MovieClip,color:uint):void {
box.graphics.beginFill(color, 1);
box.graphics.drawRect(0,0,50,50);
box.graphics.endFill();
}
View Replies !
View Related
Simple Color Change Code Doesn't Work.
i'm using AS3....i'm trying to change the color of a movie clip after i select a color from the color picker component. when i uncomment the two added lines i get errors. am i just really bad at syntax? i have no idea. this is the ONLY code in the file....i'm close to a deadline on this and i'm at a wall. if someone could guide me i'd REALLY appreciate any help i can get.
i uploaded the flash file here just in case:
http://www.zshare.net/download/929868106ef550/
the code is as follows:
import fl.events.ColorPickerEvent;
var tempColor = "0x003366";
var aBox:MovieClip = new MovieClip();
drawBox(aBox, 0xFF0000); //draw a red box
addChild(aBox);
aCp.addEventListener(ColorPickerEvent.CHANGE,chang eHandler);
function changeHandler(event:ColorPickerEvent):void {
drawBox(aBox, event.target.selectedColor);
tempColor = aCp.selectedColor.toString();
trace("- " + aCp.selectedColor);
trace("+ ", event.target.hexValue);
//testXc = new Color(_root.testX);
//testX.setRGB("0x" + event.target.hexValue);
}
function drawBox(box:MovieClip,color:uint):void {
box.graphics.beginFill(color, 1);
box.graphics.drawRect(0,0,50,50);
box.graphics.endFill();
}
View Replies !
View Related
Cleaning Up A Flash 7 Code-doesn't Work With Flashplayer 8
Hi everyone, long time no see,
I have this old code that i can't use with flash player 8. I know it's a syntax error, but I can't figure out which one. I have two errors signaled, here is the code :
1 Pos = Number(Pos)+1;
2 if (Number(Pos)>Number(MsgLen)) {
3 gotoAndPlay(1);
4 }
5 duplicateMovieClip("LetterTemplate", "Letter" add Pos, Pos);
6 set("Letter" add Pos add "/:MyPos", Pos);
7 set("Letter" add Pos add "/Letter/:Char", substring(Message, Pos, 1));
8 setProperty("Letter" add Pos, _visible, Trus);
The error is on line 5, apparently i'm missing a ',' or a ')'.
AND i have another error :
removeMovieClip("../Letter" add MyPos);
and I'm still missing a ',' or a ')'.
Can anyone help? I'm not used yet to the new syntax...
And I bet it's pretty simple!!!
Thanks in advance...
View Replies !
View Related
Code Including 'charAt' That Doesn't Work Properly With Flash 7
I got some code here at FK that works fine with fv6, but I need it working with version 7, for my portfolio site. Enter the code:
code:
var i = 0;
var idetext = "And here I put the text I need";
this.onEnterFrame = function() {
//'ispis' is the variable I declared within dynamic text properties
ispis += idetext.charAt(i);
i++;
}
This code is supposed to typewrite the string, which it does just fine, but what happens with flash 7 (A.S. versions both 1 & 2) is that it puts out 'undefined' before writing the string out. I need to get rid of that.
I've attached my .fla file if anybody needs to check it out.
Help me out and I'll buy you a once I visit your country.
View Replies !
View Related
Trace Shows Variables Changing So Why Doesn't My Code Work?
I have this code to swap buttons. 'current' holds the current pages while 'currenttab' holds the currently selected tab (button) corresponding to that page.
The page is set to solo when first run then clicking on the button evolution should target the movie instances held by current and current tab hiding them - then the idea is that the variables are updated to reflect the changes so when another button is pressed it will 'know' what page is current and target the correct movies..
what actually happens is that even though trace is showing that the variables are changing it keeps targetting the same movie as if the variables are the same..
the variables are being set on the frame above in the same timeline but i have tried making them global on the first frame of the main timeline but no change..
and also my if..then statement doesn't work - even when trace says that the value of current is 'evolution' is still keeps acting as if it isn't.
evobutton.onRelease = function() {
//checks if the current page is the same as the button clicked //
if(current != "evolution"){
// if it's not then move and fade out current page //
this._parent[current].gotoAndPlay(2);
this._parent[current].alpha(5, 0);
// puts away the page tab and fades it //
this._parent.titletabs[currenttab].gotoAndPlay(22);
this._parent.titletabs[currenttab].alpha(5, 70);
// fades up the new movie and moves new page tab//
evolution.alpha(5, 100);
titletabs.evotab.gotoAndPlay(2);
//sets the new variables //
var current = "evolution";
var currenttab = "evotab";
// //
trace(current);
trace(currenttab);
}
};
any help very much appreciated - in my fourth day of trying to fix this..
:thumb2:
View Replies !
View Related
Code Loads Images Initially But Doesn't Work OnPress
when I load an image it calls the function Preload and then once the image is loaded it calls the function doEase for a transition. Everyhting works great if I load everything at the beginning, but I need to load the first two images and the rest once I press the corresponding button. Need some advice please.
Code:
stop();
// -------------------------
// --------Preloader--------
// -------------------------
var easing = 0.2;
targetsArray = new Array([0, 0, 0], [250, 400, 500], [0, 0, 100], [445, 250, 100], [530, 105, 0], [410, 23, 0]);
// reference to this timeline
var owner = this;
function preload(target, n) {
trace ("preloaded")
var loadedbytes = target.getBytesLoaded();
var totalbytes = target.getBytesTotal();
if (loadedbytes>10 && loadedbytes>=totalbytes) {
clearInterval(owner["preload"+n]);
//now the jpg/swf is fully loaded we can call the doEase function
owner["move"+n] = setInterval(doEase, targetsArray[n][2], target, n);
}
}
// -------------------------
// ------Button Setup-------
// -------------------------
function gotoURL(movieNum) {
getURL("javascript:flashURL("+movieNum+");");
}
//---------Buttons----------
myFunction();
function myFunction() {
for (j=1; j<=4; j++) {
owner.b[j].onPress = function() {
_root.gotoURL(j);
};
}
}
stop();
// -------------------------
// --------Build Page-------
// -------------------------
namesArray = new Array("bg", "mainCopy", "image1", "image2", "image3", "image4");
locationsArray = new Array([0, 0], [650, 400], [-625, 0], [-500, 250], [530, 105], [410, 23]);
for (var i = 0; i<namesArray.length; i++) {
//create a clip on the root using a reference
var container = owner.createEmptyMovieClip(namesArray[i]+"_mc", i);
container._x = locationsArray[i][0];
container._y = locationsArray[i][1];
// Create Mc & Shape for Buttons
owner.createEmptyMovieClip("btn", i+2);
owner.btn._alpha = 0;
owner.btn.lineStyle(1);
owner.btn.moveTo(10, 10);
owner.btn.beginFill(0x999999);
owner.btn.lineTo(10, 10);
owner.btn.lineTo(156, 10);
owner.btn.lineTo(156, 615);
owner.btn.lineTo(10, 615);
owner.btn.endFill();
// Duplicate and Place
owner.btn.duplicateMovieClip("b1", i+3);
owner.b1._alpha = 10;
owner.b1._x = 10;
owner.btn.duplicateMovieClip("b2", i+4);
owner.b2._alpha = 10;
owner.b2._x = 153;
owner.btn.duplicateMovieClip("b3", i+5);
owner.b3._alpha = 10;
owner.b3._x = 306;
owner.btn.duplicateMovieClip("b4", i+6);
owner.b4._alpha = 10;
owner.b4._x = 460;
// Add Button Functionality
owner.b1.onPress = function() {
container.loadMovie("images/"+namesArray[2]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, 10);
};
owner.b2.onPress = function() {
container.loadMovie("images/"+namesArray[3]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, 12);
};
owner.b3.onPress = function() {
container.loadMovie("images/"+namesArray[4]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, 14);
};
owner.b4.onPress = function() {
container.loadMovie("images/"+namesArray[5]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, 16);
};
// Load Assetts
if (i == 0) {
container.loadMovie("images/"+namesArray[i]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, i);
} else if (i == 1) {
container.loadMovie("images/"+namesArray[i]+".jpg");
owner["preload"+i] = setInterval(preload, 100, container, i);
}
}
// -------------------------
// ---------Easing----------
// -------------------------
function doEase(target, n) {
clearInterval(owner["move"+n]);
target.onEnterFrame = function() {
var tX = targetsArray[n][0];
var tY = targetsArray[n][1];
var dx = tX-this._x;
var dy = tY-this._y;
if (Math.abs(dx)<=2) {
this._x = targetsArray[n][0];
this._y = targetsArray[n][1];
delete this.onEnterFrame;
trace("onEnterFrame removed on: "+this);
} else {
var vx = dx*easing;
var vy = dy*easing;
this._x += vx;
this._y += vy;
}
};
}
View Replies !
View Related
|