Search Amazon.com:
Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us $3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
«37 »
  • Post
  • Reply
real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


I'm not sure my question deserves it's own thread but figure there are bound to be some more flash questions.

I'm trying to make a little intro video for a page on our site. I've been given a intro.flv and a menuloop.flv already. However no matter what I do in trying to import them into a new movie it won't loop.

I've set the frame that has the looping flv to gotandplay(2); which is the frame it's in but that's not working.

So just how the hell do I get it to play the first flv, then goto the looping flv and continue to loop that over and over?

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004


I don't have any questions at the moment, but I second the sentiment for a flash questions megathread. Because everytime I do flash, I want to kill something small and furry.

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


Grr my frustrations continue. I've looked online about using cue-points in my FLV file but they aren't very clear. This is what I'm using atm.

code:
import mx.video.*;
//my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/cuepoints.flv";
function ready(eventObject:Object) {
    my_FLVPlybk.setFLVCuePointEnabled(false, "loop-begin");
    my_FLVPlybk.setFLVCuePointEnabled(false, "loop-end");
}
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object) {
        if(eventObject.info.name == "loop-end")
            my_FLVPlybk.seekToPrevNavCuePoint.name == "loop-begin";
}
my_FLVPlybk.addEventListener("cuePoint", listenerObject);
With my movieclip titled my_FLVPlybk and the two important cue-points being loop-begin and loop-end.

Only it doesn't loop. It'll play, but it just goes through once and doesn't loop back to loop-begin after hitting loop-end.

Anyone know what I'm doing wrong?

PrObLeM
May 13, 2004
Slacker?

real_scud posted:

I'm not sure my question deserves it's own thread but figure there are bound to be some more flash questions.

I'm trying to make a little intro video for a page on our site. I've been given a intro.flv and a menuloop.flv already. However no matter what I do in trying to import them into a new movie it won't loop.

I've set the frame that has the looping flv to gotandplay(2); which is the frame it's in but that's not working.

So just how the hell do I get it to play the first flv, then goto the looping flv and continue to loop that over and over?

Why don't you create a listener to listen for the "complete" event and when it fires just start the video again.

http://livedocs.adobe.com/flash/8/m...e=00003510.html

leedo
Nov 28, 2000



Isn't there a "loop" option in the FLV properties box?

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


leedo posted:

Isn't there a "loop" option in the FLV properties box?
There's an auto-rewind option but I couldn't use that because the original FLV had both the intro animation and then a portion that could be looped. I set two cue-points at where the looping would begin and end but the listening code I pasted up above never worked.

In the end I got it working by directly importing the QT file into the timeline and then simply using a gotoandplay(x); on the last frame. It's a little dirtier than what I wanted, but the filesize isn't that bad since the movie is only played at 255x109px.

exzer0
May 7, 2003



How did you add the cue points, via AS or with the encoder ?

PrObLeM
May 13, 2004
Slacker?

exzer0 posted:

How did you add the cue points, via AS or with the encoder ?

code:
var cPt:Object = new Object();
cPt.time = 3.0;
cPt.name = "cue1";
cPt.type = "actionscript";
VideoObj.addASCuePoint( cPt );
this will set an actionscript cue point at second 3 called "cue1" to VideoObj.

You can also add extra data to the cPt object that will be passed when the cue point is fired.


code:
var Listener = new Object();
Listener.cuePoint = function( eObj:Object):Void {
trace( eObj.info.name );
}
VideoObj.addEventListener("cuePoint", Listener);
This will trace "cue1" at 3.0 seconds ( give or take .1 seconds according to the documentation )

PrObLeM fucked around with this message at Mar 19, 2007 around 20:18

exzer0
May 7, 2003



I was asking how to do it, I was asking how he did it. I have had trouble with the Flash 8 Video encoder loving up cue points, and always add them via the AS as you have shown, which could have been his issue.

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


exzer0 posted:

How did you add the cue points, via AS or with the encoder ?
Via the encoder

exzer0
May 7, 2003



Try it with the Actionscript PrOblem posted. I couldn't get the cuepoints to work from the encoder ever.

Bread Zeppelin
Aug 2, 2006
Stairway to Leaven

I've tried quite a few tutorials on how to make preloaders and on every single one the preloader won't show up until it's 100%, then flashes breifly and goes to the movie. When I play it in bandwidth simulator in Flash it works just fine. How do I go about fixing this?
I'm using a simple % bar found in example 2 on this page: http://www.senocular.com/flash/tutorials/preloading/

-JS-
Jun 1, 2004



Got any audio in your actionscript? Exporting it in the first frame? If so, that's your problem. Google something like 'flash preloader audio "first frame"' for some different ways around it.

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


What am I doing wrong here? If I use a moviecliploader, nothing happens.


code:
var imgUrl:String = "testdata/background.jpg";
var bg:MovieClip = _root.diagram.siteimage;
var bgimg:MovieClip = bg.createEmptyMovieClip("img", bg.getNextHighestDepth());
bgimg._x = 0;
bgimg._y = 0;
var mcListener:Object = {}
mcListener.onLoadStart = function(){
	trace("=-=-=-=LOAD START, OMG=-=-=-=-=-=");
      };
			
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(mcListener);
loader.loadClip(imgUrl, bgimg);
No callbacks, no image loaded, nothing.

If I do this:
code:
var imgUrl:String = "testdata/background.jpg";
var bg:MovieClip = _root.diagram.siteimage;
var bgimg:MovieClip = bg.createEmptyMovieClip("img", bg.getNextHighestDepth());
bgimg._x = 0;
bgimg._y = 0;
bg.img.loadMovie(imgUrl);
it works fine.

Bread Zeppelin
Aug 2, 2006
Stairway to Leaven

-JS- posted:

Got any audio in your actionscript? Exporting it in the first frame? If so, that's your problem. Google something like 'flash preloader audio "first frame"' for some different ways around it.

No audio, no components in the library. I do have 21 buttons, is that a lot? Do buttons load at the very beginning?

Mega Shark
Oct 4, 2004


rotor posted:

What am I doing wrong here? If I use a moviecliploader, nothing happens.


code:
var imgUrl:String = "testdata/background.jpg";
var bg:MovieClip = _root.diagram.siteimage;
var bgimg:MovieClip = bg.createEmptyMovieClip("img", bg.getNextHighestDepth());
bgimg._x = 0;
bgimg._y = 0;
var mcListener:Object = {}
mcListener.onLoadStart = function(){
	trace("=-=-=-=LOAD START, OMG=-=-=-=-=-=");
      };
			
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(mcListener);
loader.loadClip(imgUrl, bgimg);
No callbacks, no image loaded, nothing.

If I do this:
code:
var imgUrl:String = "testdata/background.jpg";
var bg:MovieClip = _root.diagram.siteimage;
var bgimg:MovieClip = bg.createEmptyMovieClip("img", bg.getNextHighestDepth());
bgimg._x = 0;
bgimg._y = 0;
bg.img.loadMovie(imgUrl);
it works fine.

You're calling loadClip on bgimg, change it to img.

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


ODC posted:

You're calling loadClip on bgimg, change it to img.

that doesn't work either, that was the first thing I tried. There's some advice on the mm site that says to load it into a blank mc if you have an image, something about loading an image wiping out the movieclips timeline.

Scarboy
Jan 30, 2001

Good Luck!

I need to stream some flvs on a website I'm creating and I can't for the live of me find a swf wrapper that will just let me give it a flv file as a parameter and play it on the drat website. Ideally, I'd like to find something open source where I can change the interface to my liking.

What am I supposed to search for if I'm trying to find something like that?

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


Scarboy posted:

I need to stream some flvs on a website I'm creating and I can't for the live of me find a swf wrapper that will just let me give it a flv file as a parameter and play it on the drat website. Ideally, I'd like to find something open source where I can change the interface to my liking.

What am I supposed to search for if I'm trying to find something like that?
Before he left my boss created something like that. Basically it's a SWF file that in the actionscript looks for a flv file to be fed to it. It then loads that FLV within the SWF wrapper and plays it without a hitch.

I'm not at work right now or I'd copy some of his code but I'll try to do it tomorrow.

Scarboy
Jan 30, 2001

Good Luck!

real_scud posted:

Before he left my boss created something like that. Basically it's a SWF file that in the actionscript looks for a flv file to be fed to it. It then loads that FLV within the SWF wrapper and plays it without a hitch.

I'm not at work right now or I'd copy some of his code but I'll try to do it tomorrow.

Exactly what I need, but shouldn't something like this be stupid easy to find on the net already? I mean, what are all of these current websites using to play their flv files?

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


Scarboy posted:

Exactly what I need, but shouldn't something like this be stupid easy to find on the net already? I mean, what are all of these current websites using to play their flv files?
I think it is, I mean I'm kind of sure he found it through some site somewhere but who knows sometimes things that should be everywhere on the net aren't and instead you can find tubgirl everywhere.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?


Question I've been dying to know forever. I just kinda assumed I was right.

Do professional Flash devs actually use the Macromedia/Adobe client to do their work?

I mean, to an extent, they do, of course. But there are certain things where I swear to god it's not even possible. I myself am not a Flash developer and I don't have faith in anyone who claims to be. It's always amateurish crap that couldn't get them hired, except for maybe your local church's website. With that, I don't know any Flash professionals, or any of their work. Things like crazy animations and spinning 3D models and all this wacky stuff, there's no way I believe that any of that was created inside of Flash. I think they import it somehow. But I don't know anything of how Flash works with stuff lke that.

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


Triple Tech posted:

Question I've been dying to know forever. I just kinda assumed I was right.

Do professional Flash devs actually use the Macromedia/Adobe client to do their work?

I mean, to an extent, they do, of course. But there are certain things where I swear to god it's not even possible. I myself am not a Flash developer and I don't have faith in anyone who claims to be. It's always amateurish crap that couldn't get them hired, except for maybe your local church's website. With that, I don't know any Flash professionals, or any of their work. Things like crazy animations and spinning 3D models and all this wacky stuff, there's no way I believe that any of that was created inside of Flash. I think they import it somehow. But I don't know anything of how Flash works with stuff lke that.

I don't know anything about spinning 3D models, and while I'm a professional Flash developer in that I'm being paid to make a flash app, I'm basically learning as I go.

Those caveats aside, I use the Flash IDE as little as possible. I use Flashdevelop, which is a little actionscript editor and frontend to MTASC, which is an open-sores actionscript compiler. I draw all the graphic symbols I need in the Flash IDE, then write the actionscript that manipulates these symbols in flashdevelop. It provides the division between resources (symbols, gifs) and code that I find the lack of so maddening in the Flash IDE. Also, with the Macromedia compiler, this happens:

code:
function foo(){
  var x = "butts";
  if(true){
    var x += 1;
  }
  trace(x);
}
The output isn't "butts," like in every rational language I've ever used, but is rather "butts1." Even more shocking, many built-in Macromedia classes rely on this stupid behavior. MTASC fixes that.

Scarboy
Jan 30, 2001

Good Luck!

After enough search I've found one that suits my needs exactly.

http://www.jeroenwijering.com/?item=Flash_Video_Player

Creative Commons License, provides the source, what more could I want.

Twon
Jan 30, 2002

Knight of Mars Beater of Ass

rotor posted:

Also, with the Macromedia compiler, this happens:

code:
function foo(){
  var x = "butts";
  if(true){
    var x += 1;
  }
  trace(x);
}
The output isn't "butts," like in every rational language I've ever used, but is rather "butts1." Even more shocking, many built-in Macromedia classes rely on this stupid behavior. MTASC fixes that.

As a recovering Flash user, wouldn't an actually rational language throw some kind of exception and abort execution here? I don't think the arbitrary decision to promote the constant '1' to something that can be +='ed with a string is invalid. You could probably make an argument for the output to be "1", using the logic that taking "butts" as a number would equal 0.

This is why I don't miss working in ActionScript.

mantaworks
May 6, 2005

by Fragmaster


rotor posted:

What am I doing wrong here? If I use a moviecliploader, nothing happens.

code:
1
No callbacks, no image loaded, nothing.

If I do this:
code:
2
it works fine.

The only difference between the two is using the var bgimg for the first and the path bg.img for the second. Try using bg.img for the first instead of bgimg.

quote:

that doesn't work either, that was the first thing I tried. There's some advice on the mm site that says to load it into a blank mc if you have an image, something about loading an image wiping out the movieclips timeline.

True. The timeline of the object (movieclip, image, flv) supersedes the timeline of the mc that's used as a holder. This is why putting any code on the holder is a bad idea, because that code will disappear once you're loading poo poo in it.

Also, the bg img bg imgimg bg is driving me nuts. use the name "holder" for every empty mc you're using as a, well, holder for loading things. Also avoid compound names because they complicate poo poo. Make it distinctive so you don't end up with bg.img and bgimg.



Triple Tech posted:

Question I've been dying to know forever. I just kinda assumed I was right.

Do professional Flash devs actually use the Macromedia/Adobe client to do their work?

I mean, to an extent, they do, of course. But there are certain things where I swear to god it's not even possible. I myself am not a Flash developer and I don't have faith in anyone who claims to be. It's always amateurish crap that couldn't get them hired, except for maybe your local church's website. With that, I don't know any Flash professionals, or any of their work. Things like crazy animations and spinning 3D models and all this wacky stuff, there's no way I believe that any of that was created inside of Flash. I think they import it somehow. But I don't know anything of how Flash works with stuff lke that.

There exist many external apps that are better suited for writing complecated actionscript. There's even an open source compiler out there that turns AS2 (wait, let me hold my barf in...... ok I'm good) into an swf. This makes writing complex pieces of code a lot easier, safer and better than with the original program.

Animation is a different story. Flash started out as an animation tool (quick question: what was it called?) and all the old, crappy tools from back when still exists with us today. It might be a bit hard to draw The Neverending Story, but animators are a bunch of self-loathing perfectionists so it's doable to do so in flash. However, you can easily write some code that would move a button to the righthand corner while simultaneously make a ball realistically bounce off walls, so it's very hard to say if something is hard to do based on the fact that it's animated. If we are talking about 3d, that is in 99% of the cases pre-rendered in programs like 3dsmax and added later. And so on and so forth.

Butt (hah I made myself laugh there because it's getting pretty late and I need to get some sleep) this is all moot since you never provided an example of something you find "crazy poo poo". You also don't know a lot about making things in flash so if I pressed the magic "pour rainbows and puppies and twelve naked scarlett johanssons at the visitor in full 3d" button thats there so you would go "man thats some crazy poo poo" I would know it took me about three seconds since I know where that button is, you would be blissfully ignorant of the complete and utter mind tricks we people in the industry like to call "magic" to make you post a message on the internet and buy our poo poo so we can exiture our dream of chartering a plane to bolivia, loving three whores while simoultaniously kickstarting a drugring with your money.

That button doesn't exist, unfortunately. But if it did I would press that magic button so hard so fast and so much that i would go through keyboards like a piercing scream through eardrums because scarlett johansson is the salt to the icesculpture of my hart.

What i'm saying is without any explanation of what you find hard to do in flash, I cannot give you an answer to your question.

mantaworks
May 6, 2005

by Fragmaster


rotor posted:

Those caveats aside, I use the Flash IDE as little as possible. I use Flashdevelop, which is a little actionscript editor and frontend to MTASC, which is an open-sores actionscript compiler. I draw all the graphic symbols I need in the Flash IDE, then write the actionscript that manipulates these symbols in flashdevelop. It provides the division between resources (symbols, gifs) and code that I find the lack of so maddening in the Flash IDE. Also, with the Macromedia compiler, this happens:


Tell me how. i've never been able to make mtasc work for me.

rotor posted:

The output isn't "butts," like in every rational language I've ever used, but is rather "butts1." Even more shocking, many built-in Macromedia classes rely on this stupid behavior. MTASC fixes that.

I can tell you why this is, but you probably already know why and hate it or you, in all probability, don't give a poo poo. And rightfully so.

[chavez]
Dec 20, 2003

by Y Kant Ozma Boo


mantaworks posted:

Animation is a different story. Flash started out as an animation tool (quick question: what was it called?)


Future Splash Animator or something like that. Anyways to answer TTs question, I'm a designer/flash developer and I use flash almost exclusively. Sometimes I use SE|PY but usually only if there's going to be crazy amounts of code. I am not a hardcore AS developer, since my background isn't in programming. I came from an ad agency where 90% of my workload was banner ad campaigns and full flash sites. I cut my teeth on the banner ads where we mostly used simple scripting to add dynamic movement. We also worked on the occasional flash game, such as banana barrage but even on games like that we still just used flash. It's been my experience that designers who start using flash just stick with flash usually, and programmers who start using flash usually end up going with some kind of 3rd party stuff since the IDE is so much different from .net or whatever other dev tools they usually use.

mantaworks
May 6, 2005

by Fragmaster


[chavez posted:

]
Future Splash Animator or something like that.

You win a cookie!

[chavez posted:

] It's been my experience that designers who start using flash just stick with flash usually, and programmers who start using flash usually end up going with some kind of 3rd party stuff since the IDE is so much different from .net or whatever other dev tools they usually use.

Absolutely agreed. As a programmer/developper, you don't get to tackle complex projects in an ad agency. Something like http://www.joukoosterhof.com/ is about the toughest website you'll get to build and after that the complexity of the code increases exponentially. Flash just doesn't have the right kind of options or tools to make it easier to work with multiple programmers and designers on a deadline.

nolen
Apr 4, 2004

butts.


rotor posted:

Also, with the Macromedia compiler, this happens:

code:
function foo(){
  var x = "butts";
  if(true){
    var x += 1;
  }
  trace(x);
}
The output isn't "butts," like in every rational language I've ever used, but is rather "butts1." Even more shocking, many built-in Macromedia classes rely on this stupid behavior. MTASC fixes that.


This would work in the Macromedia compiler if you set a type for the variable. The old way Flash handled variables, it allowed type changes on the fly. I loving hated it and I think AS 2.0 was a fantastic step in the right direction.

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


mantaworks posted:

The only difference between the two is using the var bgimg for the first and the path bg.img for the second. Try using bg.img for the first instead of bgimg.

Also, the bg img bg imgimg bg is driving me nuts. use the name "holder" for every empty mc you're using as a, well, holder for loading things. Also avoid compound names because they complicate poo poo. Make it distinctive so you don't end up with bg.img and bgimg.
at some point they had rational names, but I've tried so many permutations of adding what to where that they've kind of smeared together.

I've tried adding it to bg, to holder, to bg.holder, and even to _root. Nothing works. The URL is valid, because simply using holder.loadMovie(imgUrl) works fine.

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


mantaworks posted:

Tell me how. i've never been able to make mtasc work for me.

Since there's such a huge popular outcry for a Flash IDE Alternative HOWTO, and because something like this would have saved me weeks of work a few months ago, I'll go ahead and write one up.

Step Zero:
Own Flash 8.

Step One:
Download flashdevelop. The flashdevelop site is pretty weird - it's entirely configured as a messageboard. Whatever. Is it downloaded yet? Ok, then install it. It will also install MTASC and SWFMill.

Step Two:
Configure it properly - point it at your flash install so it knows where the classes are, stuff like that. There's some sample projects here you can use to make sure all is well.

Aside:
I use the Flash IDE to draw my graphics and use MTASC to insert the actionscript into it. There are other workflows that may work for you, but this writeup isn't about those workflows, so shut up, you. So here's how to do that:

Step Three:
Create a new .fla in flash. Draw your little rainbows and unicorns and disco dancing elves and compile it to a swf. Let's call it main.swf. Make an empty flashdevelop project somewhere, and copy main.swf into it.

Step Four:
Go to project properties. Under "output swf file" specify the name of the output swf. Don't use main.swf. Specify the target flash version, and tell it to open the swf in a new tab for testing. Go to the classpath tab and point it at your flash classes (probably c:\programfiles\macromedia\flash8\en\firstrun\classes or some poo poo like that), and if you have any other code, point it there too. Now, under the 'injection' tab, choose "enable code injection" and specify main.swf as your input swf. Press ok.

Step Five:
Create a Main.as file in the root of your project dir. This will (obviously) contain a class called "Main", which must have at least one static function named main(). This will be called on the first frame of your movie, and is the entry point for all your code. I am dogmatic about not placing ANY actionscript ANYWHERE else other than .as files. You may choose to be less dogmatic, but whatever.

Step Six:
Try making your own hello world app. Create some movieclips and load symbols into them.

Step Seven, In Which We Patch Stuff:
Remember that function-local nonsense in the macromedia classes? MTASC hates it, and for good reason. Unfortunately, it's all over the mx code. Fortunately, there exists a patch. Go to that site and apply both the core8 and the mx patches. At this point, I'm just going to cut & paste the 'how to patch your mx code' doc I've already written.

quote:

How To Patch Macromedias Actionscript To Compile with MTASC

Step Zero:
Copy the C:\[flash-install]\Flash 8\en\First Run\Classes directory somewhere. We'll pretend you copied it to c:\aspatch.

Step One:
Unzip the patch files and copy them into c:\aspatch.

Step Two:
Under cygwin, or in a dos box with gnu patch installed somewhere, go to c:\aspatch. Issue these commands:

patch –u –p3 –d . < mx.patch
patch –u –p3 –d ./FP8 < core8.patch

Viola, you've got patched classes.

Step Three:
Copy c:\aspatch back over your original flash installed classes. Probably wouldn't hurt to back up the originals.
tee hee. aspatch.


Step Eight:
Phew, you've worked hard. Take a break and enjoy this picture of a baby donkey.


Step Nine:
Try a hello world with an Alert. Go back to the Flash IDE and add the "Alert" component to the library, save & recompile. Now go back to flashdevelop and adjust the classpath under project properties to point to your patched classes. Then call Alert.show(...whatever...) somewhere in your code. Big Fun!

Step Ten:
Look back on this post and say "wow, rotor spent way too much time writing this, I should send him something nice for his efforts" and then just forget about it and ignore me, you jerk.

rotor fucked around with this message at Mar 27, 2007 around 17:34

rotor
Jun 11, 2001

Official Carrier
of the Neil Bush Torch

 
 
 
 
teh butts


Twon posted:

As a recovering Flash user, wouldn't an actually rational language throw some kind of exception and abort execution here? I don't think the arbitrary decision to promote the constant '1' to something that can be +='ed with a string is invalid. You could probably make an argument for the output to be "1", using the logic that taking "butts" as a number would equal 0.

no, that behavior is expected from an untyped language. Javascript does the same thing.

The weirdness is that the scope for the variable x is the function, not the block. So the second 'var x' declaration, which would normally be treated as a new local variable named x in the scope of the block, is simply treated as a reference to the var x declared at the start of the function. I'm sure there's an actual computer sciencey name for this behavior, but I just call it "stupid."

Lupos
May 26, 2006

DIRECT HIT!

Hello. New to this particular section. Inadvertantly posted this in the general "code" thread then I noticed this one.


Heres the deal. Made a function that draws a particular shape(a folder), to my size/loc specifications, whenever I want. Now I'm trying to make a function that moves and/or sizes it as need be(while keeping the tap the same size). the trick is I can't seem to get the name of it to pass. I assume this is some retarded "I should have put it in quotes" thing but no matter what I try I can't seem to get it to work.

Folder Creator:
code:
//tabs are 20 high and 100 wide
function folderMaker(num, wide, high, x_loc, y_loc, alpha, depth) {
	//import the bevel filter AS
	import flash.filters.BevelFilter;
	//create Bevel Filter paramaters for folder
	var bevel:BevelFilter = new BevelFilter(1, 45, 0xFFFFFF, 1, 0x000000, 1, 2, 2, 1, 3);
	//create movieclip
	var folder = createEmptyMovieClip("folder["+num+"]",num);
	folder.num = num;
	//draw shape
	with (folder) {
		//define line style
		lineStyle(.5, 0x000000, 100);
		//folder color = c1003e
		beginFill(0xc1003e);
		moveTo(x_loc/*200*/, y_loc+10/*200*/);
		curveTo(x_loc/*200*/, y_loc, x_loc+10, y_loc);
		lineTo(x_loc+70, y_loc);
		curveTo(x_loc+80, y_loc, x_loc+85, y_loc+10);
		curveTo(x_loc+90, y_loc+20, x_loc+100, y_loc+20);
		lineTo(x_loc+(wide-10), y_loc+20);
		curveTo((x_loc+(wide)), y_loc+20, x_loc+wide, y_loc+30);
		lineTo(x_loc+wide, y_loc+(high-10));
		curveTo(x_loc+wide, y_loc+high, x_loc+(wide-10), y_loc+high);
		lineTo(x_loc+10, y_loc+high);
		curveTo(x_loc, y_loc+high, x_loc, y_loc+(high-10));
		endFill();
	}
	folder.filters = [bevel];
	folder._alpha = alpha;
}

folderMaker(1, 150, 150, 200, 200, 90,1);
Folder Mover:
code:
import mx.transitions.Tween;
function folderMover(folderName,new_x,new_y,time){
	var myTween:Tween = new Tween(folderName, "_x", mx.transitions.easing.None.easeNone,0, Stage.width, 50, false);

}
And the button code:
code:
on(release){
	_level0.folderMover(_level0.folder[1],400,500,5);
}

Twon
Jan 30, 2002

Knight of Mars Beater of Ass

rotor posted:

no, that behavior is expected from an untyped language. Javascript does the same thing.

The weirdness is that the scope for the variable x is the function, not the block. So the second 'var x' declaration, which would normally be treated as a new local variable named x in the scope of the block, is simply treated as a reference to the var x declared at the start of the function. I'm sure there's an actual computer sciencey name for this behavior, but I just call it "stupid."

Whoa, ok, that is weird. I totally missed the second "var" -- but then again, I'd also expect the interpreter/JIT/whatever the hell it uses to bitch about the fact that you have a variable of the same name in an enclosing scope.

real_scud
Sep 5, 2002

One of these days these elbows are gonna walk all over you


Does anyone know why a flash video that I'm having displayed via swfobject looks fine in FF, but in IE7 the video isn't being stretched properly?

Here's a screenshot to show what's happening.


It looks to be something with the integration with swfobject but I haven't been able to find any reason why ff and IE would render the same file differently.

mantaworks
May 6, 2005

by Fragmaster


real_scud posted:

Does anyone know why a flash video that I'm having displayed via swfobject looks fine in FF, but in IE7 the video isn't being stretched properly?

It looks to be something with the integration with swfobject but I haven't been able to find any reason why ff and IE would render the same file differently.

The only difference where flash is concerned is the html in wich is resides. IE uses an embed element and all the rest uses an object element to place flash content inside a page. Or the other way around, I can never remember. So the only thing I can think of is that there's a difference with the values given to one.

StolenMerch
Sep 25, 2005



Here's one that should be easy for someone who knows what they're doing (not me). I've got an array of cards I want to shuffle but it doesn't seem to be random enough. I swear card 1 doesn't get shuffled all the time and remains as cards[0] in the array too frequently. It doesn't happen every time, but enough that it makes me suspicious. Am I screwing up that splice stuff?

code:
cards = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; //more cards, truncated for space here
Array.prototype.shuffle=function(){
  var len=this.length;
  for (l=0; l<len; l++) this.splice(random(this.length),0,this.splice(random(this.length), 1));
  };
cards.shuffle();
trace (cards);

mantaworks
May 6, 2005

by Fragmaster


StolenMerch posted:

Am I screwing up that splice stuff?

Probably. I ran your code a few times and repectively speaking, the number 1 appeared almost 3x and 2 appeared almost 2x as all the other numbers.

I don't know exactly why it did that, bit herer's code I know will give you correct results.

code:

Array.prototype.shuffle = function()
{
	var len = this.length;
	for (l = 0; l < len; l++)
	{
		var card = Math.floor(Math.random() * (len-l)); // a better random 
		this.push( this.splice(card, 1) );
	}
};

tally = [null];
rounds = 1000;
for (i = 0; i < rounds; i++)
{
	cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
	cards.shuffle();
	if( !tally[cards[0]] )	tally[cards[0]] = 1;
	else					tally[cards[0]]++;
}

trace("===");
var len = cards.length;
for(n = 1; len > n; n++)
{
	trace(n + ":\t" + (tally[n] / rounds) * 100 + "%\t(" + tally[n] + ")");
}

Adbot
ADBOT LOVES YOU

Dicky B
Mar 23, 2004



Here's a problem I've run into a bunch of times. Hopefully somebody can explain it to me:
code:
//Add objects
function add_object() {
    this.attachMovie("movieClip", "objects"+obj, depth);
    this["objects"+obj].speed = Math.random()*2;
    obj++;
    depth++;
}
// Move objects
function move_objects() {
    for (i=0; i<obj; i++) {
        this["objects"+i]._y+= this["objects"+i].speed;
    }
}
add_object places a movie clip on stage and gives it a unique name and speed. move_objects moves all the previously created objects at their individual speeds. Obviously when these functions get larger it's a good idea to use the 'with' action, like this:
code:
//Add objects
function add_object() {
    this.attachMovie("movieClip", "objects"+obj, depth);
    [b]with (this["objects"+obj]) {
        speed = Math.random()*2;
    }[/b]
    obj++;
    depth++;
}
// Move objects
function move_objects() {
    for (i=0; i<obj; i++) {
        [b]with (this["objects"+i]) {
            _y+= speed;
        }[/b]
    }
}
The problem with this code is that for some reason each time a new object is created it changes the speed of all the previously created objects rather than just its own. Here's the really confusing thing, though: using tellTarget works absolutely fine:
code:
//Add objects
function add_object() {
    this.attachMovie("movieClip", "objects"+obj, depth);
    [b]tellTarget ("objects"+obj) {
        speed = Math.random()*2;
    }[/b]
    obj++;
    depth++;
}
// Move objects
function move_objects() {
    for (i=0; i<obj; i++) {
        [b]tellTarget ("objects"+i) {
            _y-= speed;
        }[/b]
    }
}
I don't want to use tellTarget though because apparently it's slow and deprecated.

Can anybody tell me where I'm going wrong with the 'with' action?

Dicky B fucked around with this message at Mar 30, 2007 around 22:21

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply
«37 »