dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: controlling dynamically loaded swf

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    24

    controlling dynamically loaded swf

    hi all

    i want to know how can i control loaded swf in flex2. what i have done is created 40 frames swf in flash 9 alpha and loaded in flex using Loader class.now i wanna control this loaded swfs timeline bt i dnt know hw to do this..Should i have to add this loaded swf into sprite or movieClip using their respective addChild method..

    regards
    sandeep

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You should be able to do it this way:

    PHP Code:
    var url1:URLRequest=new URLRequest('Child1.swf');
    var 
    myLoader:Loader = new Loader();
    myLoader.load (url1);
    var 
    myDispatcher:IEventDispatcher myLoader.contentLoaderInfo;
    myDispatcher.addEventListener (Event.COMPLETEcompleted);
    function 
    completed (e:Event)
    {
        var 
    loadedName:Object e.target.content;

    But nonetheless I transfer this thread to the NEW Flex2 forum
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    caithness massiv
    Join Date
    May 2000
    Location
    denver
    Posts
    1,672
    this is how i did it... but using Flash8 to create the clip. I'm sure there's a more elegant solution...

    First, make a single class to embed the asset:

    Code:
    package com.controls.myPackage
    {
    	import mx.core.MovieClipAsset;
    	
    	[Embed(source='../../../../assets/skins/skins.swf', symbol='mySymbolName')]
    	public class MyPlaceholder extends MovieClipAsset{}
    }
    Then, control that asset in a wrapper class as follows:

    Code:
    package com.controls.myPackage
    {
    	import flash.display.*;
     	import flash.events.*;
     	
     	import mx.core.UIComponent;
    
    	public class MyPlaceholderWrapper extends UIComponent
    	{
    		private var _sprite:Sprite;
    		private var _myPlaceholder:MyPlaceholder;
    		public function get myPlaceholder():MyPlaceholder{return _myPlaceholder}
    		
    		public function MyPlaceholderWrapper( ){}
    
    		public function rollOver():void
    		{
    		  _myPlaceholder.gotoAndPlay(76);
    		}
    		
    		public function rollOut():void
    		{
    		  _myPlaceholder.gotoAndPlay(84);	
    		}
    		
    		public function stop():void
    	        {
    	    	 _myPlaceholder.stop();
    	        }
    	    
    
    		override protected function createChildren():void
    		{
    			_sprite = new Sprite();
    			_sprite.useHandCursor = true;
    			_sprite.buttonMode = true;
    			
    			_myPlaceholder = new VideoPlaceholder();
    			
    				// add rollOver/rollOut actions
    				//_myPlaceholder.addFrameScript(1,addRollOvers);
    			
    				// add stop(); actions
    				_myPlaceholder.addFrameScript(75,stop); // initial animation
    				_myPlaceholder.addFrameScript(83,stop); // rollOver
    				//_myPlaceholder.addFrameScript(_myPlaceholder.totalFrames-1,stop); // rollOut
    			
    			_sprite.addChild(_myPlaceholder);
    			addChild(_sprite);
    		}
    		
    		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    	    {		    	
    	    	super.updateDisplayList(unscaledWidth, unscaledHeight);	    
    	    }
    	    
    	    
    	    public function restart():void
    	    {
    	    	_myPlaceholder.gotoAndPlay(1);
    	    }
    	}
    }

    Finally, use the component in MXML:

    Code:
    <ui:MyPlaceholderWrapper id="myPlaceholderWrapper"
      rollOver="myPlaceholderWrapper.rollOver();"
      rollOut="myPlaceholderWrapper.rollOut();"
    />

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    1

    Update regarding MovieClipAsset.gotoAndPlay

    Sandeep, I'm one of agent vivid's co-workers. We ran into an issue with MovieClipAsset.gotoAndPlay; there appears to be a bug with AS 3.0 in which specifying a frame number in the gotoAndPlay method causes it to execute gotoAndStop instead. Specifying a frame label instead seems to clear it up.

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