-
Actionscript works in one frame but not the other...?
Hi all,
I'm working on this electronic sheep creator for my Masters degree (don't ask haha..) which is online at www.aegreen.co.uk/creativetech/ . The problem I'm having is that a piece of actionscript I'm using for saving the sheep as a jpg using BitmapData works in one frame with one movie clip but not in another frame..
In frame 1 I create two movie clips - mc_modifysheep and mc_dna:
Code:
on(release) {
_root.createEmptyMovieClip("mc_modifysheep", 1)
mc_modifysheep._x = 150;
mc_modifysheep._y = 70;
mc_modifysheep.attachMovie("sheep_body", "body", 1, {_x:42, _y:65});
mc_modifysheep.attachMovie("sheep_head", "head", 2, {_x:0, _y:0});
mc_modifysheep.attachMovie("sheep_legs", "legs", 3, {_x:77, _y:215});
_global.bodycolour = "default";
_global.headcolour = "default";
_global.legscolour = "default";
_root.createEmptyMovieClip("mc_dna", 2)
mc_dna._x = 0;
mc_dna._y = 0;
mc_dna.attachMovie("mc_DNA_empty", "DNA empty", 1, {_x:8, _y:360});
mc_dna.attachMovie("mc_dna_default_default_top", "top", 2, {_x:45, _y:374});
mc_dna.attachMovie("mc_dna_default_default_right", "right", 3, {_x:65, _y:400});
mc_dna.attachMovie("mc_dna_default_default_left", "left", 4, {_x:32, _y:401});
gotoandstop(2);
}
the sheep in 'mc_modifysheep' and the dna in 'mc_dna' are built up over frames 2 and 3 and then in frame 4 the user decides whether the sheep is given freedom or captivity. If freedom is chosen then the user is prompted to name their sheep and the movie clip mc_modifysheep is saved as a jpg on the server using BitmapData and PHP. If captivity is chosen then the user is prompted to name the dna and the movie clip mc_dna is meant to be saved as a jpg on the server but only a white blank jpg is produced, not what is contained in mc_dna.. I've tried all sorts but I can't figure out why it's doing this..
Here's the code I'm using, that works, to save the mc_modifysheep:
Code:
import flash.display.BitmapData;
btn_freedom.onPress = function() {
freedom();
};
function freedom() {
snap_sheep = new BitmapData(305, 290);
snap_sheep.draw(mc_modifysheep);
var pixels:Array = new Array();
var w:Number = snap_sheep.width;
var h:Number = snap_sheep.height;
var a:Number = 0;
var sn:String = txt_Freedom.text;
high = 99999;
low = 00000;
ran = Math.floor(Math.random()*(Number(high)+1-Number(low)))+Number(low);
var rn:Number = ran
var filename:String = dn+sn;
for (var a = 0; a <= w; a++) {
for (var b = 0; b <= h; b++) {
var tmp = snap_sheep.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
var freedomoutput:LoadVars = new LoadVars();
freedomoutput.img = pixels.toString();
freedomoutput.height = h;
freedomoutput.width = w;
freedomoutput.filename_sheep = filename;
freedomoutput.send("save_sheep.php", "_self", "POST");
}
stop();
and here's the near identical code apart from different variable/movieclip names I'm using to try and save (but failing) mc_dna:
Code:
import flash.display.BitmapData;
btn_capt.onPress = function() {
capt();
};
function capt() {
snap_dna = new BitmapData(305, 290);
snap_dna.draw(mc_dna);
var pixels:Array = new Array();
var w:Number = snap_dna.width;
var h:Number = snap_dna.height;
var a:Number = 0;
var dn:String = txt_Capt.text;
high = 99999;
low = 00000;
ran = Math.floor(Math.random()*(Number(high)+1-Number(low)))+Number(low);
var rn:Number = ran
var filename:String = dn+rn;
for (var a = 0; a <= w; a++) {
for (var b = 0; b <= h; b++) {
var tmp = snap_dna.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
var captoutput:LoadVars = new LoadVars();
captoutput.img = pixels.toString();
captoutput.height = h;
captoutput.width = w;
captoutput.filename_dna = filename;
captoutput.send("save_dna.php", "_self", "POST");
}
stop();
I know it's a problem with the flash and not the PHP as I've tested for that, definately in the flash. I just don't understand how the same code can capture mc_modifysheep, but not mc_dna. argh!!!
If you need to take a look at the FLA file it's up at www.aegreen.co.uk/creativetech/dohumansdream.fla
Thanks everyone!!
Last edited by iamali; 05-05-2007 at 06:10 PM.
-
Script kiddie
Could it be that you're importing BitmapData twice?
-
Originally Posted by VENGEANCE MX
Could it be that you're importing BitmapData twice?
ooh, so i should only import it on the first frame and not the second? i'll try that
-
Originally Posted by VENGEANCE MX
Could it be that you're importing BitmapData twice?
nope it hasn't worked removing one of them
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|