Labs

It works in my machine!

Archive for October, 2008

VerifyError: Error #1025 or Error from hell

with one comment

i was trying to read an XML with namespaces and then Flash throw me this weird error

VerifyError: Error #1025: An invalid register 3 was accessed

then we found that was beacuse of these lines (locally declared in a function)

1
2
var ns = ttXML.namespace();
default xml namespace = ns;

the error comes when you try to call some function after those lines in your code

the solution that we found was declare ns variable outside of the function
and then everything works fine =D

Written by Raúl

October 29th, 2008 at 7:44 pm

Posted in AS3

SoundItem Class

with one comment

well we start with this Sound Util, just embed the SoundTransform and SoundChannel in one single Class and the fade ability (uses Tween Lite)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.grupow.media 
{
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundLoaderContext;
	import flash.media.SoundTransform;
	import flash.net.URLRequest;
 
	import gs.TweenLite;
	import gs.easing.Linear;
 
	/**
	* ...
	* @author Raúl Uranga
	*/
	public class SoundItem extends Sound
	{
 
		private var _channel:SoundChannel
		private var _soundTransform:SoundTransform;
 
		public function SoundItem(stream:URLRequest = null,conext:SoundLoaderContext = null) {
 
			super(stream,conext);
 
			_soundTransform = new SoundTransform();
 
		}
 
		public function fade(volume:Number,ms:int = 1000,handler:Function = null):void
		{
			//
			if (volume < 0)
				volume = 0;
			//
			if (volume > 1)
				volume = 1;
			//	
			TweenLite.to(this, ms/1000, {volume:volume,ease:Linear.easeNone,onComplete:handler});
		}
 
		public override function play(startTime:Number = 0,loops:int = 0,sndTransform:SoundTransform = null):SoundChannel
		{
			if(sndTransform != null)
				_soundTransform = sndTransform; 
 
			_channel = super.play(startTime, loops, _soundTransform);
			return _channel;
		}
 
		public function stop():void
		{
			try {
				_channel.stop();
			}catch (e:*) {
				//trace("SoundItem Error: SoundChannel is not defined, you need to start playing");
			}
		}
 
 
		public function get volume():Number
		{ 
			return _soundTransform.volume;
		}
 
		public function set volume(value:Number):void 
		{
			_soundTransform.volume = value;
 
			try {
				_channel.soundTransform = _soundTransform;
			}catch (e:*) {
				//trace("SoundItem Error: SoundChannel is not defined, you need to start playing");
			}
		}
 
	}
}

code available at google code

cheers!

Written by Raúl

October 23rd, 2008 at 3:45 pm

Posted in AS3

Welcome!

with 3 comments

Hi everyone! we’re pleased to start labs.grupow, here you will find some code examples, tutorials and AS3 headaches!

cheers!

Written by Raúl

October 23rd, 2008 at 1:30 pm

Posted in General