Redoing the player in Flash

Discuss topics that are unrelated to Ace Attorney Online, introduce yourself if you're new and read the latest Member of the Month interview.

Moderators: EN - Assistant Moderators, EN - Forum Moderators

User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

Oh, I would like to do that. But I don't have the time to do it alone. And I simply can't draw.
Currently working on a redesign of Court-records.net.
User avatar
Singapore123
Posts: 2085
Joined: Wed May 05, 2010 8:56 am
Gender: Male
Spoken languages: English, 1337, french, spanish,

Re: Redoing the player in Flash

Post by Singapore123 »

I mean that you just make a template WITH NO characters or story board. You can do you own design because it Unas choice for the design. Just show us a script or something.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

A script or something? That's incredibly vague. What the player would have to do is mostly showing and hiding objects in response to the game script. Load some images, easy. Run a bitmap animation? Now that is something I can post.

Code: Select all

package {
	
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;	
	import flash.utils.*;
	
	public class SpriteAnimator extends Sprite {
		
		var bitmaps:Dictionary;
		
		var loader:Loader;
		var loading:SpritePicture;
		var loadQueue:Vector.<SpritePicture>;
		
		var picture:Bitmap;
		var frame:int;
		var frameDelay:uint;
		
		var runAnim:SpriteAnimation;
		var animation:SpriteAnimation;
		
		public function SpriteAnimator() {
			
			bitmaps=new Dictionary(true);
			
			loadQueue=new Vector.<SpritePicture>();
			
			var animFrames:Vector.<SpriteFrame>=new Vector.<SpriteFrame>();
			
			for(var i:uint=1;i<=10;++i) {
				loadQueue.push(
					new SpritePicture(
						new URLRequest(
							i+".png"
						),
						i
					)
				);
			}
			
			animFrames.push(new SpriteFrame(1,3,-1,-3));//0
			animFrames.push(new SpriteFrame(2,3, 0,-2));//1
			animFrames.push(new SpriteFrame(3,3, 0, 0));//2
			animFrames.push(new SpriteFrame(4,3,-2, 0));//3
			animFrames.push(new SpriteFrame(5,3, 0,-3));//4
			animFrames.push(new SpriteFrame(6,3, 0,-2));//5
			animFrames.push(new SpriteFrame(7,3, 0, 0));//6
			animFrames.push(new SpriteFrame(8,3,-1,-1));//7
			animFrames.push(new SpriteFrame(9,3,-1,-1));//8
			
			runAnim=new SpriteAnimation(animFrames,0);
			
			picture=new Bitmap();
			scaleX=scaleY=3;
			addChild(picture);
			
			processQueue();
		}
		
		private function processQueue():void {
			loading=loadQueue.pop();
			loader=new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
			loader.load(loading.request);
		}
		
		private function loaded(e:Event):void {
			bitmaps[loading.id]=Bitmap(loader.content).bitmapData;
			
			loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loaded);
			
			if(loadQueue.length>0) {
				processQueue();
			} else {
				startAnimation(runAnim);
			}
		}
		
		private function startAnimation(a:SpriteAnimation):void {
			frame=-1;
			frameDelay=1;
			animation=a;
			addEventListener(Event.ENTER_FRAME,eFrame);
			//stage.addEventListener("click",eFrame);
			tick();
		}
		
		private function eFrame (e:Event):void {
			frameDelay=1;
			tick();
		}
		
		private function tick():void {
			
			if(--frameDelay==0) {
				++frame;
				if(frame>=animation.cycle.length) {
					if(animation.loopPoint==-1) {
						removeEventListener(Event.ENTER_FRAME,eFrame);
					} else {
						frame=animation.loopPoint;
					}
				}
			
			
				var spriteFrame=animation.cycle[frame];
				picture.bitmapData=bitmaps[spriteFrame.id];
				picture.x=spriteFrame.xOffset;
				picture.y=spriteFrame.yOffset;
				
				
				
				frameDelay=spriteFrame.delay;
				
				trace(frame);
			}
			
		}
	}
	
}
Currently working on a redesign of Court-records.net.
User avatar
Singapore123
Posts: 2085
Joined: Wed May 05, 2010 8:56 am
Gender: Male
Spoken languages: English, 1337, french, spanish,

Re: Redoing the player in Flash

Post by Singapore123 »

O....K.......




(WHO CAN'T UNDERSTAND THAT!?)
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

It is quite simple:
  • Load the images
  • Each frame, check if the current image should be used, if so, decrement a counter
  • If the counter reaches zero, show the next image and reset the counter
  • If there is no next image, go back to the loop point if there is any
  • If there is no loop point, stop the animation
Currently working on a redesign of Court-records.net.
User avatar
Singapore123
Posts: 2085
Joined: Wed May 05, 2010 8:56 am
Gender: Male
Spoken languages: English, 1337, french, spanish,

Re: Redoing the player in Flash

Post by Singapore123 »

OK.....


I'm like this: :random: right now.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Redoing the player in Flash

Post by Meph »

Danielinhoni wrote:But... What are the features that Canvas has, that Flash Player hasn't? (POsitive features)
Canvas can do anything via script, whereas Flash can only do Flash content.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

Name one thing that you think that Flash can not do that Canvas can. Or maybe I should start by introducing something that canvas doesn't do? Audio! The canvas element has no audio support what so ever.
Currently working on a redesign of Court-records.net.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Redoing the player in Flash

Post by Meph »

henke37 wrote:The canvas element has no audio support what so ever.
Because it doesn't need audio support, because the audio element can do it.

I'll give you something that the Flash Player can do that canvas can't: crash.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

That is because you are comparing an implementation with a technology. If you do a correct comparison, you will find that both the flash player and various browsers implementing the canvas element can crash.
Currently working on a redesign of Court-records.net.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Redoing the player in Flash

Post by Meph »

Amusing that it is a good browser, the script engine can crash, but not the canvas element itself. The browser won't lose performance.

But you're right. That's a bad argument. :P

As good argument is that Canvas is open source, can be changed to use any context (so Adobe could make their own if they wanted to), and can more easily interact with JavaScript on the page.

In 10 years time, Canvas will most likely be more widely used.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

No one is ever going to make their own context. There is nothing to gain from it.

While you do have a point in that the canvas element having easy javascript access, I strongly reject the claim that flash is harder to interact with. Just look at this example Besides, with the full player in Flash, the point is irrelevant.

As for open source, it is overrated. And the Flash compiler is open source. And parts of the player uses open source code too. No, it is not the full player, but honestly, no one cares.

And canvas being the most used of them? Ha. Just ha.

Btw, the whole prototype system in JavaScript should be tossed in the garbage can. It is a disadvantage that Flash actually kept it in the new vm. And even then, it is just for compatibility, compatibility with nothing.
Currently working on a redesign of Court-records.net.
User avatar
Nevfx
Posts: 693
Joined: Sun Jun 13, 2010 5:08 pm
Gender: Male
Spoken languages: English

Re: Redoing the player in Flash

Post by Nevfx »

All these potential changes... but is the way we use the Trial Maker still the same? As in, we just have to pick a background, profile put int he text etc? We wont have to do all that script stuff... will we?
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Redoing the player in Flash

Post by Meph »

Nevfx wrote:All these potential changes... but is the way we use the Trial Maker still the same? As in, we just have to pick a background, profile put int he text etc? We wont have to do all that script stuff... will we?
Yes. ;) It's just a backend change that allows for better improvements.
henke37 wrote:As for open source, it is overrated.
I could just as much argue that Flash is over-rated. ;) That point is irrelevant.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Redoing the player in Flash

Post by henke37 »

The editor can indeed be done in javascript. It works fine as it is. I have ideas, but there is no need to replace the editor, it is fine.
Currently working on a redesign of Court-records.net.
Post Reply