ActionScript 2, attachMovie
Hey, people!
I've got a small issue with attachMovie.
I've got an array with references to movie clips which I want to place at random locations on the scene.
Here is my function:
function randomize(target_array){
top_y = 87;
bottom_y = 296;
left_x_range = 16;
right_x_range = 220;
left_x_range_second = 305;
right_x_range_second = 535;
for(i = 0; i < target_array.length; i++){
var mc = target_array[i];
trace(mc);
mc_clothes_holder.attachMovie(mc, mc, mc_clothes_holder.getNextHighestDepth());
currY = Math.floor(Math.random() * (1 + bottom_y - top_y)) + top_y;
if(i%2 != 0){
currX = Math.floor(Math.random() * (1 + right_x_range - left_x_range)) + left_x_range;
mc_clothes_holder.mc._x = currX;
mc_clothes_holder.mc._y = currY;
}else{
currX = Math.floor(Math.random() * (1 + right_x_range_second - left_x_range_second)) + left_x_range_second;
mc_clothes_holder.mc._x = currX;
mc_clothes_holder.mc._y = currY;
trace(mc_clothes_holder.mc);
The thing here is that the trace of "mc" in the beginning returns the correct movie clip reference, but "mc_clothes_holder.mc" after the attachMovie returns "undefined".
Does anyone have any idea why this doesn't work? What have I done wrong?
Thanks!
Your problem may lie in the way you are using "mc" In an attachMovie scenario, the first argument is supposed to be the linkage ID of the object in the library. Then you go and name the instance you create that same thing, "mc", which is bound to conflict with the var mc you already defined which is merely a string value.
I'm tempted to tell you to try tracing...
trace(mc_clothes_holder[mc]);
because if mc is a string, and is the instance name as well, you would need to use bracket notation (or eval) to have the string treated as an object reference.
But I'd recommend changing the name of the instance you create to something else, maybe: mc+"Obj" just to avoid any confusion...
trace(mc_clothes_holder[mc+"Obj"]);
Similar Messages
-
Using Actionscript to create complete scenes
Ok let me paint a picture. I'm designing an online flash
application that will dynamically display tutorials stored in a
MySQL database. These tutorials will be added via a php control
panel for tutors to add new tutorials to the database.
So my flash will load, dynamically create a new scene, add in
some static elements i.e. logo and some other images and then list
the tutorials for the user to select.
The user then selects a tutorial and a new scene is
dynamically created to display the contents of this scene i.e. a
scrollPane for the text, video component for the video elements and
the title etc.
I recently read this tutorial so getting the data from the
database into Flash shouldn't be a major problem.
http://www.webmonkey.com/webmonkey/03/40/index1a.html
Here's what I think I need
I'm about to start digging through my flash bible so I'll
edit this and let you know what I've found out myself,
1. How to create a new scene using Actionscript,
2. How to add a few images (jpgs) from the library using
Actionscript,
3. how to add a scrollPane (all using actionscript),
4. how to add some text fields,
5. how to add a video player to access a video from a folder
on the server and lastly
6. some kind of back button..
Majority of these components will be loading content from PHP
which will access my MySQL server.
Any help would be greatly appreciated.
Thanks
SteveA tall order for a single thread! There are many possible
answers to each question. Plus there are not enough specifics to
guide you to the correct alternative. The good news it you can do
what you are planning.
1. How to create a new scene using Actionscript,
Do not be confused with the technical feature of a scene in
Flash IDE. It is not something you use in Actionscript. However
from a design view, you can create any page oriented content
application you want. The usually dynamic element for creating a
page is a MovieClip or the as you mentioned the component
ScrollPane which is MovieClip.
Beyond that there are many many ways to go.
In general you would create one or more template layouts and
load the content in selecting the template.
A shell Flash movie would handle the loading of the templates
and the data or content that would show.
As well there could be swf that are custom pages that simply
load and handle all the needed content separately.
2. How to add a few images (jpgs) from the library using
Actionscript,
MovieClip.attachMovie
You also can load externally using
MovieClip.loadMovie
or if you need to manipulate it after loading then
MovieClipLoad.onLoadInit
3. how to add a scrollPane (all using actionscript),
Explained at
ScrollPane.contentPath">MovieClipLoad.onLoadInit
4. how to add some text fields,
The question implies to create the TextField dynamically and
a central method is:
MovieClip.createTextField
5. how to add a video player to access a video from a folder
on the server and lastly
Use the FLVPlayback component that is delivered with Flash 8
Pro. You need to encode the video as FLV format using the video
encoder that comes with Flash 8 (also possible with import except
you elected to make it external) or a third party encoder.
You put the flv files on the server with the swf containing
the FLVPlayer and use the
FLVPlayback.contentPath
method.
6. some kind of back button..
Again many many ways to go: You can use the Flash component
button or create your own. You can make a button from a MovieClip.
You can do these dynamically or at design time and in either case
change their functionality and respond to their interactions at
runtime. -
Actionscript execution order with attachMovie statements
Hi I wonder if anyone's got any decent solutions to this...
Basically whenever I have a script generating an interface by
dynamically placing movie clips (using the attachMovie method), I
often need the actionscript of the attached movie clip to execute
before the rest of the code in the main script continues.
According to normal actionscript execution order, the current
script finishes before 1st frame actionscript of any attached
movies is executed, so say for example I had the following in frame
1 of my root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
trace("end");
and the movie clip in my library with the linkage identifier
"myMovieClip" has the following on frame 1 of its timeline:
trace("middle");
Normally this would output:
start
end
middle
However I want it to output:
start
middle
end
The only appropriate way I've found so far to do this is to
have a function that is called on completion of the myMovieClip
actions, i.e. in the root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
movieClip1.onLoaded=function() {
trace("end");
and in the timeline of the myMovieClip movie clip:
trace("middle");
this.onLoaded();
But the problem with this is that if I rather than the
trace("end"); statement I want a series of other commands,
some of them in turn using attachMovie methods, again wanting the
scripts to execute in the order above, I'm going to end up with a
lot of nested onLoaded functions and it's going to end up looking
pretty ugly!
Any thoughts?you're welcome.
i generally load everything sequentially. if you don't want user's to possibly advance into the display far enough to see a load-delay, then you can use some preload display. here's an example i'm doing for a current client:
www.kglad.com/Files/tf
and click portfolio.
this client has a lot of images to load and wants them presented as soon as possible so i load them sequentially. that makes for an orderly display (though this client only wants a few images viewable on-stage at any one time). -
Need help with actionscript 2 (root.attachmovie)
Hi all! I have a big problem at work. Here is the situation. I have an html passing a variable as an array to my flash. In the flash i want to call a couple of symbols depending on the variable from html and display them as a slideshow. I need to add these symbols dynamically but i dont know where to start. I have created all my movie symbols and linked them for actionscript. I have created a simple line of code just to display one symbol using _root.attachMovie and the symbol does not show. here it the code:
_root.attachMovie(usb, usb,1);
usb.x = 276.15;
usb.y = 199.50;
Now the symbol should be visible right? What am i doing wrong?This is the Flash Player forum; you better ask in the Actionscript forum.
-
Using Actionscript to generate a grid
Hello all.
I am working on a Flash project and have a problem that has
turned out to be a real head scratcher for me. I need to create a
Flash form that will generate a floorplan grid based upon width and
length values entered by the user. I have successfully completed
part of the task and I am able to generate a grid based upon the
width and length entered by the user.
Here is my problem: When the Width and Length "units" are
entered as feet, I need to generate a grid that displays 1 grid
square for every 5 feet of length or width entered, (the scale is 1
square grid = 5 ft so if you entered a 50 ft building length or
width the "length or width" side of the grid would be 10 grid units
in length). Then, if the user re-enters new values for the width
and height and clicks "draw floorplan"
again
the grid needs to regenerate
again
at the proper size. Currently my sample generates 1 grid for
every foot of length or width entered and will not regenerate
properly.
Below is a link to a sample of where I am so far as well as
the Actionscript I am using to control the sample file.
Can anyone provide some pointers on how to generate the grid
with one grid representing 5ft and how to regenerate the grid once
new values are input and the "draw floorplan" button is clicked
again? (Also, ultimately I need to then send the form data as
email.)
Any help is very much appreciated!
Bitjammer
Link to sample:
http://216.197.127.249/grid/grid_sample_1.html
(Try entering 10 width and 10 length then click draw floor
plan)
Here is my actionscript code so far:
my_button.addEventListener("onPress",gridf);
my_button.onPress=function(){if(Number(widthTF.text)>1&&Number(heightTF.text)>1){gridF(Num ber(widthTF.text),Number(heightTF.text))
function gridF(h,w){
initX = 0;
initY = 0;
counter = 0;
for (var i = 1; i<=h; i++) {
for (var j = 1; j<=w; j++) {
counter++;
grid_container.attachMovie("cellMC", "cell"+counter,
counter);
grid_container["cell"+counter]._x = initX;
grid_container["cell"+counter]._y = initY;
initX += 15;
initY += 15;
initX = 0;
(For clarification: the width input variable is widthTF and
height input varible is heightTF.)Thanks for taking time to answer my post, kglad.
Yes. I believe I understand. I could create another button
and call it "Reset Grid" and call this function, however what I am
hoping for is to have the grid redraw simply by the user entering
new values for the width and height and then clicking "draw
floorplan" again.
Currently the first line of code is:
my_button.addEventListener("onPress",gridf); Should not the grid
redraw each time and then parse the new values in the width and
height fields? I am sure I am just dense but my grid is not
clearing each time the "draw " button is clicked.
You can see this happen on the sample link below. After
entering say 20 width and 20 height values and clicking "draw"
button, the grid is created perfectly. Then if, say new values of
10 width and 10 height are entered and "draw" button is clicked,
the grid does not redraw correctly using these new values.
Sample link:
http://216.197.127.249/grid/grid_sample_1.html
Could the problem be that the gridf function should happen as
the first function in the script before the new values are parsed
again? Should a: grid_container.removeMovieClip(); execute before
anything else is executed each time the "draw" button is clicked? -
How to add a button by writing in Actionscript?
I have a Flash Button. If I had drag this button from the
Library to the Document then I know how to have a mouse event. I
would write the event in the same Frame.
But I don't want to drag it from the Library. I want to
display this button by by using Actionscript, "attachMovie".
1. Is this the correct way to attach a button by
Actionscript?
2. How do I add a actionlistner?
My guess would be as the following but it doesnt' work:
var informationButton:MovieClip =
_root.attachMovie("myButton", "newButton",
_root.getNextHighestDepth());
WhatShouldBeHere.onRelease() = function(){
myFunction();
Thank you for all your suggestions....WhatShouldBeHere would be informationButton, or newButton.
Also, your onRelease function has a syntax error, you have two sets
of (). It should only be after the function(). -
Hi everyone,
I am new to actionscript and Flash.
I have been working on code updation project wherein initially we had an image and text as movieclips in fla library. The image and the text are read by the actionscript program which then creates an animation.
For Example:
// Picture
// _imageMC: Name of the Movie Clip in the libary which
// contains the picture.
var _imageMC:String = "polaroid";
This is later on used by another actionscript class as follows to finally create the animation.
var _mcPolaroid:MovieClip = this._mcBg.attachMovie(this._polaroid, "polaroid_mc", this._mcBg.getNextHighestDepth());
Now the problem here is when one needs to update the image or text, one needs to go and open the fla file andmanually change the image attached to the movieClip (polaroid).
I want to ease the updation process by giving the url of the image in an XML file. Read the image url from the xml and load this image in the library of the fla as movieclip. This, i think, will result in less code change and improve the updation of the final animation image.
The problem i am facing is not been able to figure out how can i change the image (after fetching its URL) to a movieclip and then load it in the library?
Thank you kindly in advance,
VarunThe following was my attempt: (i created a new MovieClip)
this.createEmptyMovieClip("polaroidTest", this.getNextHighestDepth());
loadMovie("imagefile.jpg", polaroidTest)
var _imageMC:String = "polaroidTest";
This mentioned variable _imageMC is read by a MovieClip class(self created as follows)
/////////////////////////////// CODE STARTS //////////////////////////////////////
class as.MovieClip.MovieClipPolaroid {
private var _mcTarget:MovieClip;
private var _polaroid:String;
private var _mcBg:MovieClip;
private var _rmcBg:MovieClip;
private var _w:Number;
private var _h:Number;
private var _xPosition:Number;
private var _yPosition:Number;
private var _border:Number;
* Constructor
function MovieClipPolaroid(mcTarget:MovieClip, polaroid:String) {
this._mcTarget = mcTarget;
this._polaroid = polaroid;
init();
* initialise the polaroid movieclip and reflecting it
private function init():Void {
this._border = 10;
this.initSize();
this.setPosition(48,35);
this.createBackground();
var _mcPolaroid:MovieClip = this._mcBg.attachMovie(this._polaroid, "polaroid_mc", this._mcBg.getNextHighestDepth());
_mcPolaroid._x = _border;
_mcPolaroid._y = _border;
var _rmcPolaroid:MovieClip=this._rmcBg.attachMovie(this._polaroid,"rpolaroid_mc", this._rmcBg.getNextHighestDepth());
_rmcPolaroid._yscale *=-1;
_rmcPolaroid._y = _rmcPolaroid._y + _h + _border ;
_rmcPolaroid._x =_border;
* create the background for the polaroid
private function createBackground():Void {
this._mcBg = _mcTarget.createEmptyMovieClip("target_mc",_mcTarget.getNextHighestDepth());
this._rmcBg = _mcTarget.createEmptyMovieClip("rTarget_mc", _mcTarget.getNextHighestDepth());
fill(_mcBg,_w+2*_border,_h+2*_border,100);
fill(_rmcBg,_w+2*_border,_h+2*_border,10);
placeBg(_mcBg,_w+2*_border,_yPosition);
placeBg(_rmcBg,_w+2*_border,_h+2*_border+_yPosition);
* position the background
private function placeBg(mc:MovieClip,w:Number,h:Number) : Void {
mc._x = Stage.width - w - _xPosition;
mc._y = h;
* paint the backgound
private function fill(mc:MovieClip,w:Number,h:Number, a:Number): Void {
mc.beginFill(0xFFFFFF);
mc.moveTo(0, 0);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
mc._alpha=a;
* init the size of the polaroid
private function initSize():Void {
var mc:MovieClip =_mcTarget.createEmptyMovieClip("mc",_mcTarget.getNextHighestDepth());
mc.attachMovie(this._polaroid,"polaroid_mc", _mcTarget.getNextHighestDepth());
this._h = mc._height;
this._w = mc._width;
removeMovieClip(mc);
mc = null;
* sets the position of the polaroid
public function setPosition(xPos:Number,yPos:Number):Void {
this._xPosition = xPos;
this._yPosition = yPos;
* moving in
public function moveIn():Tween {
var mc:MovieClip = this._mcTarget;
mc._visible=true;
var tween:Tween = new Tween(mc, "_x", Strong.easeOut, 0, 0, 1, true);
var tween:Tween = new Tween(mc, "_y", Strong.easeOut, 200, 0, 1, true);
var tween:Tween = new Tween(mc, "_xscale", Strong.easeOut, 30, 100, 1, true);
var tween:Tween = new Tween(mc, "_yscale", Strong.easeOut, 30, 100, 1, true);
var tween:Tween = new Tween(mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
return tween;
* moving in
public function moveOut():Tween {
var mc:MovieClip = this._mcTarget;
var tween:Tween = new Tween(mc, "_alpha", Strong.easeIn, 99, 0, 1, true);
var tween:Tween = new Tween(mc, "_x", Strong.easeIn,0, 1000, 1, true);
var tween:Tween = new Tween(mc, "_y", Strong.easeIn, 0, -50, 1, true);
var tween:Tween = new Tween(mc, "_xscale", Strong.easeIn, 100, 50, 1, true);
var tween:Tween = new Tween(mc, "_yscale", Strong.easeIn, 100, 50, 1, true);
return tween;
/////////////////////////////// CODE ENDS ///////////////////////////////////////
As in the current case, the name of the movieclip which has the image (originally polaroid) is being read through the variable _imageMC which we hadd given the value "polaroidTest".
The animation shows no image even when i have inserted the correct url (i m sure this step isn't wrong).
Any clues? -
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!!If you dont find anything specific, a lot of the problems i
encounter like this are because one little thing is spelled wrong.
like it doesnt match whats in your php file, ect. my suggestion,
though a long one, if you know its supposed to work, and theres no
syntax error, re type it, not copy and paste, and just be careful.
keep tripple checking. you might not even find what was spelled
wrong, but it might fix the situation, -
Help Please! My actionscript is rusty....
Hello Flash Friends!
Please help a rusty actionscript user - I'm just creating a
simple movie that when you mouse over it calls a movie then when
you take your mouse off the movie goes away - it'll be for stats
kinda thing, but it's been a while since I dabbled in the
actionscript world so I feel like a beginner again... I've got it
all working simple simple but what am I missing for the mouse out?
Or am I way off base?
this.createEmptyMovieClip ("container_mc",1);
button.onRollOver = function () {
var t:MovieClip =
container_mc.attachMovie("popup","popup_mc",container_mc.getNextHighestDepth());
button.onRollOut = function () {
**** MISSIN THIS *****
ANY help would be greatly appreciated.
Thanks for reading.I guess you want to remove it as you're attaching it each
time you rollover...
button.onRollOver = function () {
var t:MovieClip =
container_mc.attachMovie("popup","popup_mc",container_mc.getNextHighestDepth());
button.onRollOut = function () {
container_mc.popup_mc.removeMovieClip(); -
Action script _root.attachMovie
Hi all! I have a big problem at work. Here is the situation. I have an html passing a variable as an array to my flash. In the flash i want to call a couple of symbols depending on the variable from html and display them as a slideshow. I need to add these symbols dynamically but i dont know where to start. I have created all my movie symbols and linked them for actionscript. I have created a simple line of code just to display one symbol using _root.attachMovie and the symbol does not show. here it the code:
_root.attachMovie(usb, usb,1);
usb.x = 276.15;
usb.y = 199.50;
Now the symbol should be visible right? What am i doing wrong?I will paste my code so you have better understanding. Here is what i have in my flash:
txt1.text = logos;
It seems I have difficulties passing the FlashVars from html. I have created a dynamic text box which I gave the instance name txt1. In my html, I have the following code for the flash:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="60" id="FlashID" title="logoflash">
<param name="movie" value="logo.swf" />
<param name=FlashVars value="logos=usb%2mp3" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="logo.swf" width="300" height="60">
<!--<![endif]-->
<param name=FlashVars value="logos=usb%2mp3" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
</object>
</object>
I have already wrote "fla" in the text box. When I preview the flash only all that shows is "f". When I preview the html within Dreamweaver, there is nothing on the text box.
When i try your code:
trace(usb);
var mc:MovieClip=_root.attachMovie(usb, usb,1);
trace(mc);
Nothing shows...I have worked with that 4 hours yesterday and read everything, I`m lost!!! -
Hi, I don't know if anyone else has had this problem, but i
can't seem to solve it.
so i have a .fla and i'm loading an external swf into a
movieclip that exisits on the first frame of the .fla file using
movieClip.loadMovie. I want to attach a movieclip from the library
of the .fla i'm working in to the movieClip that i'm loading the
external swf into using movieClip.attachMovie. so the movieclip
should appear on top of the external swf. is this possible?Ah, thank you, that make sense now. The solution you
suggested worked great.
I did also find two other solutions, for anyone else who
might read this. One is to essentially create an empty movieclip on
your timeline. From the linkage window for the empty movieclip, I
made sure I set the Class field to the name of the class I'd
written, something I didn't do previously. This attaches all the
class actionscript to the empty movieclip, and even automatically
runs the constructor when the empty movieclip is placed on the
timeline. It also automatically provides a 'reference' to the main
timeline when I refer to this.attachMovie() from inside the class.
So it worked, but isn't as elegant as doing everything from the
actionscript (unless you are building a component).
The last reference I came across is the
Object.registerClass() method used to attach as class to an object,
similar to using the Linkage method above. But I haven't
successfully tried it yet.
Thanks again for the help kglad,
dana.
Dana Sheikholeslami
Art Institute of California -
Basic question about Actionscript and symbols
I like the object oriented features of actionscript (2.0).
One thing confuses me tho, namely the combination of symbol classes
and constructors. Since symbols can't be instanciated by new
SomeMovie(...), but rather has to be created with attachMovie(), it
seems to me that there is no use of constructors for symbols.
Instead you have to send an init object in the attachMovie() call.
This seems to me to be lacking in logic. It would be much more
logical if you could do:
var m = new MyMovie(constructor arguments...);
destinationClip.attachMovie(m);
Am I correct that this way of doing it is not possible in
current actionscript?
And second, don't you agree this would be a more consistent
use of the actionscript language?First, I just wanna thank u for replying. I still have some
follow up questions that I think are of interest:
About the first issue of constructors u say they
automatically gets called. But isn't it true that only a
constructor that takes no arguments can be automatically called?
Because, how could a constructor call with arguments MyMovie(x, y,
size, etc), be automatically called? My point is, that it would be
more neat to send the parameters thru the constructor, than thru an
init object. Also, I wonder why u think constructors are error
prone. Maybe they are error prone exactly because
Flash/actionscript invites to an inconsistent way of initializing
MovieClips and other object instances?
Second, u say that attaching a class to a MovieClip should be
avoided unless all or most of the functionality of the MovieClip
Class is needed. I usually attach a class a MovieClip that needs
some code to describe its behaviour. In practice, I think the only
essential method that I need from MovieClip is the onEnterFrame().
Are you suggesting that it would be better to skip onEnterFrame in
individual objects, and rather loop over some array to make all
objects get their command to do their thing? I thought the good
thing about onEnterFrame was that I could avoid having to traverse
arrays of objects, and instead let Flash itself call all objects
that need to be updated each frame.
Third, I would like to repeat the benefit of not having to
create variable names as attachMovie requires. For instance, assume
alot of clips are being attached to the same containing clip. Now u
have to make sure that all attached clips get different variable
names, or strange things will happen. But if attachMovie just took
a reference to a clip as parameter u would avoid that problem.
If u know some document that discusses these issues, i would
be happy if anyone had a link to it. My suggestion to the Flash
developers is to make MovieClip objects consistent with ordinary
objects. -
Mute and unmute button is actionscript 3.0
Hi,
I am wondering how to make a mute and unmute button is actionscript 3.0. I did it before in actionscript 2.0 but not in 3.0.
Here is my actionscript 2.0 code.
var sound = 1;
var slashMC = _root.attachMovie("slash","slash01",99);
slash01._visible = false;
slashMC._y = btn._y;
slashMC._x = btn._x;
var s:Sound = new Sound();
s.attachSound("Gravy");
s.start(1,999);
btn.onPress = function(){
if(sound==1){
s.stop();
slash01._visible = true;
sound = 0;
else if(sound==0){
sound = 1;
slash01._visible = false;
s.start(1,999);
ThanksTry this:
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
import flash.net.URLRequest;
var isPlaying:Boolean = false;
var snd:Sound = new Sound();
var channel:SoundChannel = new SoundChannel();
var pos:Number = 0;
var soundVolume:Number = 1;
snd.load(new URLRequest("something.mp3"));
btn_Stop.addEventListener(MouseEvent.CLICK, stopMusic);
btn_Stop.buttonMode = true;
btn_Play.addEventListener(MouseEvent.CLICK, playMusic);
btn_Play.buttonMode = true;
function stopMusic(evt:Event):void
channel.stop();
pos = 0;
isPlaying = false;
function playMusic(evt:Event):void
if(!isPlaying)
channel = snd.play(pos);
btn_Play.visible = false;
btn_Pause.visible = true;
isPlaying = true; -
Converting from actionscript 2 to actionscript 3
I found a program online thats sapoesed to do a lot of the converting for you and it did it converted more than 1000+ lines without any errors but not all of them... I am getting 2 errors in the code listed below and they are1084: Syntax error: expecting identifier before import. this is on line 3 of the code below and 1084: Syntax error: expefcting rightbrace before function. this i on lines 7 and 8 of the code below. i think there is a simple fix to these but cant figure out where to put the right brace and the identifier. Any help is highly appreciated.
Marcus
package {
if (_global.hasLoaded_XML == undefined)
import flash.display.MovieClip;
import flash.display.Stage;
_global.hasLoaded_XML = true;
Object.prototype.handleXML = public function (xmlNode, xmlPath, doneFunc)
xmlNode.ignoreWhite = true;
xmlNode.onLoad = function (success)
addTier = function (currentPath)
for (var _loc2 in currentPath.attributes)
currentPath[_loc2] = currentPath.attributes[_loc2];
} // end of for...in
for (var _loc2 in currentPath.childNodes)
if (currentPath.childNodes[_loc2].childNodes.length >= 0)
addTier(currentPath.childNodes[_loc2]);
} // end if
currentPath[currentPath.childNodes[_loc2].nodeName + _loc2] = currentPath.childNodes[_loc2];
currentPath[currentPath.childNodes[_loc2].nodeName] = currentPath.childNodes[_loc2];
} // end of for...in
addTier(xmlNode);
doneFunc();
xmlNode.load(xmlPath);
Object.prototype.set_nodeText = public function (textPass)
return (textPass);
Object.prototype.get_nodeText = public function ()
return (this.firstChild.nodeValue);
Object.prototype.addProperty("nodeText", Object.prototype.get_nodeText, Object.prototype.set_nodeText);
ASSetPropFlags(Object.prototype, ["get_nodeText", "set_nodeText", "nodeText"], 1);
} // end if
if (_global.hasLoaded_TWEENING == undefined)
_global.hasLoaded_TWEENING = true;
MovieClip.prototype.propTween = public function (id, propArray, valueArray, duration, method, nextStep, offset, nextParams)
var hasTripped = false;
if (this.loopHolder == undefined)
this.createEmptyMovieClip("loopHolder", this.getTopDepth());
} // end if
if (method == undefined)
var method = "linearTween";
} // end if
if (this.loopHolder["loopCounter_" + id] != undefined)
this.loopHolder["loopCounter_" + id].removeMovieClip();
} // end if
var _loc3 = this.loopHolder.createEmptyMovieClip("loopCounter_" + id, this.loopHolder.getTopDepth());
if (offset != undefined)
_loc3.duration = Math.max(duration, duration + offset);
if (offset < 0)
_loc3.rollBack = duration + offset;
else
_loc3.rollBack = 0;
} // end else if
else
_loc3.duration = duration;
} // end else if
_loc3.count = 1;
_loc3.onEnterFrame = function ()
if (this.count <= this.duration)
if (this.count <= duration)
for (var _loc2 = 0; _loc2 < propArray.length; ++_loc2)
if (this[b + "_" + propArray[_loc2]] == undefined || this.count == 1)
this[b + "_" + propArray[_loc2]] = this.parent.parent[propArray[_loc2]];
} // end if
this.parent.parent[propArray[_loc2]] = Penner[method](this.count, this[b + "_" + propArray[_loc2]], valueArray[_loc2], duration);
if (propArray[_loc2] == "scaleX" || propArray[_loc2] == "scaleY")
if (this.parent.parent[propArray[_loc2]] == 0 && this.parent.parent.visible == true)
this.parent.parent.visible = false;
} // end if
if (this.parent.parent[propArray[_loc2]] != 0 && this.parent.parent.visible != true)
this.parent.parent.visible = true;
} // end if
} // end if
} // end of for
} // end if
if (this.rollBack == this.count && nextStep != undefined)
nextStep(nextParams);
hasTripped = true;
} // end if
++this.count;
else
this.removeMovieClip();
if (nextStep != undefined && hasTripped != true)
nextStep(nextParams);
} // end if
} // end else if
MovieClip.prototype.killTweens = public function ()
this.loopHolder.removeMovieClip();
MovieClip.prototype.tweenScale = public function (xscale, yscale, duration, method, nextStep, offset, nextParams)
var _loc2 = "Scale";
var _loc4 = ["scaleX", "scaleY"];
var _loc3 = [xscale - this.scaleX, yscale - this.scaleY];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
MovieClip.prototype.tweenPosition = public function (xVar, yVar, duration, method, nextStep, offset, nextParams)
var _loc2 = "Position";
var _loc4 = ["x", "y"];
var _loc3 = [xVar - this.x, yVar - this.y];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
MovieClip.prototype.tweenRotation = public function (rotation, duration, method, nextStep, offset, nextParams)
var _loc2 = "Rotation";
var _loc4 = ["rotation"];
var _loc3 = [rotation];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
MovieClip.prototype.tweenAlpha = public function (alpha, duration, method, nextStep, offset, nextParams)
var _loc2 = "Alpha";
var _loc4 = ["alpha"];
var _loc3 = [alpha - this.alpha];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
MovieClip.prototype.tweenSize = public function (width, height, duration, method, nextStep, offset, nextParams)
var _loc2 = "Size";
var _loc4 = ["width", "height"];
var _loc3 = [width - this.width, height - this.height];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
MovieClip.prototype.tweenTint = public function (rtint, gtint, btint, duration, method, nextStep, offset, nextParams)
var _loc2 = "RGB";
var _loc4 = ["_rtint", "_gtint", "_btint"];
var _loc3 = [rtint - this._rtint, gtint - this._gtint, btint - this._btint];
this.propTween(_loc2, _loc4, _loc3, duration, method, nextStep, offset, nextParams);
} // end if
if (_global.hasLoaded_TMATH == undefined)
_global.hasLoaded_TMATH = true;
_global.ranNum = public function (low, high)
return (Math.round(Math.random() * (high - low)) + low);
} // end if
if (_global.hasLoaded_PENNER == undefined)
_global.hasLoaded_PENNER = true;
_global.Penner = {};
ASSetPropFlags(_global, "Penner", 1, true);
Penner.linearTween = public function (t, b, c, d)
return (c * t / d + b);
Penner.easeInQuad = public function (t, b, c, d)
t = t / d;
return (c * (t) * t + b);
Penner.easeOutQuad = public function (t, b, c, d)
t = t / d;
return (-c * (t) * (t - 2) + b);
Penner.easeInOutQuad = public function (t, b, c, d)
t = t / (d / 2);
if (t < 1)
return (c / 2 * t * t + b);
} // end if
return (-c / 2 * (--t * (t - 2) - 1) + b);
Penner.easeInCubic = public function (t, b, c, d)
t = t / d;
return (c * (t) * t * t + b);
Penner.easeOutCubic = public function (t, b, c, d)
t = t / d - 1;
return (c * ((t) * t * t + 1) + b);
Penner.easeInOutCubic = public function (t, b, c, d)
t = t / (d / 2);
if (t < 1)
return (c / 2 * t * t * t + b);
} // end if
t = t - 2;
return (c / 2 * ((t) * t * t + 2) + b);
Penner.easeInQuart = public function (t, b, c, d)
t = t / d;
return (c * (t) * t * t * t + b);
Penner.easeOutQuart = public function (t, b, c, d)
t = t / d - 1;
return (-c * ((t) * t * t * t - 1) + b);
Penner.easeInOutQuart = public function (t, b, c, d)
t = t / (d / 2);
if (t < 1)
return (c / 2 * t * t * t * t + b);
} // end if
t = t - 2;
return (-c / 2 * ((t) * t * t * t - 2) + b);
Penner.easeInQuint = public function (t, b, c, d)
t = t / d;
return (c * (t) * t * t * t * t + b);
Penner.easeOutQuint = public function (t, b, c, d)
t = t / d - 1;
return (c * ((t) * t * t * t * t + 1) + b);
Penner.easeInOutQuint = public function (t, b, c, d)
t = t / (d / 2);
if (t < 1)
return (c / 2 * t * t * t * t * t + b);
} // end if
t = t - 2;
return (c / 2 * ((t) * t * t * t * t + 2) + b);
Penner.easeInSine = public function (t, b, c, d)
return (-c * Math.cos(t / d * 1.570796E+000) + c + b);
Penner.easeOutSine = public function (t, b, c, d)
return (c * Math.sin(t / d * 1.570796E+000) + b);
Penner.easeInOutSine = public function (t, b, c, d)
return (-c / 2 * (Math.cos(3.141593E+000 * t / d) - 1) + b);
Penner.easeInExpo = public function (t, b, c, d)
return (t == 0 ? (b) : (c * Math.pow(2, 10 * (t / d - 1)) + b));
Penner.easeOutExpo = public function (t, b, c, d)
return (t == d ? (b + c) : (c * (-Math.pow(2, -10 * t / d) + 1) + b));
Penner.easeInOutExpo = public function (t, b, c, d)
if (t == 0)
return (b);
} // end if
if (t == d)
return (b + c);
} // end if
t = t / (d / 2);
if (t < 1)
return (c / 2 * Math.pow(2, 10 * (t - 1)) + b);
} // end if
return (c / 2 * (-Math.pow(2, -10 * --t) + 2) + b);
Penner.easeInCirc = public function (t, b, c, d)
t = t / d;
return (-c * (Math.sqrt(1 - t * t) - 1) + b);
Penner.easeOutCirc = public function (t, b, c, d)
t = t / d - 1;
return (c * Math.sqrt(1 - (t) * t) + b);
Penner.easeInOutCirc = public function (t, b, c, d)
t = t / (d / 2);
if (t < 1)
return (-c / 2 * (Math.sqrt(1 - t * t) - 1) + b);
} // end if
t = t - 2;
return (c / 2 * (Math.sqrt(1 - (t) * t) + 1) + b);
Penner.easeInElastic = public function (t, b, c, d, a, p)
if (t == 0)
return (b);
} // end if
t = t / d;
if (t == 1)
return (b + c);
} // end if
if (!p)
p = d * 3.000000E-001;
} // end if
if (!a)
a = 0;
} // end if
if (a < Math.abs(c))
a = c;
var _loc7 = p / 4;
else
_loc7 = p / 6.283185E+000 * Math.asin(c / a);
} // end else if
t = t - 1;
return (-a * Math.pow(2, 10 * (t)) * Math.sin((t * d - _loc7) * 6.283185E+000 / p) + b);
Penner.easeOutElastic = public function (t, b, c, d, a, p)
if (t == 0)
return (b);
} // end if
t = t / d;
if (t == 1)
return (b + c);
} // end if
if (!p)
p = d * 3.000000E-001;
} // end if
if (!a)
a = 0;
} // end if
if (a < Math.abs(c))
a = c;
var _loc7 = p / 4;
else
_loc7 = p / 6.283185E+000 * Math.asin(c / a);
} // end else if
return (a * Math.pow(2, -10 * t) * Math.sin((t * d - _loc7) * 6.283185E+000 / p) + c + b);
Penner.easeInOutElastic = public function (t, b, c, d, a, p)
if (t == 0)
return (b);
} // end if
t = t / (d / 2);
if (t == 2)
return (b + c);
} // end if
if (!p)
p = d * 4.500000E-001;
} // end if
if (!a)
a = 0;
} // end if
if (a < Math.abs(c))
a = c;
var _loc7 = p / 4;
else
_loc7 = p / 6.283185E+000 * Math.asin(c / a);
} // end else if
if (t < 1)
t = t - 1;
return (-5.000000E-001 * (a * Math.pow(2, 10 * (t)) * Math.sin((t * d - _loc7) * 6.283185E+000 / p)) + b);
} // end if
t = t - 1;
return (a * Math.pow(2, -10 * (t)) * Math.sin((t * d - _loc7) * 6.283185E+000 / p) * 5.000000E-001 + c + b);
Penner.easeInBack = public function (t, b, c, d, s)
if (s == undefined)
s = 1.701580E+000;
} // end if
t = t / d;
return (c * (t) * t * ((s + 1) * t - s) + b);
Penner.easeOutBack = public function (t, b, c, d, s)
if (s == undefined)
s = 1.701580E+000;
} // end if
t = t / d - 1;
return (c * ((t) * t * ((s + 1) * t + s) + 1) + b);
Penner.easeInOutBack = public function (t, b, c, d, s)
if (s == undefined)
s = 1.701580E+000;
} // end if
t = t / (d / 2);
if (t < 1)
s = s * 1.525000E+000;
return (c / 2 * (t * t * ((s + 1) * t - s)) + b);
} // end if
t = t - 2;
s = s * 1.525000E+000;
return (c / 2 * ((t) * t * ((s + 1) * t + s) + 2) + b);
Penner.easeInBounce = public function (t, b, c, d)
return (c - Penner.easeOutBounce(d - t, 0, c, d) + b);
Penner.easeOutBounce = public function (t, b, c, d)
t = t / d;
if (t < 3.636364E-001)
return (c * (7.562500E+000 * t * t) + b);
else if (t < 7.272727E-001)
t = t - 5.454545E-001;
return (c * (7.562500E+000 * (t) * t + 7.500000E-001) + b);
else if (t < 9.090909E-001)
t = t - 8.181818E-001;
return (c * (7.562500E+000 * (t) * t + 9.375000E-001) + b);
else
t = t - 9.545455E-001;
return (c * (7.562500E+000 * (t) * t + 9.843750E-001) + b);
} // end else if
Penner.easeInOutBounce = public function (t, b, c, d)
if (t < d / 2)
return (Penner.easeInBounce(t * 2, 0, c, d) * 5.000000E-001 + b);
} // end if
return (Penner.easeOutBounce(t * 2 - d, 0, c, d) * 5.000000E-001 + c * 5.000000E-001 + b);
} // end if
if (_global.hasLoaded_COLOR == undefined)
_global.hasLoaded_COLOR = true;
MovieClip.prototype.apply_rtint = public function (value)
var _loc2 = new Color(this);
var _loc3 = {rb: value};
_loc2.setTransform(_loc3);
MovieClip.prototype.fetch_rtint = public function ()
var _loc2 = new Color(this);
return (_loc2.getTransform().rb);
MovieClip.prototype.addProperty("_rtint", MovieClip.prototype.fetch_rtint, MovieClip.prototype.apply_rtint);
ASSetPropFlags(MovieClip.prototype, ["apply_rtint", "fetch_rtint", "_rtint"], 1);
MovieClip.prototype.apply_gtint = public function (value)
var _loc2 = new Color(this);
var _loc3 = {gb: value};
_loc2.setTransform(_loc3);
MovieClip.prototype.fetch_gtint = public function ()
var _loc2 = new Color(this);
return (_loc2.getTransform().gb);
MovieClip.prototype.addProperty("_gtint", MovieClip.prototype.fetch_gtint, MovieClip.prototype.apply_gtint);
ASSetPropFlags(MovieClip.prototype, ["apply_gtint", "fetch_gtint", "_gtint"], 1);
MovieClip.prototype.apply_btint = public function (value)
var _loc2 = new Color(this);
var _loc3 = {bb: value};
_loc2.setTransform(_loc3);
MovieClip.prototype.fetch_btint = public function ()
var _loc2 = new Color(this);
return (_loc2.getTransform().bb);
MovieClip.prototype.addProperty("_btint", MovieClip.prototype.fetch_btint, MovieClip.prototype.apply_btint);
ASSetPropFlags(MovieClip.prototype, ["apply_btint", "fetch_btint", "_btint"], 1);
} // end if
if (_global.hasLoaded_DEPTHS == undefined)
_global.hasLoaded_DEPTHS = true;
MovieClip.prototype.getTopDepth = public function ()
var _loc3 = 0;
for (var _loc4 in this)
var _loc2 = this[_loc4];
if (_loc2.getDepth() != undefined && _loc2.getDepth() > _loc3)
_loc3 = _loc2.getDepth();
} // end if
} // end of for...in
return (_loc3 + 1);
} // end if
var tick = 0;
var transMethod = "easeInOutExpo";
var openClip = null;
_global.selectProject = function (whichClip)
if (!whichClip.isOpen)
lockMovie();
selectedProject = whichClip;
panelOpen = true;
closeProject(openClip);
openClip = whichClip;
whichClip.isOpen = true;
whichClip.fetchContent();
dropMe(whichClip);
} // end if
_global.deselectProject = function (whichClip)
delete selectedProject;
unlockMovie();
panelOpen = false;
closeProject(whichClip);
whichClip.setRollOvers();
_global.closeProject = function (whichClip)
whichClip.dropContent();
if (whichClip.isOpen)
whichClip.isOpen = false;
dropMe();
} // end if
dropMe = function (whichClip)
if (!whichClip)
deselectProject(selectedProject);
} // end if
public var _loc7 = [];
public var _loc5 = 0;
for (public var _loc2 = 0; _loc2 < projectArray.length; ++_loc2)
var _loc4 = projectArray[_loc2].dataObject.category;
if (projectArray[_loc2] != whichClip)
if (_global["filter_" + _loc4] == true)
_loc7.push(projectArray[_loc2]);
projectArray[_loc2].isOpen = false;
projectArray[_loc2].isOut = false;
continue;
} // end if
if (!projectArray[_loc2].isOut)
_loc5 = _loc5 + 2;
var _loc3 = 10 + _loc5;
projectArray[_loc2].isOut = true;
projectArray[_loc2].tweenScale(0, 0, _loc3, "easeInOutExpo");
projectArray[_loc2].tweenPosition(0, 0, _loc3, "easeInOutExpo");
} // end if
} // end if
} // end of for
orderArray = _loc7;
false;
whichClip.tweenPosition(0, 0, 20, transMethod);
whichClip.tweenScale(100, 100, 20, transMethod);
whichClip.tweenAlpha(100, 20, transMethod);
root["alignObjects_" + currentMode]();
_global.hideAll = function ()
for (public var _loc1 = 0; _loc1 < projectArray.length; ++_loc1)
projectArray[_loc1].tweenTint(-150, -150, -150, 10);
} // end of for
displayPlane.tweenTint(-30, -30, -30, 10);
_global.showAll = function ()
for (public var _loc1 = 0; _loc1 < projectArray.length; ++_loc1)
1;
projectArray[_loc1].tweenTint(0, 0, 0, 10);
} // end of for
displayPlane.tweenTint(0, 0, 0, 10);
alignObjects_horizontal = function ()
delete displayPlane.onEnterFrame;
public var range = 0;
setPos = public function (jump)
for (var _loc2 = 0; _loc2 < orderArray.length; ++_loc2)
var _loc1 = orderArray[_loc2];
var _loc8 = orderArray[_loc2 - 1];
if (_loc2 == 0)
range = range - (range - (displayPlane.width + 80 - stage.stageWidth)) * 1.000000E-001;
var _loc7 = range / stage.stageWidth;
var _loc9 = _loc1.x - (_loc1.x - (80 - stage.stageWidth / 2 + -mouseX * _loc7)) * 1.000000E-001;
else
_loc9 = _loc8.x + _loc8.width / 2 + _loc1.width / 2 + 10;
} // end else if
var _loc4 = 0;
var _loc11 = Math.sqrt(Math.pow(displayPlane.mouseX - _loc1.x, 2) + Math.pow(displayPlane.mouseY - _loc1.y, 2)) / 4;
if (Math.abs(displayPlane.mouseY) < 80 && !navOpen)
var _loc10 = 150 - Math.max(0, Math.min(100, _loc11));
if (_loc2 == 0)
_loc9 = _loc1.x - (_loc1.x - (100 - stage.stageWidth / 2 + -mouseX * _loc7)) * 1.000000E-001;
} // end if
else
_loc10 = _loc1.scaleX - (_loc1.scaleX - 100) * 2.000000E-001;
_loc9 = _loc1.x - (_loc1.x - (-orderArray.length * 120 / 2 + _loc2 * 120)) * 2.000000E-001;
} // end else if
var _loc5 = _loc1.scaleX - (_loc1.scaleX - _loc10) * 3.000000E-001;
var _loc6 = 100;
if (jump)
_loc1.y = _loc4;
_loc1.x = _loc1.x - (_loc1.x - _loc9) * 9.000000E-001;
_loc1.scaleX = _loc1.scaleY = _loc5;
_loc1.alpha = _loc6;
continue;
} // end if
if (panelOpen)
_loc5 = 0;
else
_loc5 = 100;
} // end else if
_loc9 = -orderArray.length * 120 / 2 + _loc2 * 120;
var _loc3 = 5 + _loc2;
if (_loc2 == orderArray.length - 1)
_loc1.tweenPosition(_loc9, _loc4, _loc3, transMethod, setMotion);
else
_loc1.tweenPosition(_loc9, _loc4, _loc3, transMethod);
} // end else if
_loc1.tweenScale(_loc5, _loc5, _loc3, transMethod);
_loc1.tweenAlpha(_loc6, _loc3, transMethod);
} // end of for
setMotion = public function ()
if (panelOpen != true)
displayPlane.onEnterFrame = function ()
setPos(true);
} // end if
setPos();
_global.root = this;
if (_root.swfRoot)
_global.swfRoot = _root.swfRoot;
else
_global.swfRoot = "";
} // end else if
setProperty("", _quality, "BEST");
var stageListener = new Object();
stageListener.onResize = function ()
layoutScreen();
Stage.addListener(stageListener);
layoutScreen = function ()
navBar.x = Math.round((stage.stageWidth - 1072) / 2);
navBar.y = Math.round((stage.stageHeight + 600) / 2);
displayPlane.BG.width = displayPlane.slug.width = stage.stageWidth;
displayPlane.BG.height = displayPlane.slug.height = stage.stageHeight;
navBar.mainNav.grabber.x = stage.stageWidth/2;
navBar.mainNav.BG.height = 30;
navBar.mainNav.BG.width = stage.stageWidth/2;
beginMovie = function ()
populatePanel();
createObjects();
layoutScreen();
displayPlane.tweenAlpha(100, 10);
populatePanel = function ()
createInterfaces();
createBackgrounds();
createFilters();
createInterfaces = function ()
_global.interfaceArray = [];
public var _loc5 = interfaceNode.data0;
public var _loc6 = navBar.mainNav.attachMovie("interfacePanel", "interfacePanel_1", 0);
navBar.mainNav.BG.x
_loc6.y = 1;
_loc6.x = 1;
for (public var _loc4 = 0; _loc4 < _loc5.childNodes.length; ++_loc4)
var thisObject = _loc5["interface" + _loc4];
var _loc3 = _loc6.attachMovie("navClip", "navClip" + _loc4, _loc4);
_loc3.thisObject = thisObject;
interfaceArray.push(thisObject);
_loc3.x = _loc4 * 150+ 1;
_loc3.textClip.displayText.text = thisObject.title.toUpperCase();
_loc3.textClip.displayText.autoSize = true;
_loc3.onRollOver = function ()
this.gotoAndPlay("in");
_loc3.onRollOut = function ()
this.gotoAndPlay("out");
_loc3.onPress = function ()
_global.currentMode = this.thisObject.id;
dropMe();
root["alignObjects_" + this.thisObject.id]();
setInterfaceRollovers(currentMode);
} // end of for
_global.currentMode = interfaceArray[ranNum(0, interfaceArray.length - 1)].id;
setInterfaceRollovers(currentMode);
setInterfaceRollovers = function (id)
public var _loc4 = interfaceNode.data0;
public var _loc3 = navBar.mainNav.interfacePanel_1;
for (public var _loc1 = 0; _loc1 < _loc4.childNodes.length; ++_loc1)
var _loc2 = _loc3["navClip" + _loc1];
if (id == _loc2.thisObject.id)
_loc2.toggleClip.gotoAndStop(1);
continue;
} // end if
_loc2.toggleClip.gotoAndStop(2);
} // end of for
createBackgrounds = function ()
_global.backgroundArray = [];
public var _loc5 = backgroundNode.data0;
public var _loc6 = navBar.mainNav.attachMovie("interfacePanel", "interfacePanel_2", 1);
_loc6.y = navBar.mainNav.interfacePanel_1.height + 50;
_loc6.x = 1;
for (public var _loc4 = 0; _loc4 < _loc5.childNodes.length; ++_loc4)
var thisObject = _loc5["interface" + _loc4];
var _loc3 = _loc6.attachMovie("navClip", "navClip" + _loc4, _loc4);
_loc3.thisObject = thisObject;
backgroundArray.push(thisObject);
_loc3.y = _loc4 * 23 + 34;
_loc3.textClip.displayText.text = thisObject.title.toUpperCase();
_loc3.textClip.displayText.autoSize = true;
_loc3.onRollOver = function ()
this.gotoAndPlay("in");
_loc3.onRollOut = function ()
this.gotoAndPlay("out");
_loc3.onPress = function ()
changeBG(this.thisObject.path);
} // end of for
changeBG(backgroundArray[ranNum(0, backgroundArray.length - 1)].path);
setBGRollovers = function (path)
public var _loc4 = backgroundNode.data0;
public var _loc3 = navBar.mainNav.interfacePanel_2;
for (public var _loc1 = 0; _loc1 < _loc4.childNodes.length; ++_loc1)
var _loc2 = _loc3["navClip" + _loc1];
if (path == _loc2.thisObject.path)
_loc2.toggleClip.gotoAndStop(1);
continue;
} // end if
_loc2.toggleClip.gotoAndStop(2);
} // end of for
changeBG = function (path)
setBGRollovers(path);
public var imageHolder = displayPlane.BG.createEmptyMovieClip("imageHolder", 0);
if (path)
imageHolder.alpha = 0;
imageHolder.loadMovie(swfRoot + path);
displayPlane.BG.onEnterFrame = function ()
if (imageHolder.getBytesLoaded() == imageHolder.getBytesTotal() && imageHolder.getBytesTotal() > 10)
imageHolder.x = -imageHolder.width / 2;
imageHolder.y = -imageHolder.height / 2;
imageHolder.tweenAlpha(100, 10);
delete this.onEnterFrame;
} // end if
} // end if
createFilters = function ()
public var _loc6 = projectsNode.data0;
for (public var _loc4 = 0; _loc4 < _loc6.projects.childNodes.length; ++_loc4)
var _loc5 = _loc6.projects["category" + _loc4];
_global["filter_" + _loc5.type] = true;
} // end of for
createObjects = function ()
_global.projectCount = 0;
_global.projectArray = [];
public var _loc8 = projectsNode.data0;
for (public var _loc7 = 0; _loc7 < _loc8.projects.childNodes.length; ++_loc7)
var _loc5 = _loc8.projects["category" + _loc7];
for (var _loc4 = 0; _loc4 < _loc5.childNodes.length; ++_loc4)
var _loc6 = _loc5["project" + _loc4];
_loc6.category = _loc5.type;
var _loc3 = displayPlane.attachMovie("displayNode", "displayNode_" + projectCount, projectCount);
_loc3.scaleX = _loc3.scaleY = 0;
_loc3.dataObject = _loc6;
projectArray.push(_loc3);
++projectCount;
} // end of for
} // end of for
_global.orderArray = projectArray;
public var _loc9 = displayPlane.attachMovie("slug", "slug", projectCount);
_loc9.visible = false;
_loc9.onRollOver = public function ()
_loc9.useHandCursor = false;
displayPlane.createEmptyMovieClip("topClip", projectCount + 1);
displayPlane.createEmptyMovieClip("topClip2", projectCount + 2);
this["alignObjects_" + currentMode]();
_global.bumpToTopLevel = function (whichClip)
if (whichClip.getDepth() < displayPlane.topClip.getDepth())
displayPlane.topClip.swapDepths(whichClip);
} // end if
_global.bumpToOrgLevel = function (whichClip)
if (whichClip.getDepth() > displayPlane.topClip.getDepth())
displayPlane.topClip.swapDepths(whichClip);
} // end if
_global.bumpToTopLevel2 = function (whichClip)
if (whichClip.getDepth() < displayPlane.topClip2.getDepth())
displayPlane.topClip2.swapDepths(whichClip);
} // end if
_global.bumpToOrgLevel2 = function (whichClip)
if (whichClip.getDepth() > displayPlane.topClip2.getDepth())
displayPlane.topClip2.swapDepths(whichClip);
} // end if
_global.lockMovie = function ()
displayPlane.slug.visible = true;
_global.unlockMovie = function ()
displayPlane.slug.visible = false;
_global.setTag = function (textPass)
nameTag.displayText.text = textPass.toUpperCase();
nameTag.displayText.autoSize = true;
nameTag.BG.width = nameTag.displayText.width + 20;
nameTag.BG.height = nameTag.displayText.height + 6;
nameTag.displayText.x = -Math.round(nameTag.displayText.width / 2);
nameTag.displayText.y = -Math.round(nameTag.displayText.height / 2) + 1;
public var X = Math.round(nameTag.displayText.width / 2) + 30;
public var Y = Math.round(nameTag.displayText.height / 2) + 30;
if (nameTag.visible != true)
nameTag.visible = true;
if (mouseX > 500)
var hTag = "left";
nameTag.x = mouseX - X;
else
var hTag = "right";
nameTag.x = mouseX + X;
} // end else if
if (mouseY > 100)
var vTag = "bottom";
nameTag.y = mouseY - Y;
else
var vTag = "top";
nameTag.y = mouseY - Y;
} // end else if
nameTag.y = mouseY;
nameTag.onEnterFrame = function ()
if (hTag == "left")
var _loc4 = _root.mouseX - (this.x + X);
else
_loc4 = _root.mouseX - (this.x - X);
} // end else if
if (vTag == "bottom")
var _loc3 = _root.mouseY - (this.y + Y);
else
_loc3 = _root.mouseY - (this.y - Y);
} // end else if
this.x = Math.round(this.x + _loc4 * 1.000000E-001);
this.y = Math.round(this.y + _loc3 * 1.000000E-001);
} // end if
_global.killTag = function ()
_root.nameTag.visible = false;
delete _root.nameTag.onEnterFrame();First off i would like to thank you for your reply! Second i am new to adobe flash and actionscript so let me explain to you what i trying to do. I downloaded a horizontal button menu and a photo slideshow made in flash and i have been trying to get them both to work in the same file. They both have xml's that i edited with my own stuff. Everything for the current web page i am createing right now is done its just getting them all together. I think the buttons that i downloaded are in as2 and im trying to get them into as3 with the slideshow. I am not 100% sure the buttons are as2 or not but i know when i import the slide show and change the setting in the publish settings to as3 the buttons dont show up but as long as its in as2 they will show up. Is there any easy way around this?
Thanks!
Marcus -
CFMX flash forms & actionscript
I'm sure this has been asked somewhere else, but I didn't see
a topic on it.
Using a cfform format=flash....there is a subset of the
actionscript language that is available for use. Is there a listing
somewhere of what is included in this subset, or any documentation
on this? When I'm writing an AS function, it would be nice to know
that either (1) the AS I'm trying to use isn't supported in that
subset or (2) it is supported, but I've just made a type or
something in my code. Most often, when either of these things
happens, my form just won't display which can make it tough to
track down the problem.
Any help, or a point in the right direction would be
great!!The
words
that Coldfusion's flash compiler prohibits have to do with the
creation of new objects. They are
new
import
delete
createChild
loadmovie
duplicateMovieClip
AttachMovie
registerclass
createTextField
__proto__
To get one decimal place, multiply by 10 and divide by 10. To
get two decimal places, multiply by 100 and divide by 100, and so
on. You will find more in this
technote
about rounding to specific decimal places in Flash
Maybe you are looking for
-
T400 with 5100N intel wireless only getting 72 MB max speed.
I have a Airlink 101 150N router that works at full speed (150 MB) with all my other N adapters except my new T400 that has a 5100N wireless adapter. It only gets 72 MB rate max at full signal strength. Any suggestions? Hal Solved! Go to Solution.
-
There is 2 seasons of the same tv show on my ipad. why is that?
Ok, I just got a iPad not to long ago and I'm having a problem with my videos. I have 2 Tosh.0 folders in videos. There both in the same season, but the episodes are split apart. Can someone please help me with an answer?
-
Morning all, I am trying to setup an array of numbers however, by looking at the crystal reports help file, I cannot find out how to set one up. I have created a new formula and inserted Local NumberVar Array x := MakeArray (1, 2, 3, 4, 5); however,
-
Hi All, I have a typical issue which i am unable to resolve. The scenario is, the user has created 2 Incoming Payments of amount INR 60,000.00 dated 26/02/09 and 28/02/09 with the same cheque number. Also, he has created two deposits and canc
-
Sorting search results by rank
Hi, Is it possible to sort the search results by rank in RH8 html help ? It works when I click on Title but not when Rank is clicked. What I mean is changing from ascending to descending order. Thanks,