Works On ActionScript 1.0 But Not On ActionScript 2.0
The following code works if you have your flash file set to:Flash Player 6Action Script 1I need it to work for Flash Player 7Action Script 2What it does is that basically if i have 1 2 3 4 5and i click on the 5 it will arrange the movie clips so they will be5 1 2 3 4mc is the name for action script of the movie clip i'm usingI thinkthe function that doesn't work correctly is the move functionvar acceleration = 12;var friction = 0.7;clipArray = [];posArray = [];for (var k = 0; k<5; k++) { myclip = attachMovie("mc", "mc"+k, k); myclip._y = 100; myclip._x = 170+myclip._width*k; //myclip.myText.text = "Button "+k; clipArray.push(myclip); //countArray.push(k); posArray.push(myclip._x); myclip.onPress = dostuff;}function move() { var xdif = posArray[this.jvar]-this._x; this.xspeed += xdif/this._parent.acceleration; this.xspeed *= this._parent.friction; this._x += this.xspeed; this.checkDistance(); }checkDistance = function () { if (Math.abs(posArray[this.jvar]-this._x)<1) { this._x = posArray[this.jvar]; delete this.onEnterFrame; }};function dostuff() { for (var i = 0; i<clipArray.length; i++) { // setting indexes clipArray[i].ivar = i;; } // deleting the mc the user clicked k = clipArray.splice(this.ivar, 1); // the mc you click is on the front clipArray = k.concat(clipArray); for (var j = 0; j<posArray.length; j++) { // re setting the indexes clipArray[j].jvar = j; trace(clipArray[j]+" "+clipArray[j].jvar); // calls move clipArray[j].onEnterFrame = move; }}
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 03-22-2005, 09:59 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
- Help: This Works In Actionscript 1 But I Need It To Work In Actionscript 2
- Works In Actionscript 1.0, Not Actionscript 2.0, Help?
- Works On ActionScript 1.0 But Not On ActionScript 2.0
- Works On ActionScript 1.0 But Not On ActionScript 2.0
- Works On ActionScript 1.0 But Not On ActionScript 2.0
- Actionscript Works In 6 But Not 7
- ActionScript Only Works Once?
- Roll Over Actionscript. It Works But...
- Actionscript Which Works Something Like Tetris...
- Interactive 3d With Vr In Actionscript? Yes It Works.
- Actionscript Works In One Frame But Not The Other...?
- [F8] ActionScript Only Works In FireFox ..?
- Anybody Know How Export To Actionscript Works?
- Actionscript Works In IDE,projector But Not SWF
- Actionscript That Works On Mac, But Not On Windows?
- Works Fine In Actionscript 1 But Not 2?
- Actionscript Of Loaded Movie Does Not Works
- Identical Actionscript Works In One Frame But Not Another...?
- ActionScript (2.0) Works Locally But Not From Server... What's Up?
- Actionscript Animation Works Just In A Zone Of Stage
- Iframes And Actionscript Not Working In IE, But Works Okay In Firefox?
- CS3.....using Actionscript 2.0.....how Do I Make A Popup Window That Actually Works?
- Sound Actionscript - Works Locally Not Online - Flash Mx
- This Actionscript Geturl Javascript Works In Safari, But Not IE Or Opera :(
- Actionscript 3.0 Mouse Click Event Listener Works Only Once
- Actionscript Local Shared Object Works Fine Then Fails After 4 Minutes
- Actionscript Local Shared Object Works Fine Then Fails After 4 Minutes
- Arrggh ActionScript For Flash Mail Form Works On Local, But Not Effective On Remote?
- My ActionScript Not Working When Published Works In Flash 6 Not In Flash 8~
- Basic Moving Clip W/actionscript + Random Motion W/actionscript
- Adding Actionscript To An Empty Movie Clip Created By Actionscript
- [FCS3] Adding Actionscript To A Movieclip Through Actionscript?
- Jigsaw Puzzle - Changing From Actionscript 2.0 To Actionscript 3.0
- Giving Actionscript To An Actionscript-loaded Movie
- Warning: An ActionScript 1.0/2.0 SWF File Has Loaded An ActionScript 3.0 SWF;
- Migrate ActionScript 1.0 To ActionScript 2.0 , Part 1: The Basics
- Works In Flash 6 Actionscript 1 & 2 But Not In Flash 7 Or 8
- Actionscript - User Input Actionscript
- [F8] Flash6 Actionscript 2, Flash 8 Actionscript 2...help
- Moving A Game From Actionscript 1.0 To Actionscript 2.0...
- Convert Actionscript Flash 5 To Actionscript 2.0
- Swf Actionscript 3, Load A Actionscript 2 File.
- Flash ActionScript == Flex ActionScript?
- Urgent :Getting Actionscript To 'pause' - Actionscript 2.0
- Obtaining An ActionScript 2 Variable From ActionScript 3
- ActionScript 3.0 Is 5~7 Times Slower Then ActionScript 2.0
- URGENT How Do I Get Actionscript To Pause Actionscript 2.0
- Actionscript 3 Tutorials For Actionscript Beginners
- Actionscript 1.0 Include Files In Actionscript 2.0
Help: This Works In Actionscript 1 But I Need It To Work In Actionscript 2
I have some scrolling navigation that works when published using actionscript 1 but not actionscript 2. I need to use actionscript 2 because it supports the streaming video that I'm trying to navigate. Can someone help me rewrite my button logic to get the scroll bar to work as it did in actionscript 1? Please see my fla if necessary, but here is the area I need help with.
if (Number((getProperty("../scrollhandle", _y)))>Number((Number(../:top)+Number((../:speed/(../:height/../:scrolllength)))))) {
setProperty("../scrollhandle", _y, (getProperty("../scrollhandle", _y)-(../:speed/(../:height/../:scrolllength))));
} else {
setProperty("../scrollhandle", _y, ../:top);
}
tellTarget ("../scrollhandle") {
gotoAndPlay(3);
}
the error that I get is:
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 1: Operator '>' must be followed by an operand
if (Number((getProperty("../scrollhandle", _y)))>Number((Number(../:top)+Number((../:speed/(../:height/../:scrolllength)))))) {
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 2: Operator '-' must be followed by an operand
setProperty("../scrollhandle", _y, (getProperty("../scrollhandle", _y)-(../:speed/(../:height/../:scrolllength))));
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 4: Unexpected '.' encountered
setProperty("../scrollhandle", _y, ../:top);
Please help if you can.
Works In Actionscript 1.0, Not Actionscript 2.0, Help?
Any idea why this would work fine in Flash MX but not MX 2004 Pro? I'm new to the upgrade but I can't imagine why this doesn't work.
_root.mission.gotoAndStop("mission");
I'm publishing in Actionscript 1.0 so I don't see what the difference would be.
Thank you much!
Works On ActionScript 1.0 But Not On ActionScript 2.0
The following code works if you have your flash file set to:
Flash Player 6
Action Script 1
I need it to work for
Flash Player 7
Action Script 2
What it does is that basically if i have
1 2 3 4 5
and i click on the 5 it will arrange the movie clips so they will be
5 1 2 3 4
mc is the name for action script of the movie clip i'm using
I think
the function that doesn't work correctly is the move function
HOW CAN I FIX THIS Sad
Code:
var acceleration = 12;
var friction = 0.7;
clipArray = [];
posArray = [];
for (var k = 0; k<5; k++) {
myclip = attachMovie("mc", "mc"+k, k);
myclip._y = 100;
myclip._x = 170+myclip._width*k;
//myclip.myText.text = "Button "+k;
clipArray.push(myclip);
//countArray.push(k);
posArray.push(myclip._x);
myclip.onPress = dostuff;
}
function move() {
var xdif = posArray[this.jvar]-this._x;
this.xspeed += xdif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this._x += this.xspeed;
this.checkDistance();
}
checkDistance = function () {
if (Math.abs(posArray[this.jvar]-this._x)<1) {
this._x = posArray[this.jvar];
delete this.onEnterFrame;
}
};
function dostuff() {
for (var i = 0; i<clipArray.length; i++) {
// setting indexes
clipArray[i].ivar = i;;
}
// deleting the mc the user clicked
k = clipArray.splice(this.ivar, 1);
// the mc you click is on the front
clipArray = k.concat(clipArray);
for (var j = 0; j<posArray.length; j++) {
// re setting the indexes
clipArray[j].jvar = j;
trace(clipArray[j]+" "+clipArray[j].jvar);
// calls move
clipArray[j].onEnterFrame = move;
}
}
Works On ActionScript 1.0 But Not On ActionScript 2.0
The following code works if you have your flash file set to:
Flash Player 6
Action Script 1
I need it to work for
Flash Player 7
Action Script 2
What it does is that basically if i have
1 2 3 4 5
and i click on the 5 it will arrange the movie clips so they will be
5 1 2 3 4
mc is the name for action script of the movie clip i'm using
I think
the function that doesn't work correctly is the move function
var acceleration = 12;
var friction = 0.7;
clipArray = [];
posArray = [];
for (var k = 0; k<5; k++) {
myclip = attachMovie("mc", "mc"+k, k);
myclip._y = 100;
myclip._x = 170+myclip._width*k;
//myclip.myText.text = "Button "+k;
clipArray.push(myclip);
//countArray.push(k);
posArray.push(myclip._x);
myclip.onPress = dostuff;
}
function move() {
var xdif = posArray[this.jvar]-this._x;
this.xspeed += xdif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this._x += this.xspeed;
this.checkDistance();
}
checkDistance = function () {
if (Math.abs(posArray[this.jvar]-this._x)<1) {
this._x = posArray[this.jvar];
delete this.onEnterFrame;
}
};
function dostuff() {
for (var i = 0; i<clipArray.length; i++) {
// setting indexes
clipArray[i].ivar = i;;
}
// deleting the mc the user clicked
k = clipArray.splice(this.ivar, 1);
// the mc you click is on the front
clipArray = k.concat(clipArray);
for (var j = 0; j<posArray.length; j++) {
// re setting the indexes
clipArray[j].jvar = j;
trace(clipArray[j]+" "+clipArray[j].jvar);
// calls move
clipArray[j].onEnterFrame = move;
}
}
Works On ActionScript 1.0 But Not On ActionScript 2.0
The following code works if you have your flash file set to:
Flash Player 6
Action Script 1
I need it to work for
Flash Player 7
Action Script 2
What it does is that basically if i have
1 2 3 4 5
and i click on the 5 it will arrange the movie clips so they will be
5 1 2 3 4
mc is the name for action script of the movie clip i'm using
I think
the function that doesn't work correctly is the move function
var acceleration = 12;
var friction = 0.7;
clipArray = [];
posArray = [];
for (var k = 0; k<5; k++) {
myclip = attachMovie("mc", "mc"+k, k);
myclip._y = 100;
myclip._x = 170+myclip._width*k;
//myclip.myText.text = "Button "+k;
clipArray.push(myclip);
//countArray.push(k);
posArray.push(myclip._x);
myclip.onPress = dostuff;
}
function move() {
var xdif = posArray[this.jvar]-this._x;
this.xspeed += xdif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this._x += this.xspeed;
this.checkDistance();
}
checkDistance = function () {
if (Math.abs(posArray[this.jvar]-this._x)<1) {
this._x = posArray[this.jvar];
delete this.onEnterFrame;
}
};
function dostuff() {
for (var i = 0; i<clipArray.length; i++) {
// setting indexes
clipArray[i].ivar = i;;
}
// deleting the mc the user clicked
k = clipArray.splice(this.ivar, 1);
// the mc you click is on the front
clipArray = k.concat(clipArray);
for (var j = 0; j<posArray.length; j++) {
// re setting the indexes
clipArray[j].jvar = j;
trace(clipArray[j]+" "+clipArray[j].jvar);
// calls move
clipArray[j].onEnterFrame = move;
}
}
Actionscript Works In 6 But Not 7
Whack-a-mole type game works great when published for Flash 6 or earlier but why not Flash 7?
Source file here:
http://www.vexing.org/whack/
Written in Actionscript 1.0. Taken from Gary Rosenzweig's book "Flash 5 Actionscript for Fun and Games".
Thanks,
-P
ActionScript Only Works Once?
Hi all!
Im trying to get a dropdown meny to work with my flipbook. The thing is that it works just fine if it runs once, but after the script has been used it won´t work again.
My code:
Code:
var lo = new Object();
lo.change = function (evt_obj:Object) {
var dest_page_number = evt_obj.target.selectedItem.data;
myBook.flipGotoPage(dest_page_number);
}
combo_mc.addEventListener("change", lo);
function onInit(){
number_txt.text = pageNumber;
lo.book = myBbook;
}
Roll Over Actionscript. It Works But...
My roll over button works but only once or twice. after that its a mess. when the mouse roll over the "portfolio" button, theres a movieclip that suppose to play and when it rolls out its suppose to play another movieclip.
what is missing? i need ur help. thanx. below is the script that i use. i attach below the button and u guys can test it.
on (rollOver) {
_root.anim1.play();
}
on (rollOut) {
_root.anim2.play();
}
on (rollOut) {
_root.anim1.GotoAndPlay(1);
}
Actionscript Which Works Something Like Tetris...
I am looking for a script which works like the game tetris.
actually the requirment is to make a flash in which i can choose a container and also the item.....after which i needs to see how many items can be fitted in the container horizontally and vertically or both.
Lot of calulations needed and its just one percent of the total requirment so if i get through this i think i will manage the later 99%.
Please reply
Kapi Patel
India
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!!
[F8] ActionScript Only Works In FireFox ..?
stream = new Sound();
vol = 100;
channel = "http://84.16.251.251:10208;stream.nsv";
_root.onLoad = function() {
stream.stop();
stream.loadSound(channel, true);
setvol(vol);
}
/ This is my actionscript to stream audio from an internet radio station.
It works fine in FireFox .... but not in IE, Chrome etc ..
Please help ... newbie here!
Anybody Know How Export To Actionscript Works?
Hi,
I've got a lot of other question threads going but I keep coming up with new problems! This time I just need to know how that damn Export to Actionscript works! I've got it figured out mostly but I can't target objects within objects.
If you have a MovieClip that you choose to export for actionscript (this movieclip is NOT on the stage at runtime... it's added later) And that MovieClip has a lot of other objects inside of it. How do you target those things inside??
I've tried to trace their names by saying
PHP Code:
trace(MovieClip.getChildAt(1).name);
and they all come back with no title so I don't know which is which..
Anybody have experience with this??
Thanks!
-b
Actionscript Works In IDE,projector But Not SWF
Hello, I'm atempting to create a swf that loads in a controller swf and accesses some of the information contained within the load swf. My main timeline is pretty simple.
var preloader_mc:MovieClip = this.createEmptyMovieClip("preloader_mc", this.getNextHighestDepth());
var labelcontainer:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var label:TextField = labelcontainer.createTextField("label", 1, 0, 365, 150, 20);
var TOCcontainer:MovieClip = this.createEmptyMovieClip("TOCcontainer", this.getNextHighestDepth());
var TOClabel:TextField = TOCcontainer.createTextField("TOClabel", 1, 0, 300, 150, 20);
then I have an onenter frame function that access the variable contained within the loaded swf.
loadMovie("xml_controller.swf", preloader_mc);
onEnterFrame = function () {
vTime = this.preloader_mc.container.controlBar.timeView.label.value;
this.label.text = vTime
};
When I test the movie I see the time displayed and everything is ok. When I create a projector file I see the time display. When I try to run the swf, in a browser or straight from explorer All I see is undefined for the values.
Anybody have any ideas why this would work in two environments but not the third?
Actionscript That Works On Mac, But Not On Windows?
Hello all,
I am trying to make a rollover glint effect by using a text mask, and some basic actionscript. I got it to work wonderfully, but it does not work as expected on Windows. It will run the first time, but doesn't seem to reset and start again with subsequent mouseovers. I have tried just about everything, but I can't seem to get it. You may a have a look here....
http://mat.is-a-geek.com/flash/Prev_...rev_ver_2.html
The code I'm using is:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.gotoAndStop(1);
}
}
Any help in this matter would be greatly appreciated. Thanks.
bcode
Works Fine In Actionscript 1 But Not 2?
HI all,
ive got a pre loader that works fine when i export on actionscript 1 but not in AS2??
ive spent a week using the mx 2004 pro demo and im finding it very hard to get to grips with!!
heres all the AS for the loader
ActionScript Code:
#initclip
function LoaderClass() {
this.slideColor = new Color(this.slide);
this.bordColor = new Color(this.bord);
this.update();
}
//
LoaderClass.prototype = new MovieClip();
//
LoaderClass.prototype.update = function() {
this.slideColor.setRGB(this.scolor);
this.bordColor.setRGB(this.bcolor);
//
this.bord._width = this.SlideWidth+4;
this.slide._width = this.SlideWidth;
this.bord._height = this.SlideHeight+4;
this.slide._height = this.SlideHeight;
//
this.createTextField("mytext", 1, this.bord._x, this.bord._y, 300, 40);
delete this.mtextFormat;
this.mtextFormat = new TextFormat(this);
//
this.mTextFormat.font = this.fname;
this.mTextFormat.color = this.bcolor;
this.mTextFormat.size = this.fsize;
this.mytext.text = "";
this.mytext.setTextFormat(this.mtextFormat);
//
};
//-----------
LoaderClass.prototype.setSlideWidth = function(b) {
this.SlideWidth = b;
this.update();
};
LoaderClass.prototype.getSlideWidth = function() {
return (this.SlideWidth);
};
LoaderClass.prototype.setSlideHeight = function(h) {
this.SlideHeight = h;
this.update();
};
LoaderClass.prototype.getSlideHeight = function() {
return (this.SlideHeight);
};
LoaderClass.prototype.setTintColor = function(c) {
this.tcolor = c;
this.update();
};
LoaderClass.prototype.turnOnTint = function() {
this.applyTint = true;
this.update();
};
// Connect the class with the linkage ID for this movie clip
Object.registerClass("Loader", LoaderClass);
#endinitclip
and
ActionScript Code:
onClipEvent (load) {
_root.stop();
this.topScale = this._width;
this._xscale = 0;
ft = int(_root.getBytesTotal()/1024);
}
onClipEvent (enterFrame) {
fl = int(_root.getBytesLoaded()/1024);
this._xscale = (fl/ft)*this.topScale;
_parent.mytext.text = "LOADING "+fl+" KB OF "+ft+" KB";
_parent.mytext.setTextFormat(_parent.mtextFormat);
// _parent.llt = "LOADING "+fl+" KB OF "+ft+" KB";
if (fl == ft) {
tellTarget ("_root") {
play();
}
}
}
thanks in advance!!!
Actionscript Of Loaded Movie Does Not Works
I am loading a movie in a movie clip,, now the movie which is being loaded is a scroller , but as it is loaded in a movie clip , the actionscript of the scroller stops working,
just see this:-
scroller.swf
Now i load this scroller in a movie clip of other fla
loadMovie ("Ticker.swf", "_root.mymc";
and now when i publish it, an error is given
Target not found: Target="/scrollleft" Base="_level0.mymc"
Identical Actionscript Works In One Frame But Not Another...?
Hi all,
I'm working on this electronic sheep creator for my Masters degree (don't ask haha..) which is online at [url]www.aegreen.co.uk/creativetech/[/url] . 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);
}[/CODE]
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();[/CODE]
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();[/CODE]
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 [url]www.aegreen.co.uk/creativetech/dohumansdream.fla[/url]
Thanks everyone!!
Edited: 05/05/2007 at 04:12:12 PM by iamali84
ActionScript (2.0) Works Locally But Not From Server... What's Up?
Greetings: I have a main flash movie and am calling an external flash movie that loads a FLV file. This external SWF file simply plays back a video. All is working here fine. In this externally loaded flash movie I also have two buttons that are supposed to close the window underneath it and then unload it.
It is these two buttons that work perfectly when I test the movie locally within the Flash CS3 environment but do not work when I upload the files to the server; Here is the code on button 1:
---------------------------------------
_root.onEnterFrame = function() {
loadMovieNum("
Iframes And Actionscript Not Working In IE, But Works Okay In Firefox?
Hey everyone.
I have my buttons in my flash menu changing urls in 2 iframes. It works fine in Firefox, but only the first one loads in IE - I am clueless... anyone know what is going on?
My code -
name.onRelease = function() {getURL(furl, "right");getURL("random.php", "left");}
My only guess is that IE won't refresh the page if it thinks it already has it in its cache. Random.php loads a random image, and var furl is the page the buttons point to.
Any help is appreciated!!
Thanks,
adam
the site i am working on that has the problem- http://www.jimjcummings.com/template.html
CS3.....using Actionscript 2.0.....how Do I Make A Popup Window That Actually Works?
Iv'e been trying all types of code and am pulling my hair out......how do i go about making a javascript popup window that works in safari, as well as all the other browsers? Im getting this error when i try to use safari:
Safari doesn’t allow JavaScript to be used in this way.
I just want a simple javascript popup window thats not going to give me any type of problems...please. I have a button on my stage called StartSearch.
What code do i put in the actionscript? where do i place the actionscript? What code and where do i place the code in the html doc where the flash is embedded? Please help
Sound Actionscript - Works Locally Not Online - Flash Mx
The following code works on my local machine but not when I upload.
I have a video which I use as a background to one section of the site. I load it into an empty mc which has the code below attached.
The scaling part works fine.
The part that causes problems is the audio. I want the Audio for the background video to play if the user is NOT listening to a mp3 (its a music artist site).
If they are listening to a mp3 I want it to be a silent video.
I use the _root.MP3Active to track if a mp3 is playing
0 = not playing
1 = playing.
I guess my problem is associated with the fact that the video loads instantly on my local macjhine but not online?
any ideas how to fix this or do it differently?
thanks mark
Code:
onClipEvent(load){
_root.BGVideoSound = new Sound(this);
}
onClipEvent(data){
this._xscale = 300;
this._yscale = 300;
_root.BGVideoSound.setVolume(0);
if(_root.MP3Active == 1){
_root.BGVideoSound.setVolume(0);
}
else{
_root.BGVideoSound.setVolume(100);
}
}
This Actionscript Geturl Javascript Works In Safari, But Not IE Or Opera :(
I just have the following on a frame so that when it passes the frame it sets the css display property of a div from display="none" to "inline". It works in safari, seems to be the way to do it yet in Firefox and Internet explorer it tries to load a new window instead of sending the javascript code to the browser document.... any ideas??
Code:
getURL("javascript:document.getElementById('news0').style. display='inline'");
Actionscript 3.0 Mouse Click Event Listener Works Only Once
I'm a newbie. I'm using actionscript 3.0 and I have a separate package .as file with all my action script code. I have 2 buttons called myBtn1 and myBtn2 in my .fla file whose base class are both flash.display.SimpleButton.
The event listener for myBtn1 (buttonClickHandler) always fires correctly. But, the eventHandler for myBtn2 (textClickHandler) only fires once and only if myBtn2 is the first button to be clicked. (I realize those event handlers and switch statements look rather silly with only one item each, but I removed code.)
Why does textClickHandler only seem to work once?
Any help would be greatly appreciated!
Attach Code
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.events.Event;
public class myClass extends MovieClip {
public function myClass() {
trace("myClass constructor");
myBtn1.addEventListener(MouseEvent.CLICK,buttonClickHandler);
myBtn2.addEventListener(MouseEvent.CLICK,textClickHandler);
gotoAndStop(1);
}
public function buttonClickHandler(event:MouseEvent):void {
trace("buttonClickHandler");
switch (event.target) {
case myBtn1:
trace("myBtn1 clicked");
gotoAndStop(1);
break;
default :
trace("buttonClickHandler: unknown entry");
break;
}
}
public function textClickHandler(event:MouseEvent):void {
trace("textClickHandler");
switch (event.target) {
case myBtn2:
trace("myBtn2clicked");
gotoAndStop(2);
break;
default :
trace("textClickHandler: unknown entry");
break;
}
}
}
}
Actionscript Local Shared Object Works Fine Then Fails After 4 Minutes
This failure only occurs with one of my testers using Firefox. It does not fail on my computer using Firefox. It does not fail on anyone's computer using IE6 or IE7. I have 2 separate flash files, one with a thumbnail array and one is a fullsize image. The client insisted on 2 separate files. You may view a trimmed-down version at http://www.tonybarre.com/Flash/index.html. When you rollover a thumbnail, I write a unique code to a LSO. The fullsize file continually polls the LSO. When it finds a change, it updates the fullsize image. It initially works in my tester's Firefox browser, but after 4 minutes the rollovers no longer cause a fullsize image update. Below you will find the actionscript from the thumbnail file, followed by the actionscript from the fullsize file.
***Thumbnail***
var tcode = "asa_";
_global.allClips = new Array();
for (i=0;i<24;i++){
var mcName = "imageHolder" + i + "_mc";
this.holder1_mc.createEmptyMovieClip(mcName,i);
allClips.push(mcName);
}
_global.glowClips = new Array();
for (var i=0; i<24;i++) {
var glowName = "glowHolder" + i + "_mc";
this.holder2_mc.createEmptyMovieClip(glowName,i);
glowClips.push(glowName);
}
var num = 0;
for (var j=1;j<=3;j++) {
for (var k=1;k<=2;k++) {
for (var i=1;i<=(6 - 2 * (j-1));i++) {
num++;
if (num>99) {
thumbNum = num;
}else if (num>9) {
thumbNum = "0" + num;
}else {
thumbNum = "00" + num;
}
var thumbName = "thumbs" + "/" + tcode + thumbNum + ".jpg";
thisMovie=this.holder1_mc[allClips[num-1]];
loadMovie(thumbName,thisMovie);
thisMovie._x= (i-1) * 52 ;
thisMovie._y= 18 + ((k-1)+(2*(j-1))) * 52 ;
thisGlow=this.holder2_mc[glowClips[num-1]];
thisGlow.attachMovie("MC_glow", "glow"+i+"_mc", i);
thisGlow._x = (i-1) * (52) - 3;
thisGlow._y = 15 + ((k-1)+(2*(j-1))) * 52;
thisGlow._alpha = 0;
}
}
}
_global.linksArray = new Array();
varsObj = new LoadVars();
varsObj.onLoad = function() {
for (i=0;i<24;i++) {
linksArray=varsObj["url" + (i+1)];
}
for (var m=0;m<24;m++) {
thisLink=linksArray[m];
if (thisLink !== "") {
thisMovie=_root.holder1_mc[allClips[m]];
thisMovie.index=m;
thisMovie.onRelease = function () {
getURL(linksArray[this.index]);
}
thisMovie.onRollOver = function () {
thisGlow=_root.holder2_mc[glowClips[this.index]];
thisGlow._alpha = 85;
var imageToShow_so = SharedObject.getLocal("imageToShare", "/");
imageToShow_so.data.imageNumber = this.index;
imageToShow_so.flush();
}
thisMovie.onRollOut = function () {
thisGlow=_root.holder2_mc[glowClips[this.index]];
thisGlow._alpha = 0;
}
}
}
}
varsObj.load("links.txt");
***FullSize***
var tcode = "asa_";
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size Image";
_global.oldNum = (-1);
_global.toggle = 2;
_root.holder_mc.createEmptyMovieClip("imageHolder1",1);
_root.holder_mc.imageHolder1.createEmptyMovieClip("image",1);
_root.holder_mc.imageHolder1.image._x=0;
_root.holder_mc.imageHolder1.image._y=30;
_root.holder_mc.createEmptyMovieClip("imageHolder2",2);
_root.holder_mc.imageHolder2.createEmptyMovieClip("image",1)
function updateImage () {
var newImage_so = SharedObject.getLocal("imageToShare", "/");
var imageNum = newImage_so.data.imageNumber + 1;
if (imageNum !== oldNum) {
if (imageNum == 0) {
}else{
if (imageNum>99) {
image = imageNum;
}else if (imageNum>9) {
image = "0" + imageNum;
}else {
image = "00" + imageNum;
}
var newImage = "fullsize" + "/" + tcode + image + ".jpg";
if (toggle == 1) {
if (textArray[imageNum-1]==undefined){
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size";
}else{
descr_txt.text = textArray[imageNum-1];
}
_root.holder_mc.imageHolder1.image.loadMovie(newImage,1);
_root.holder_mc.imageHolder1.image._x=0;
_root.holder_mc.imageHolder1.image._y=30;
_root.holder_mc.imageHolder1.onEnterFrame = function () {
if (this._alpha < 100) {
this._alpha += 10;
}else {
delete this.onEnterFrame;
}
}
_root.holder_mc.imageHolder2.onEnterFrame = function () {
if (this._alpha > 0) {
this._alpha -= 15;
}else {
delete this.onEnterFrame;
}
}
toggle = 2;
} else if (toggle == 2) {
if (textArray[imageNum-1]==undefined){
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size";
}else{
descr_txt.text = textArray[imageNum-1];
}
_root.holder_mc.imageHolder2.image.loadMovie(newImage,1);
_root.holder_mc.imageHolder2.image._x=0;
_root.holder_mc.imageHolder2.image._y=30;
_root.holder_mc.imageHolder2.onEnterFrame = function () {
if (this._alpha < 100) {
this._alpha += 10;
}else {
delete this.onEnterFrame;
}
}
_root.holder_mc.imageHolder1.onEnterFrame = function () {
if (this._alpha > 0) {
this._alpha -= 15;
}else {
delete this.onEnterFrame;
}
}
toggle = 1;
}
}
oldNum = imageNum;
}
}
setInterval(updateImage,300);
Actionscript Local Shared Object Works Fine Then Fails After 4 Minutes
This failure only occurs with one of my testers using Firefox. It does not fail on my computer using Firefox. It does not fail on anyone's computer using IE6 or IE7. I have 2 separate flash files, one with a thumbnail array and one is a fullsize image. The client insisted on 2 separate files. You may view a trimmed-down version at http://www.tonybarre.com/Flash/index.html. When you rollover a thumbnail, I write a unique code to a LSO. The fullsize file continually polls the LSO. When it finds a change, it updates the fullsize image. It initially works in my tester's Firefox browser, but after 4 minutes the rollovers no longer cause a fullsize image update. Below you will find the actionscript from the thumbnail file, followed by the actionscript from the fullsize file.
***Thumbnail***
// here is the code which precedes the number in the thumb file name
// it must be specified as a parameter in the tag that calls this movie
var tcode = "asa_";
// Create an array to hold the names of all the movie clips
_global.allClips = new Array();
// Make a batch of empty movie clips; put their names in the array
for (i=0;i<24;i++){
var mcName = "imageHolder" + i + "_mc";
this.holder1_mc.createEmptyMovieClip(mcName,i);
allClips.push(mcName);
}
// Create an array to hold the names of all the glow clips
_global.glowClips = new Array();
// Create the names; put them in the array. create the clips; attach the glow later
for (var i=0; i<24;i++) {
var glowName = "glowHolder" + i + "_mc";
this.holder2_mc.createEmptyMovieClip(glowName,i);
glowClips.push(glowName);
}
// fill & position the movie clips
// i is the "column"; j is the first, 2nd, or 3rd grouping of 2 rows;
// k is the row within the grouping; num keeps track of the 24 movie clips in sequence
var num = 0;
for (var j=1;j<=3;j++) {
for (var k=1;k<=2;k++) {
for (var i=1;i<=(6 - 2 * (j-1));i++) {
// construct a string for the sequence number to match thumb names
num++;
if (num>99) {
thumbNum = num;
}else if (num>9) {
thumbNum = "0" + num;
}else {
thumbNum = "00" + num;
}
// construct the name of the thumbnail, including the path
var thumbName = "thumbs" + "/" + tcode + thumbNum + ".jpg";
// here is convenient way to refer to the movie clip on this iteration
thisMovie=this.holder1_mc[allClips[num-1]];
// put the thumbnail into the movie clip
loadMovie(thumbName,thisMovie);
// move the movie clip into place
thisMovie._x= (i-1) * 52 ;
thisMovie._y= 18 + ((k-1)+(2*(j-1))) * 52 ;
// here is a convenient way to refer to the glow clip on this iteration
thisGlow=this.holder2_mc[glowClips[num-1]];
// attach the glow to the glowClip
thisGlow.attachMovie("MC_glow", "glow"+i+"_mc", i);
// move the glow into place; set alpha to zero. glow effect will come from alpha
thisGlow._x = (i-1) * (52) - 3;
thisGlow._y = 15 + ((k-1)+(2*(j-1))) * 52;
thisGlow._alpha = 0;
}
}
}
// When you click on a thumbnail, you go to a new page.
// links.txt contains a table of links. The next block loads that table
// and assigns them to the appropriate thumbnails.
// Here is an array in which to put the links
_global.linksArray = new Array();
// First we load the links into a LoadVars object and thence into the array
varsObj = new LoadVars();
varsObj.onLoad = function() {
for (i=0;i<24;i++) {
linksArray[i]=varsObj["url" + (i+1)];
}
// assign links to movie clips
for (var m=0;m<24;m++) {
thisLink=linksArray[m];
// the external file has a placeholder for all the links
// if the placeholder is blank, there is no corresponding thumbnail and there is a
// blank rectangle instead. If we roll over this blank rectangle we want no state change
if (thisLink !== "") {
// here is a convenient reference to the movie clip to which we will assign behaviours
thisMovie=_root.holder1_mc[allClips[m]];
// we assign a property to this movie in order to carry it into the function below
thisMovie.index=m;
thisMovie.onRelease = function () {
getURL(linksArray[this.index]);
}
thisMovie.onRollOver = function () {
// glow (note: because of the if statement: no link, no glow)
// as above, a convenient reference to the current glow clip
// note that without assigning the index property above, we would not have
// access to m inside the function
thisGlow=_root.holder2_mc[glowClips[this.index]];
thisGlow._alpha = 85;
// write the image number to a Local Shared Object.
// Tells which full-size image to show in a different flash file
var imageToShow_so = SharedObject.getLocal("imageToShare", "/");
imageToShow_so.data.imageNumber = this.index;
imageToShow_so.flush();
}
thisMovie.onRollOut = function () {
thisGlow=_root.holder2_mc[glowClips[this.index]];
thisGlow._alpha = 0;
}
}
}
}
varsObj.load("links.txt");
***FullSize***
// here is the code which precedes the number in the thumb file name
// it must be specified as a parameter in the tag that calls this movie
// and the statement below can be removed.
var tcode = "asa_";
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size Image";
_global.oldNum = (-1);
_global.toggle = 2;
// let's load images alternately into imageHolder1 and imageHolder2
// we put an extra level of container. loading a jpg into the "image" container destroys
// all the properties of "image". so instead we put all the properties onto imageHolder 1 & 2
_root.holder_mc.createEmptyMovieClip("imageHolder1 ",1);
_root.holder_mc.imageHolder1.createEmptyMovieClip( "image",1);
//_root.holder_mc.imageHolder1.image.attachMovie("MC _Default", "default_mc",1);
_root.holder_mc.imageHolder1.image._x=0;
_root.holder_mc.imageHolder1.image._y=30;
_root.holder_mc.createEmptyMovieClip("imageHolder2 ",2);
_root.holder_mc.imageHolder2.createEmptyMovieClip( "image",1)
function updateImage () {
var newImage_so = SharedObject.getLocal("imageToShare", "/");
// a convenient way to refer to the image number
var imageNum = newImage_so.data.imageNumber + 1;
if (imageNum !== oldNum) {
if (imageNum == 0) {
//load default background; not implemented. client happy with background
}else{
// build the name of the image
if (imageNum>99) {
image = imageNum;
}else if (imageNum>9) {
image = "0" + imageNum;
}else {
image = "00" + imageNum;
}
// construct the name of the thumbnail, including the path
var newImage = "fullsize" + "/" + tcode + image + ".jpg";
// alternately load images into imageHolder1 and imageHolder2
if (toggle == 1) {
if (textArray[imageNum-1]==undefined){
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size";
}else{
descr_txt.text = textArray[imageNum-1];
}
_root.holder_mc.imageHolder1.image.loadMovie(newIm age,1);
_root.holder_mc.imageHolder1.image._x=0;
_root.holder_mc.imageHolder1.image._y=30;
_root.holder_mc.imageHolder1.onEnterFrame = function () {
if (this._alpha < 100) {
this._alpha += 10;
}else {
delete this.onEnterFrame;
}
}
_root.holder_mc.imageHolder2.onEnterFrame = function () {
if (this._alpha > 0) {
this._alpha -= 15;
}else {
delete this.onEnterFrame;
}
}
toggle = 2;
} else if (toggle == 2) {
if (textArray[imageNum-1]==undefined){
descr_txt.text = "Mouse Over a ThumbNail Image to View Full Size";
}else{
descr_txt.text = textArray[imageNum-1];
}
_root.holder_mc.imageHolder2.image.loadMovie(newIm age,1);
_root.holder_mc.imageHolder2.image._x=0;
_root.holder_mc.imageHolder2.image._y=30;
_root.holder_mc.imageHolder2.onEnterFrame = function () {
if (this._alpha < 100) {
this._alpha += 10;
}else {
delete this.onEnterFrame;
}
}
_root.holder_mc.imageHolder1.onEnterFrame = function () {
if (this._alpha > 0) {
this._alpha -= 15;
}else {
delete this.onEnterFrame;
}
}
toggle = 1;
}
}
oldNum = imageNum;
}
}
setInterval(updateImage,300);
Arrggh ActionScript For Flash Mail Form Works On Local, But Not Effective On Remote?
Hey guru,
I have Flash site with navigation menu and slide in & out boxes of contents for each sections - each sections has own Flash movie files.
In the 'Contact Us' section - I am trying to add 'contact form' which I've downloaded from site and it works on it own.
Now I tried to add on my exisiting Flash file in 'Contact Us' section. I tested on the localhost and works fine after filling out the form and hit subit button then form disappears with 'Message Sent' box on top (next frame).
But when I uploaded them to web hosting site - the 'Message Sent' did not show up even it has sent form in email to me anyway.
I tried different ways in scripting - only things it works localhost with this:
Code:
onClipEvent (data) {
// show message sent screen
_parent.nextFrame();
}
I have tried this way...
Code:
onClipEvent (data) {
// show message sent screen
_root.nextFrame();
}
Still no luck. Is there something I should have added for them to work on web server (remote)?
Please let me know mate!
LB
My ActionScript Not Working When Published Works In Flash 6 Not In Flash 8~
Hi,
I have this file which I created from http://www.tutorialized.com/tutorial...entation/11499 where the actionscript works in Flash Player 6 but when I publish into Flash player 7 or 8 it does not seem to want to play.
It gets a pop up message stating:
"A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort?"
My purpose to get this working in Flash 8 is because I need to incorporate CSS Stylesheets externally.
Here is the following actionscript:
stop();
numberOfTabs = 3;
for (i=1; i<=numberOfTabs; i++) {
line = eval("tab"+i);
line.onRelease = function() {
for (i=1; i<=numberofTabs; i++) {
otherTabs =
eval("this._parent.tab"+i);
otherTabs.bottomLine._visible =
true;
}
this.bottomLine._visible = false;
contentFrame = Number (this._name.substr(3,
1));
this._parent.contents.gotoAndStop(contentFrame);
}
}
tab1.bottomLine._visible = false;
tab1.onPress = function() {
gotoAndStop("tab1");
};
tab2.onPress = function() {
gotoAndStop("tab2");
};
tab3.onPress = function() {
gotoAndStop("tab3");
};
How does it need to be changed?
[FCS3] Adding Actionscript To A Movieclip Through Actionscript?
Yo, is there a way to add actionscript to a movieclip created in actionscript? Such as a onClipEvent(load) and onClipEvent(enterframe)? I have a onEnterFrame already for the movie clip as its created though. I have taken code thats from a gravity tutorial where it uses the two methods above. I've tried adding them into the onEnterFrame that I had already to add gravity to the movieclips created though that did'nt work =(
Jigsaw Puzzle - Changing From Actionscript 2.0 To Actionscript 3.0
Hello Everyone,
I was hoping someone could help me convert the following actionscript from actionscript 2.0 to actionscript 3.0. I'm trying to complete a jigsaw puzzple but I'm having problems converting it into actionscript 3.0.
Below is my actionscript:
//Puzzle Pieces
scramble_btn.onRelease = function(){
piece1._x = random(250);
piece1._y= random(250);
piece2._x = random(250);
piece2._y= random(250);
piece3._x = random(250);
piece3._y= random(250);
piece4._x = random(250);
piece4._y= random(250);
startGame();
messageOn.text = "";
counter.text = "00:00";
clearInterval(timeStarted);
timeStarted = setInterval(countdown, 1000);
time_start = 0;
}
//Puzzle Move
function startGame(){
piece1.onPress = function(){
this.startDrag();
piece1.swapDepths(1)
}
piece1.onRelease = function() {
this.stopDrag();
hit1();
checker();
};
piece2.onPress = function(){
this.startDrag();
piece2.swapDepths(1)
}
piece2.onRelease = function() {
this.stopDrag();
hit2();
checker();
};
piece3.onPress = function(){
this.startDrag();
piece3.swapDepths(1)
}
piece3.onRelease = function() {
this.stopDrag();
hit3();
checker();
};
piece4.onPress = function(){
this.startDrag();
piece4.swapDepths(1)
}
piece4.onRelease = function() {
this.stopDrag();
hit4();
checker();
}
};
//HitTest Script
function hit1(){
if(piece1.hitTest(container1)){
piece1._x = container1._x;
piece1._y = container1._y;
}else{
piece1._x = random(250);
piece1._y = random(250);
}
}
function hit2(){
if(piece2.hitTest(container2)){
piece2._x = container2._x;
piece2._y = container2._y;
}else{
piece2._x = random(250);
piece2._y = random(250);
}
}
function hit3(){
if(piece3.hitTest(container3)){
piece3._x = container3._x;
piece3._y = container3._y;
}else{
piece3._x = random(250);
piece3._y = random(250);
}
}
function hit4(){
if(piece4.hitTest(container4)){
piece4._x = container4._x;
piece4._y = container4._y;
}else{
piece4._x = random(250);
piece4._y = random(250);
}
}
//Timer
counter.text = "00:00";
function countdown() {
started();
time_start = time_start+1;
if (time_start>10) {
messageOn.text = "GAME OVER!!!";
clearInterval(timeStarted);
}
}
function started(){
sec = Math.floor(time_start+1/1000);
sec = (sec<10)?"0"+sec:sec;
min = Math.floor(sec/60);
min = (min<10)?"0"+min:min;
counter.text = min+":"+sec;
};
//This will check if all puzzle pieces are complete...and display game finish messsage.
function checker(){
if((piece1.hitTest(container1)) && (piece2.hitTest(container2)) && (piece3.hitTest(container3)) && (piece4.hitTest(container4))){
messageOn.text = "CONGRATULATIONS!!!";
clearInterval(timeStarted);
}
}
Giving Actionscript To An Actionscript-loaded Movie
How can I (if possible) set actionscript (say, an on-mouse event) to a movie that I load via attachMovie()? I poked around and I couldn't seem to find an answer...
I want the movie that I load via attachMovie() to have an on(RollOver) event...any thoughts?
Warning: An ActionScript 1.0/2.0 SWF File Has Loaded An ActionScript 3.0 SWF;
Hi all,
I'm trying to clone an swf (produced in CS3) that has been loaded into my app (built using Actionscript/mxmlc) but keep getting the following message appear in my logs:
Code:
Warning: An ActionScript 1.0/2.0 SWF file has loaded an ActionScript 3.0 SWF; code in the ActionScript 3.0 SWF will not run.
I know the CS3 swf has been produced using Actionscript 3 as it's settings and published for FP9. It does nothing more than a motion tween of a graphic.
Here is a really simple example of how to emulate the problem:
ActionScript Code:
package{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
[SWF(backgroundColor=0x000000)]
public class Test extends Sprite{
private var _mc:MovieClip;
public function Test():void{
var mc:String = "rain.swf";
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedSWF);
ldr.load(new URLRequest(mc));
}
private function loadedSWF(e:Event):void{
var mc:MovieClip = MovieClip(e.target.content);
this._mc = MovieClip(new (mc.constructor)());
this.addChild(this._mc);
}
}
}
I'm using the following version of mxmlc: Version 3.0.0 build 1844
I've also tried a slightly more convoluted way:
ActionScript Code:
package{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getQualifiedClassName;
import flash.net.URLRequest;
[SWF(backgroundColor=0x000000)]
public class Test extends Sprite{
private var _mc:MovieClip;
public function Test():void{
var mc:String = "rain.swf";
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedSWF);
ldr.load(new URLRequest(mc));
}
private function loadedSWF(e:Event):void{
var c:Class = Class(e.target.applicationDomain.getDefinition(getQualifiedClassName(e.target.content)));
this._mc = new c();
this.addChild(this._mc);
}
}
}
I would like to know what's causing the warning message, am I doing something wrong?
Works In Flash 6 Actionscript 1 & 2 But Not In Flash 7 Or 8
I have this bit of script that is a timer that counts down heres the script..
and it works well in flash 6 but not 7 or 8.. can anyone see the problem..
i have attached the timer.fla..
startTimer();
function restartTimer() {
hours = "00";
minutes = "00";
seconds = "00";
milliseconds = "00";
added = "";
buttonPressTime = getTimer()/1000-pauseLength;
pauseTimer();
}
function startTimer() {
unpauseTime = getTimer()/1000;
pauseLength = (unpauseTime-pauseTime)+pauseLength;
StartTime = 11;
timing = true;
}
function addTimer() {
added = added+10;
timing = true;
}
function pauseTimer() {
pauseTime = (getTimer()/1000);
timing = true;
}
//
timer = scoreBoard.onEnterFrame=function () {
scoreBoard.goTime = goTime;
scoreBoard.StartTime = StartTime;
scoreBoard.buttonPressTime = buttonPressTime;
scoreBoard.hours = hours;
scoreBoard.pauseLength = pauseLength;
scoreBoard.minutes = minutes;
scoreBoard.seconds = seconds;
totalTimes = getTimer()/1000-pauseLength;
goTime = (totalTimes-buttonPressTime);
//this is where you set the original amount of time (in seconds)
//StartTime = 12;
runTime = (StartTime-goTime);
//
if (timing == true) {
hours = Math.floor((runTime+added)/3600);
minutes = Math.floor(((runTime+added)/3600-hours)*60);
seconds = Math.floor((((runTime+added)/3600-hours)*60-minutes)*60);
//milliseconds = Math.floor(((runTime+int(added))-(seconds+(minutes*60)+(hours*3600)))*100);
if (seconds<10) {
seconds = "0"+seconds;
}
if (minutes<10) {
minutes = "0"+minutes;
}
if (hours<10) {
hours = "0"+hours;
}
/*if (milliseconds<10) {
milliseconds = "0"+milliseconds;
}*/
if (runtime<=0) {
restartTimer();
timing = false;
delete onEnterFrame;
}
}
};
Actionscript - User Input Actionscript
I am trying to develop a way where by a users input can determine the number of fields in a form e.g. the user inputs the number 3 then the form would have 3 fields
can you show me or point me in the direction of an example i can look at and manipulate?
[F8] Flash6 Actionscript 2, Flash 8 Actionscript 2...help
Ok loosing it a bit now, have gone back to a very old project from a Flash 6 file, managed to convert the script language to ActionScript2, works fine as flash6 actionscript2, but once I change the project to be flash 8 I get One error......and I know where it's coming from (see below), Have come to a dead - end here, so hope that one of you guys may be able to help me....
Feel free to use this if you can get it working, just credit the designer (Me).
On the main stage MC named "site", go inside and double click on any of the MC's (named "str0, or str1 etc....all instances). Once inside an "str" MC move to frame 2 and the MC on the stage should be called "seg0 or seg1 etc...(again all instances"), go inside the MC and click on frame 1 of the actions layer. Scroll down and look for the variable named "var nummer = _parent.plus+Number(this._name.substr(3, 1));"....this always returns NaN in flash player 8, but works in flash player 6?.................help me.....I'm drowning.
link to files:
http://www.solidvision.co.uk/dev/help.zip
Moving A Game From Actionscript 1.0 To Actionscript 2.0...
Hi there.
I hope someone can help me out here. I have been asked to create a simple Flash memory game, and I have been given a template to use as a basis. However, this template has been created in Actionscript 1.0 for Flash player 5. I now need to transfer it over to Actionscript 2.0 Flash player 8, and Ive noticed lots of odd behaviour once it has been changed.
Here is the code....
Code:
initGame();
stop();
function initGame() {
// make sorted list of cards
cardsListOrdered = [];
for (i=1; i<=18; i++) {
cardsListOrdered.push(i, i);
}
// shuffle list
cardsListSorted = [];
while (cardsListOrdered.length>0) {
r = int(Math.random()*cardsListOrdered.length);
cardsListSorted.push(cardsListOrdered[r]);
cardsListOrdered.splice(r, 1);
}
// create card clips and assign their location and picture
x = 0;
y = 0;
for (i=0; i<36; i++) {
attachMovie("Card", "Card"+i, i);
_root["Card"+i].picture = cardsListSorted[i];
_root["Card"+i]._x = x*60+200;
_root["Card"+i]._y = y*60+50;
// move to next card spot
x++;
if (x>5) {
x = 0;
y++;
}
}
firstclip = 0;
}
function clickCard(clip) {
// see if two card are showing
if (secondclip != 0) {
// turn those two cards back over
firstclip.enabled = true;
secondclip.enabled = true;
firstclip.gotoAndStop(1);
secondclip.gotoAndStop(1);
firstclip = 0;
secondclip = 0;
}
// see if same card was clicked
if (firstclip == clip) {
// turn card back over
firstclip.gotoAndStop(1);
firstclip = 0;
// see if no cards are showing
} else if (firstclip == 0) {
// turn first card over
clip.gotoAndStop(clip.picture+1);
firstclip = clip;
firstclip.enabled = false;
// must be one card showing
} else {
// turn second card over
clip.gotoAndStop(clip.picture+1);
secondclip = clip;
secondclip.enabled = false;
// see if two cards match
if (firstclip.picture == secondclip.picture) {
// Disable both cards
firstclip.enabled = false;
secondclip.enabled = false;
firstclip = 0;
secondclip = 0;
}
}
}
When set to FlashPlayer5, all works well. If a player tries clicking the same tile twice, it stops them. Also, when a pair of tiles are uncovered, again, the user is no-longer able to press them. This was done using the "enabled = false".
However, when I change it to Flash Player 8, none of these seems to work. Ill include the .fla so someone could possibly play around with it and see where the problem is, or whether there is another way to do it....
Hope someone can help.
Many thanks
Swf Actionscript 3, Load A Actionscript 2 File.
Hey dudes.
I need some help over here:
i have one banner player, and load some external swf files in actionscript 2, but the player is actionscript 3.
The files is loaded like a movie, when load a as2 files into as3. I just need a trigger when the swf file ends, when is in the last frame of movie.
Someone have a ideia in how do that?
thanks!
Flash ActionScript == Flex ActionScript?
Is ActionScript basically programmed the same way for Flash as it is for Flex? I know some folks who develop in AS for Flex. I didn't know if it was exactly the same for Flash, so I could tap them as a resource when I have an AS question.
Thanks,
Loren
Urgent :Getting Actionscript To 'pause' - Actionscript 2.0
Hi guys,
I need the actionscript to carry out a piece of code, then pause for 0.5 seconds, then carry out the next piece of code, then pause, then next code e.t.c
There will be twenty pieces of code that build up an animation with tweens that need to start at different times.
I guess its something to do with setInterval, but I'm not sure on the syntax, as there 20 pieces of code I don't want lots of nested code (though if thats the only way to do it then so be it!)
I'd really appreciate your help guys
cheers
Obtaining An ActionScript 2 Variable From ActionScript 3
Probably one of the most subjects on this forum has to be ActionScript 3 and ActionScript 2 communication. I found several threads on how to communicate between the two using a LocalConnection class, but there is one problem with this approach - I can't transport any values with it. Because LocationConnection.send doesn't have a return type, there is no way to transport a value from AS2 to AS3. This is very unfortunate, as I need to have access to a value that is set somewhere in the AS2 code.
I could use JavaScript as a middle layer to communicate the data between the two, but this will be a very ineffective way to achieve it. Are there any better ways for doing this?
ActionScript 3.0 Is 5~7 Times Slower Then ActionScript 2.0
I have a code that will translate this XML
quote:
<?xml version='1.0'?>
<Member>
<M>
<Username>Test 1</Username>
<Password>Test 1 Password</Password>
</M>
<M>
<Username>Test 2</Username>
<Password>Test 2 Password</Password>
</M>
<M>
<Username>Test 3</Username>
<Password>Test 3 Password</Password>
</M>
</Member>
Into this array
quote:
Array[0].Username = "Test 1"
Array[0].Password = "Test 1 Password"
Array[1].Username = "Test 2"
Array[1].Password = "Test 2 Password"
Array[2].Username = "Test 3"
Array[2].Password = "Test 3 Password"
Here is my variable declaration
quote:
var StartTime:Number = getTimer();
var EndTime:Number = getTimer();
var j:Number = 0;//This Variables used for ActionScript 3.0 Loop
var k:Number = 0;//This Variables used for ActionScript 3.0 Loop
Here is the XML String
quote:
var MyXMLString:String = "<?xml version='1.0'?><member><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O></member>";
var MyXML:XML = new XML(MyXMLString);//Parse the XML ONCE
I have a function called ConvertXML , and to check the performance i made it loop every frame by calling the following RunXML function
quote:
function RunXML(Events:Event){
StartTime = getTimer();
for(var i:Number=0;i<100;i++){
var MyXMLArr:Array = ConvertXML(MyXML, false, false);
}
EndTime = getTimer();
trace(EndTime - StartTime + " ms");
}
and here is my code for parsing the variable MyXML in ActionScript 3.0 (ConvertXML function)
quote:
//Action Script 3.0 ConvertXML
import flash.xml.*;
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (j=0; j<RecvXML.child("*").length(); j++) {
var TempObject = new Object();
for (k=0; k<RecvXML.child("*")[j].elements("*").length(); k++) {
TempObject[RecvXML.child("*")[j].elements("*")[k].name()] = RecvXML.child("*")[j].elements("*")[k];
}
RowArr.push(TempObject);
}
return RowArr;
}
addEventListener(Event.ENTER_FRAME, RunXML);
The code above run 5~7 times slower then the following actionscript 2.0 code
quote:
//Action Script 2.0 ConvertXML
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (var aNode:XMLNode = RecvXML.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
var TempRecord:Object = new Object();
for (var bNode:XMLNode = aNode.firstChild; bNode != null; bNode=bNode.nextSibling) {
TempRecord[bNode.nodeName] = bNode.firstChild.toString();
}
RowArr.push(TempRecord);
}
return RowArr;
}
this.onEnterFrame = RunXML;
they both does exactly the same thing.. and yet the actionscript 3.0 code run 5~7 TIMES SLOWER . why?
i have tried other benchmark, and it seems that actionscript 3.0 perform 10 to 100 TIMES FASTER then actionscript 2.0 , only for this one it run slower... why?
I also attach all the code for actionscript 3.0
should you want to try the actionscript 2.0 , just uncomment the ConvertXML and this.onEnterFrame for actionscript 2.0 and comment the one for actionscript 3.0
Why? have i done something wrong?
Cheers and God Bless,
Chowi
Attach Code
var StartTime:Number = getTimer();
var EndTime:Number = getTimer();
var MyXMLString:String = "<?xml version='1.0'?><member><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O></member>";
var MyXML:XML = new XML(MyXMLString);//Parse the XML ONCE
var j:Number = 0;//This Variables used for ActionScript 3.0 Loop
var k:Number = 0;//This Variables used for ActionScript 3.0 Loop
/*
//Action Script 2.0 ConvertXML
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (var aNode:XMLNode = RecvXML.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
var TempRecord:Object = new Object();
for (var bNode:XMLNode = aNode.firstChild; bNode != null; bNode=bNode.nextSibling) {
TempRecord[bNode.nodeName] = bNode.firstChild.toString();
}
RowArr.push(TempRecord);
}
return RowArr;
}
this.onEnterFrame = RunXML;
*/
//Action Script 3.0 ConvertXML
import flash.xml.*;
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (j=0; j<RecvXML.child("*").length(); j++) {
var TempObject = new Object();
for (k=0; k<RecvXML.child("*")[j].elements("*").length(); k++) {
TempObject[RecvXML.child("*")[j].elements("*")[k].name()] = RecvXML.child("*")[j].elements("*")[k];
}
RowArr.push(TempObject);
}
return RowArr;
}
addEventListener(Event.ENTER_FRAME, RunXML);
function RunXML(Events:Event){
StartTime = getTimer();
for(var i:Number=0;i<100;i++){
var MyXMLArr:Array = ConvertXML(MyXML, false, false);
}
EndTime = getTimer();
trace(EndTime - StartTime + " ms");
}
Edited: 10/09/2008 at 12:17:57 AM by M4G1C14N
URGENT How Do I Get Actionscript To Pause Actionscript 2.0
Hi guys,
sorry to repost, I know its an annoying thing to do, but this is pretty urgent on a project I'm doing.
I need the actionscript to carry out a piece of code, then pause for 0.5 seconds, then carry out the next piece of code, then pause, then next code e.t.c
There will be twenty pieces of code that build up an animation with tweens that need to start at different times.
I guess its something to do with setInterval, but I'm not sure on the syntax, as there 20 pieces of code I don't want lots of nested code (though if thats the only way to do it then so be it!)
I'd really appreciate your help guys
cheers
Actionscript 3 Tutorials For Actionscript Beginners
hey all, looking for some tutorials on actionscript 3 for people who are relatively new to actionscript altogether? Finding loads of tutorials but they seem to expect u to already have a grasp of actionscript 2!!
cheers in advance!
|