Results 1 to 4 of 4
  1. #1
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    75

    Question CLIK & AS3.0 errors when copy&pasting components from CLIK_Components_AS3.fla

    Hi, I started looking into CLIK components and ran into a problem:

    If I copy&paste some components such as DefaultTextArea from CLIK_Components_AS3.fla into my flash file and test it in the Scaleform player, I get the following error:
    Code:
    C:\...\Flash\AS3\CLIK\scaleform\clik\controls\TextArea.as, Line 1	5000: The class 'scaleform.clik.controls.TextArea' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.
    I noticed that the error goes away if in the document's ActionScript setting I untick the "Automatically declare stage instances" setting.

    BUT then if I change any of the Component Parameters (such as text, defaultText etc.) of the CLIK component (namedTextBox in this example) and test the movie, I get this:
    Code:
    Scene 1, Layer 'contentContainer', Frame 1	1120: Access of undefined property TextBox.
    Then again if in the 1st frame I go to the Actions and define the TextBox (var TextBox:DefaultTextArea;) it all works just fine. The thing is, that the CLIK_Components_AS3.fla does not do that and everything still works well in it!

    So, any idea what I'm doing wrong? Why doesn't it all just work like in CLIK_Components_AS3.fla? Any help would be greatly appreciated!

  2. #2

    Default

    For your first error, you are correct. You must disable Automatically Declare Stage Instances in the AS3 Publish Settings for the file.

    File->ActionScript Settings

    See the CLIK AS3 User Guide. Search User Guide for error number 1152.

    http://gameware.autodesk.com/documen...user_guide.pdf




    As for your second issue, I'm not sure what your issue is. Are you giving the textArea an instance name in the properties and trying to access it from code using this instance name?

    The standard way to do this is to give your textArea an instance name, say: myTextArea

    Then in code:

    Code:
    myTextArea.text = "12345";
    Last edited by Matt Doyle; 02-21-2012 at 02:04 PM.

  3. #3
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    75

    Default

    Thanks for the reply Matt.

    I've figured out a few things, but this is the main problem:

    We want to have one Flash file called JJHUD.swf, which in turn loads multiple flash files such as Inventory.swf, Puzzle.swf, Memo.swf and few couple others. In all of them we want to use CLIK components for buttons etc. I managed to load multiple SWF files using the Loader class, and switch between them, but as soon as I started adding CLIK components into them, I get all kinds lot of reference errors.

    How should I approach this setup?

    At the moment JJHUD.swf has JJHUD.as as it's Class in the document properties. Inside JJHUD.as it's extending the UIComponent class like this:
    Code:
    package
    {
    	import flash.display.MovieClip;
    	import flash.ui.Mouse; //To modify the normal mouse stuff, like hiding it
    	import flash.events.MouseEvent;
    	import flash.events.ProgressEvent;
    	import flash.events.IEventDispatcher;
    	import flash.display.Loader;
    	import flash.net.URLRequest;
    
    
    	import scaleform.gfx.Extensions; //To enable GFx Extensions
    	import flash.external.ExternalInterface; //To enable talking to Unreal code 
    	import flash.system.fscommand; //To Enable the HACK way of communicating with Unreal (for testing purposes)
    	
    	import scaleform.clik.core.UIComponent;
    	import scaleform.clik.events.ButtonEvent;
    	import scaleform.clik.constants.InvalidationType;
    	import scaleform.clik.controls.Button;
    
    	public dynamic class JJHUD extends UIComponent
    	{
    		/** Varibles */
    		public var _swfLoader:Loader;
    		public var _swfRequest:URLRequest;
    		 
    		public var _swfPathArr:Array = new Array("Dialogue/Dialogue.swf", "Inventory/Inventory.swf", "Puzzle/Puzzle.swf", "Hints/Hints.swf", "Memo/Memo.swf");
    		//public var _swfPathArr:Array = new Array("Puzzle/Puzzle.swf");
    		 
    		public var _swfClipsArr:Array = new Array();
    		public var _swfTempClip:MovieClip;
    		public var _loadedSWFs:int;
    
    
    		public var contentCont:MovieClip;
    		public var mouseCursor:MovieClip;
    
    		public var loadInventory:Button;
    		public var loadHints:Button;
    		public var loadMemo:Button;
    		public var loadPuzzle:Button;
    		public var loadDialogue:Button;
    		public var loadEmpty:Button;
    
    
    		/** Constructor */
    		public function JJHUD():void
    		{
    			super();
    		}
    
            override protected function configUI():void 
            {
                super.configUI();
    
    			// Hide the normal mouse cursor
    			Mouse.hide();
    
    			/* Start loading the external swf files */
    			startLoading(_swfPathArr);
    		}
    
            override protected function draw():void {
                super.draw();
            }
    
    
    		private function addListeners():void
    		{
    			// Update mouse cursor
    			stage.addEventListener( MouseEvent.MOUSE_MOVE, moveMouseCursor, false, 0, true );
    
    			// DEBUG:
    			stage.addEventListener(MouseEvent.MOUSE_DOWN, stageDown);
    			stage.addEventListener(MouseEvent.MOUSE_UP, stageUp);
    			stage.addEventListener(MouseEvent.MOUSE_OVER, stageOver);
    			stage.addEventListener(MouseEvent.MOUSE_OUT, stageOut);
    
    		    loadInventory.addEventListener(MouseEvent.CLICK, setContent);
    		    loadHints.addEventListener(MouseEvent.CLICK, setContent);
    		    loadMemo.addEventListener(MouseEvent.CLICK, setContent);
    		    loadPuzzle.addEventListener(MouseEvent.CLICK, setContent);
    		    loadDialogue.addEventListener(MouseEvent.CLICK, setContent);
    		    loadEmpty.addEventListener(MouseEvent.CLICK, setContent);
    		}
    
    		function startLoading(pathArr:Array):void {
    		    //_swfLoader = new Loader();
    		    _swfRequest = new URLRequest();
    		   
    		    loadSWF(pathArr[0]);
    		}
    
    		function loadSWF(path:String):void {
    		    _swfLoader = new Loader(); //<- needed to work in Scaleform
    		    setupListeners(_swfLoader.contentLoaderInfo);
    		   
    		    _swfRequest.url = path;
    		    _swfLoader.load(_swfRequest);
    		}
    		 
    		function setupListeners(dispatcher:IEventDispatcher):void {
    		    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    		    dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    		}
    		 
    		function currentSwfProgress(event:ProgressEvent):void {
    		    var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
    		    // swfPreloader.percentTF.text = _perc + "%";
    		}
    
    		function onSwfComplete(event:Event):void 
    		{
    		    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    		    event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
    
    		    _swfTempClip = event.target.content;
    		    //_swfTempClip.customID = _loadedSWFs;
    		 
    		    _swfClipsArr.push(_swfTempClip);
    
    		    if(_loadedSWFs <_swfPathArr.length - 1) {
    		        _loadedSWFs++;
    		        loadSWF(_swfPathArr[_loadedSWFs]);
    		    } else {
    		        onCompletePreloading();
    		    }
    		}
    
    		function onCompletePreloading():void {
    
    			trace("_swfClipsArr[0]: " + _swfClipsArr[0])
    		    contentCont.addChild(_swfClipsArr[0]);
    
    			/* Add listeners */
    			addListeners();
    		}
    		 
    		function setContent(event:MouseEvent):void {
    		    var _swfToAdd:MovieClip;
    
    
    			for (var j:uint = 0; j < _swfClipsArr.length; j++){
    		    	trace("_swfClipsArr[i]:" +_swfClipsArr[i].name);
    			}
    		   
    		    switch(event.target.name) 
    		    {
    
    		        case "loadDialogue":
    		        _swfToAdd = _swfClipsArr[0];
    		        break;
    
    		        case "loadInventory":
    		        _swfToAdd = _swfClipsArr[1];
    		        break;
    
    		        case "loadPuzzle":
    		        _swfToAdd = _swfClipsArr[2];
    		        break;
    		       
    		        case "loadHints":
    		        _swfToAdd = _swfClipsArr[3];
    		        break;
    		       
    		        case "loadMemo":
    		        _swfToAdd = _swfClipsArr[4];
    		        break;
    
    		        case "loadEmpty":
    		        _swfToAdd = _swfClipsArr[0];
    		        break;
    
    
    		    }
    		   
    		    contentCont.removeChildAt(contentCont.numChildren-1);
    		    contentCont.addChild(_swfToAdd);
    		    trace(_swfToAdd.customID);
    
    			for (var i:uint = 0; i < contentCont.numChildren; i++){
    		    	trace("contentcont: "+contentCont.getChildAt(i).name);
    			}
    		}
    
    
    
    		//*******************
    		// MOUSE CURSOR MOVEMENT
    		//*******************
    		private function moveMouseCursor( e:MouseEvent ):void 
    		{
    			mouseCursor.x = e.stageX;
    			mouseCursor.y = e.stageY;
    		}
    
    
    
    		//*******************
    		// STAGE EVENTS
    		//*******************
    		function stageDown(e:MouseEvent) : void
    		{
    			trace("--Stage down at: " +mouseX +" / " +mouseY);
    			trace("  target: " +e.target + " target.name: " + e.target.name);
    		}
    
    		function stageUp(e:MouseEvent) : void
    		{
    			trace("--Stage up at: " +mouseX +" / " +mouseY + " obj: " + e.relatedObject);
    			trace("  target: " +e.target + " target.name: " + e.target.name);
    		}
    
    		function stageOver(e:MouseEvent) : void
    		{
    			trace("--Stage over at: " +mouseX +" / " +mouseY + " obj: " + e.relatedObject);
    			trace("  target: " +e.target + " target.name: " + e.target.name);
    		}
    		function stageOut(e:MouseEvent) : void
    		{
    			trace("--Stage out at: " +mouseX +" / " +mouseY + " obj: " + e.relatedObject);
    			trace("  target: " +e.target + " target.name: " + e.target.name);
    		}
    
    	} // End Class
    
    } // End Package
    Apart from the Puzzle/Puzzle.swf, the other files don't have any CLIK components and work well (their classes extending from MovieClip). The Puzzle.swf's class is Puzzle.as, which like JJHUD extends from UIComponent. In the Puzzle.fla the only object in it is a button with instance name of continueBtn.
    Code:
    package  {
    	
    	import flash.display.MovieClip;
    	import flash.events.Event;
    	import flash.events.MouseEvent;
    
    	import scaleform.clik.core.UIComponent;
    	import scaleform.clik.events.ButtonEvent;
    	import scaleform.clik.constants.InvalidationType;
    	import scaleform.clik.controls.Button;
    	
    	
    	public dynamic class Puzzle extends UIComponent 
    	{
    		/* Vars from the scene */
    		//public var puzzleNumberLabel:DefaultLabel;
    		//public var puzzleNameLabel:DefaultLabel;
    		//public var puzzleMeritsLabel:DefaultLabel;
    
    		//public var contentContainer:MovieClip;
    		//public var myTextField:DefaultTextArea;
    		public var continueBtn:Button;
    
    		//public var customID:String;
    		
    
    
    		public function Puzzle() 
    		{
    			// constructor code
    			super();
    		}
    
    		override protected function configUI():void 
    		{
    			super.configUI();
    			//Set up stuff like names:
    			//continueBtn.label = "Start Puzzle";
    
    			//Call for listeners to be added:
    			addListeners();
    		}
    
    		override protected function draw():void {
    			super.draw();
    		}
    
    		private function addListeners()
    		{
    			//continueBtn.addEventListener(MouseEvent.MOUSE_UP, handleContinueBtn);
    		}
    
    		private function handleContinueBtn()
    		{
    			if(this.currentLabel == "StartSlide")
    			{
    				gotoAndStop(5);
    				//continueBtn.label = "Finish Puzzle";
    			} else if(this.currentLabel == "PuzzleContent")
    			{
    				gotoAndStop(10);
    				//continueBtn.label = "Close Puzzle";
    			} else if(this.currentLabel == "EndSlide")
    			{
    				gotoAndStop(1);
    				//continueBtn.label = "StartSlide";
    			}
    		}
    	}
    	
    }
    Alone, the Puzzle.swf works fine. But when I try to run the JJHUD in the Scaleform player, I get this:
    Code:
    Error: TypeError: Error #1009: Cannot access a property of null object reference.
    at Puzzle/__setProp_continueBtn_Scene_baka_0()
    at Puzzle instance constructor()
    And yes, the Puzzle.swf has a Button with instance name of continueBtn in it's frame 1 (on layer baka).

    Funny thing, just 'till moment ago I got another error as well about not being able to create object called contentContainer in the Puzzle, which is an object I had deleted ages ago and commented out the definition as well. Somehow the linking seems to be a bit broken as well.

    But yes, any help with setting up a system like this would be massively welcomed!

  4. #4
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    75

    Default

    OK, after seeing the linking problem while typing my last post, I decided to create a new flash file NewPuzzle.swf from scratch, put a CLIK button in it, and load that in JJHUD...

    Well, it all works!

    Which is rather odd since the NewPuzzle.swf is pretty much identical to the Puzzle.swf which did not work.

    I think somehow along the way the linking of files had somehow broken. This is not really the 1st time when recreating a flash file has solved a problem.

    Is there any way to avoid this? Somehow force the links to be redone? It'd be quite horrible if I had no way of knowing if the error was "real" or caused by these mysterious linking errors..


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.