A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: AS2 swf problem under AS3 swf (probably Tweener problem)

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    4

    AS2 swf problem under AS3 swf (probably Tweener problem)

    Hello. I have this problem for a days and it hasn't been soluted yet although I put it on couple of forums. I have 3 files: test.fla, file_as2, file_as3.

    The test.fla code:

    Code:
    var obj:Object = new Object();
    stage.addEventListener(KeyboardEvent.KEY_DOWN, hitKey);
    obj['sp'] = null;
    
    loader();
    
    function loader():void {
    
    	trace('I\'m loading swf...');
    	var sp:Sprite = new Sprite();
    	var ld:Loader = new Loader();
    	ld.load(new URLRequest('file_as3.swf'));
    	ld.contentLoaderInfo.addEventListener(Event.COMPLETE, comp);
    	addChild(sp);
    	sp.addChild(ld);
    	obj['sp'] = sp;
    	
    }
    
    function comp(e:Event):void {
    	trace('swf is loaded...');
    }
    
    function hitKey(e:KeyboardEvent):void {
    	
    	trace('I\'m deleting ' + obj['sp'] + '...');
    	
    	if (obj['sp'] != null) {
    		removeChild(obj['sp']);
    		obj['sp'] = null;
    	}
    	
    	trace('Previous object has a status: ' + obj['sp'] + '...');
    	
    	loader();
    	
    }
    The file_as2:code

    Code:
    for (var a:Number = 1; a <= 6; a++) {
    	
    	this['a' + a]._alpha = 0;
    	
    	caurina.transitions.Tweener.addTween(this['a' + a], {
    		delay:a/5,
    		time:.5,
    		_alpha:100,
    		transition:'linear'
    	});
    	
    }
    The file_as3 code:

    Code:
    import caurina.transitions.*;
    
    for (var a:Number = 1; a <= 6; a++) {
    	
    	this['a' + a].alpha = 0;
    	
    	Tweener.addTween(this['a' + a], {
    		delay:a/5,
    		time:.5,
    		alpha:1,
    		transition:'linear'
    	});
    	
    }
    The test.fla file is a typical Loader, which loads external swf files and shows them on the screen. After any key is pressed, the swf is deleted from the screen and loaded again.

    The file_as2 and file_as3 are the AS2 and AS3 compiled having a simple square animation (6 squares fading in from alpha 0 one by one) animated by caurina Tweener. If the file_as3 is compilated and loaded externally there is no problem (six sqares are fading in, after pressing any key the vanish and appear (loaded) again and again...). But if the swf as2 file is loaded, it shows the squares only once and after pressing any key and loading it again, it doesn't shows it at all.

    I guess it's Tweener problem, because when i trace it in AS2 file (onUpdate) it traces only at the beginning.
    How it's possible, that AS3 somehow stops all Tweeners in 2nd time loaded AS2 file?? How to fix it?? Sorry for my english, i left a link for these 3 files to find solution. Try it (test.swf) and then change path inside fla to load AS2 file... Thanks for any ideas.

    Link to download: http://www.filolozka.pl/zip/file.ZIP

  2. #2
    Junior Member
    Join Date
    Jul 2009
    Posts
    2

    same problem

    Ive just had to upgrade an AS2 holder to AS3 and have just bumped into the same problem, did you solve it?

    If I refresh the page it works fine, but if a navigate between AS2 swf's loaded into my AS3 holder the second and subsequent times I load up an AS2 file all the tweeners don't work.

    considering shifting all the tweeners to tweenlite.


    Tom

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Yes I solved it. Lots of people say, that it's enought ot put: this._lockroot = true in AS2 file but it's not true.

    If you want to load AS2 files with Tweener into AS3, you must put your AS2 file into a container, for example:

    file: as2.swf - have a as2 data with Tweener
    file: as2cont.swf - have a as2 loader, which loads as2.swf (cannot import any Tweener libs)
    file: as3.swf - loads as2cont.swf, which loads as2.swf

    Sorry for my english. Thats only solution, which I know.

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    2
    thanks vantooh,

    just setting the AS2 file to lockroot seems to have solved it for me, but maybe i haven't tested it enough

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Try to download the zip file from my 1-st post and put lockroot in 1st frame as2, compile it and run as3 file. You will notice, that it doesn't work =).

  6. #6
    Junior Member
    Join Date
    Aug 2011
    Posts
    1
    It's an old post, but it has saved my life!!!! Thanks to all of you, especially to Vantooh! I have searched this solution for days!!! Youuuuu rule!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center