import flash.events.*;
import flash.display.*;
var origX:Number;
var origY:Number;
var target:DisplayObject;
var matchNum:uint;
redClick.buttonMode = true;
blueClick.buttonMode = true;
yellowClick.buttonMode = true;
redClick.addEventListener(MouseEvent.MOUSE_DOWN, redDrag);
function redDrag(event:MouseEvent):void
{
redClick.origX = redClick.x;
redClick.origY = redClick.y;
blueClick.origX = blueClick.x;
blueClick.origY = blueClick.y;
yellowClick.origX = yellowClick.x;
yellowClick.origY = yellowClick.y;
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
redClick.startDrag();
stage.addChild(this);
}
blueClick.addEventListener(MouseEvent.MOUSE_DOWN, blueDrag);
function blueDrag(event:MouseEvent):void
{
redClick.origX = redClick.x;
redClick.origY = redClick.y;
blueClick.origX = blueClick.x;
blueClick.origY = blueClick.y;
yellowClick.origX = yellowClick.x;
yellowClick.origY = yellowClick.y;
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
blueClick.startDrag();
stage.addChild(this);
}
yellowClick.addEventListener(MouseEvent.MOUSE_DOWN, yellowDrag);
function yellowDrag(event:MouseEvent):void
{
redClick.origX = redClick.x;
redClick.origY = redClick.y;
blueClick.origX = blueClick.x;
blueClick.origY = blueClick.y;
yellowClick.origX = yellowClick.x;
yellowClick.origY = yellowClick.y;
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
yellowClick.startDrag();
stage.addChild(this);
}
function drop(event:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_UP, drop);
stopDrag();
if (redClick.hitTestObject(redDrop))
{
redClick.visible = false;
redDrop.alpha = 1;
matchNum++;
}
if (blueClick.hitTestObject(blueDrop))
{
blueClick.visible = false;
blueDrop.alpha = 1;
matchNum++;
}
if (yellowClick.hitTestObject(yellowDrop))
{
yellowClick.visible = false;
yellowDrop.alpha = 1;
matchNum++;
}
redClick.x = redClick.origX;
redClick.y = redClick.origY;
blueClick.x = blueClick.origX;
blueClick.y = blueClick.origY;
yellowClick.x = yellowClick.origX;
yellowClick.y = yellowClick.origY;
if (matchNum > 2)
{
MovieClip(parent).gotoAndStop(2);
}
}
stop();
Updated:
Now I am recieving this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip
From this class:
package com.George.MegaAmazingApp.Components
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.MouseEvent;
public class Wheel extends MovieClip
{
public function Wheel(area:MovieClip, diagram:MovieClip)
{
area.addEventListener(MouseEvent.CLICK, clickHandler);
}
private function clickHandler(event:MouseEvent):void
{
trace("wheel clicked");
trace("this is diagram");
}
}
}
and this script:
import com.George.MegaAmazingApp.Components.*;
var wheel:Wheel = new Wheel(this.wheel,this.car);
Debug gives:
Attempting to launch and connect to Player using URL C:/Documents and Settings/reithg/My Documents/Classes/com/GeorgesMegaAmazingApp-app.xml
[SWF] GeorgesMegaAmazingApp.swf - 51681 bytes after decompression
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2968e51 to com.George.MegaAmazingApp.Components.Wheel.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at GeorgesMegaAmazingApp_fla::MainTimeline()
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
GeorgesMegaAmazingApp-app.xml doesn’t exist in that directory but I don’t know why it is looking there anyway, it is not where the fla is located.
asked Sep 19, 2011 at 12:10
George ReithGeorge Reith
13k18 gold badges78 silver badges145 bronze badges
3
Either this.wheel
or this.car
is not a MovieClip
. Also could you turn on debugging in File > Publish Settings? You’ll then get better error messages because, without more information, your error could be just about anywhere.
Edit:
Try renaming var wheel
to something else because it seems that Flash is confused with your two wheel objects. For example, try:
var wheelObject:Wheel = new Wheel(this.wheel,this.car);
answered Sep 19, 2011 at 12:27
laurentlaurent
86.6k75 gold badges283 silver badges420 bronze badges
3
Is Wheel.as in the directory com/George/MegaAmazingApp/Components? (case-sensitive)
Is that ‘com’ directory in a source path directory?
answered Sep 19, 2011 at 12:16
Peter HallPeter Hall
49.4k12 gold badges122 silver badges193 bronze badges
2
Hi again,
I’m running the 6.0 SDK and am attempting to use the HTML bridge (verbatim plugin.xml action to the HTML samples) but I keep getting this error message when I navigate to the plugin’s objects view. Any ideas why I’d be hitting this error on a 5.5 vCenter? I don’t see this error on 6.0 vCenters and I don’t see this error if I remove the ActionSpec that uses the className com.vmware.vsphere.client.htmlbridge.HtmlActionDelegate.
Any pointers appreciated! If needed I can try bundling up a sample app to reproduce.
Error Stack
———————
TypeError: Error #1034: Type Coercion failed: cannot convert SvtModule@23ef34a31851 to com.vmware.common.interfaces.prioritization.IPrioritizableItem.
at com.vmware.vsphere.client.prioritization::PrioritizedItemTransformer/transform()
at ObjectsCreator/onObjectCreated()
at com.vmware.extensionfw::CallbackUtil$/callback()
at com.vmware.extensionfw::ExtensionObjectParser/onObjectDeserialized()
at com.vmware.flexutil::MxmlDeserializer/onThreadTerminated()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.vmware.flexutil::PseudoThread/terminate()
at com.vmware.flexutil::PseudoThread/onTimer()
at com.vmware.flexutil::PseudoThread/start()
at com.vmware.flexutil::MxmlDeserializer/xmlToObjectAsync()
at com.vmware.extensionfw::ExtensionObjectParser/parse()
at ObjectsCreator/onResourceModulesLoaded()
at com.vmware.flexutil::ResourceLoader/onModuleLoad()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ResourceEventDispatcher/moduleInfo_readyHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfoProxy/moduleEventHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ModuleInfo/readyHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::FlexModuleFactory/update()
at mx.core::FlexModuleFactory/docFrameHandler()
at mx.core::FlexModuleFactory/docFrameListener()
Hi guys,
I’m trying to compile an AIR 3.4 app under FlashDevelop but as soon as I instanciate a Shape I get this error:
as3[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert to starling.display.shaders.IShader.
Do you think it can be fixed?
Thank yo for your great work. It helps a lot!
Regards
Do you get the same error after compiling your code with the latest stable Flex SDK (4.6 I believe)?
Yes, I compile with Flex SDK 4.6, AIR 3.4, ASC 2.0 preview 2, FlashDevelop
The version of the SDK you’re using (the ASC 2.0 ‘preview’) is still in beta, and I’d be interested in knowing if you get the same problem on an old ‘stable’ version of the SDK
What I mean by ‘stable’ is a version of the SDK not from labs.adobe.com. I.e
http://sourceforge.net/adobe/flexsdk/wiki/Download%20Flex%204.6/
I’ll see if I can reproduce your problem by compiling against the preview SDK as soon as I can — but you may be able to work around this problem in the meantime by simply using an older SDK.
I can compile with the latest 4.7 Beta2 drop from labs.adobe.com.
I’ve also been able to successfully compile with the latest beta SDK.
@13Flo — Are you still experiencing problems? If so, could you provide me with a more detailed repro case?
Hi Jonathan,
Sorry for the late reply.
Here’s what I did:
- downloaded the SDK on Sourceforge (http://sourceforge.net/adobe/flexsdk/wiki/Download%20Flex%204.6/)
- overlayed AIR 3.4
- followed this (french) tutorial enabling FlashDevelop 4.0.4 to compile with ASC 2.0 p3 (http://www.pureas3.org/fr/le-nouveau-compilateur-as3-asc-2-0-sous-flashdevelop) by using a modified fdbuild.exe [That might be the issue I guess].
The AS3 code:
square = new Shape();
square.graphics.beginFill( 0xFF0000 );
square.graphics.drawRect( 0, 0, 10, 10 );
square.graphics.endFill();
addChild( square );
Runtime error:
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert to starling.display.shaders.IShader.
I’ll try to find some time to try with FlashBuilder but if you guys can compile with the 4.7 beta, I guess that might be the issue.
What do you think?
Same error here (with similar as3 code): I’m using Flash Builder 4.7 with stable Flex SDK 4.6 and AIR 3.5 overlay.
Are there some news or solutions from your side ?
TypeError: Error #1034: Type Coercion failed: cannot convert to starling.display.shaders.IShader.
at starling.display.materials::StandardMaterial()[/Users/valley/Development/flex/Starling-Extension-Graphics/extension/src/starling/display/materials/StandardMaterial.as:31]
at starling.display.graphics::Graphic()[/Users/valley/Development/flex/Starling-Extension-Graphics/extension/src/starling/display/graphics/Graphic.as:46]
at starling.display.graphics::Fill()[/Users/valley/Development/flex/Starling-Extension-Graphics/extension/src/starling/display/graphics/Fill.as:0]
at starling.display::Graphics/beginFill()[/Users/valley/Development/flex/Starling-Extension-Graphics/extension/src/starling/display/Graphics.as:61]
Hey guys — afraid I’m still having no luck repro-ing this. I’ve got FB 4.7 beta running — and I’ve overlayed the AIR 3.5 SDK (boy — that was a pain — this came in handy http://forums.adobe.com/message/4734285)
All the extension examples are compiling and running fine with this setup.
Could you let me know if you’re able to compile the examples ok?
If you’re still having trouble, I’d be interested in getting a copy of the project folder — you can pm me at ‘jonathanrpace at hotmail dot com’
Jonathan,
I actually encountered at one point the same problem. Trying to think back on what caused it and how I worked around it: I was forced to used the source for Starling instead of the swc because of Feathers using the latest Starling codebase. I think this started the issue for the Starling Graphics Extension as described above. I think what I did to solve it was stop using the extension swc and use the src (overlaid it in the Starling source). So it could be something in the way your swc is compiled that causes issues in FB 4.7/AIR 3.5. Sorry I am a bit fuzzy in my recollections.
On 2012-11-18, at 9:21 AM, Jonathan Pace notifications@github.com wrote:
Hey guys — afraid I’m still having no luck repro-ing this. I’ve got FB 4.7 beta running — and I’ve overlayed the AIR 3.5 SDK (boy — that was a pain — this came in handy http://forums.adobe.com/message/4734285)
All the extension examples are compiling and running fine with this setup.
Could you let me know if you’re able to compile the examples ok?
If you’re still having trouble, I’d be interested in getting a copy of the project folder — you can pm me at ‘jonathanrpace at hotmail dot com’
—
Reply to this email directly or view it on GitHub.
Ok this is how i run it (and get the mentioned error above):
-
Downloaded Flex SDK 4.6 and AIR 3.5 in that bundle: http://www.swfgeek.net/2012/11/07/combined-version-of-the-flex-4-6-and-air-3-5-sdk-for-the-lazy-ones/
-
Using the very latest sources (not swc) of Starling and Starling-Extension-Graphics and name that separatedly as source path in Flash Builder 4.7 beta.
So everything seems to be up to date.
When i try running e.g. the 02_Dynamic_Fill_Example project (either mobile or desktop) gives the same error.
I’m getting the same error message. Trying to compile using Flash Builder 4.7 beta using AIR SDK 3.4. Importing Starling and Starling Graphics Extension full source not swc.
getting error: «TypeError: Error #1034: Type Coercion failed: cannot convert to starling.display.shaders.IShader.»
Works fine in FlashDevelop using AIR SDK 3.2
After digging around a little I was actually able to get it working. I changed lines 31 and 32 of display.materials.StandardMaterial from this:
this.vertexShader = vertexShader || new StandardVertexShader();
this.fragmentShader = fragmentShader || new VertexColorFragmentShader();
to this:
this.vertexShader = vertexShader || IShader(new StandardVertexShader());
this.fragmentShader = fragmentShader || IShader(new VertexColorFragmentShader());
No idea why the latest AIR SDK in FlashBuilder couldn’t implicitly cast these and an older SDK in flashdevelop could. Seems rather bizarre to me but this change is making it work with no problems now.
Very interesting . . . . and strange! My hunch is that the new ASC compiler is having a problem resolving dependencies that mxmlc didn’t — maybe a circular dependency?
Hopefully this fix will work for most people in the meantime — I don’t plan on merging it into the main branch ( I don’t particularly want to introduce a potentially costly cast each time a material is created ).
Once the SDK is out of beta I’ll give it another test — but for now I’m going to concentrate on other things.
Thanks Andy.
Works fine in my project now.
Thank you Andy!
Thanks guys, I believe this is the bug we’ve been tracking as #3331259 — the issue is that ASC 2 has to emit additional coerce instructions under certain circumstances to appease the runtime’s verifier. Forcing these coercions with casts is a workaround, though we believe we have fixed this and will distribute it in ASC 2.0 Preview 4 due to appear on Adobe Labs very soon.
I can confirm this is now compiling and running correctly using release version of AIR 3.6 SDK
Hello all,
I am new to flex, and Flash builder, I followed the tutorial in this link: https://developers.arcgis.com/flex/guide/tutorial-query-your-data.htm to write a mobile mapping application that includes a query task, after writing the code, no errors appeared in the problems tab but there was 6 warnings, and when running the app the following error appears (Also shown in screenshots):
An ActionScript error has occurred:
TypeError: Error #1034: Type Coercion failed: cannot convert views::AGISHomeView@6396ae1 to spark.components.View.
at spark.components::ViewNavigator/createViewInstance()
at spark.components::ViewNavigator/commitNavigatorAction()
at spark.components::ViewNavigator/commitProperties()
at mx.core::UIComponent/validateProperties()
at mx.managers::LayoutManager/validateProperties()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()
Any kind of help is appreciated.
Hani,
___________________________________________________________________________________________________________
Screenshots:
1- Warnings:
2- Error:
__________________________________________________________________________________________________________
Here is the code I used:
<?xml version=»1.0″ encoding=»utf-8″?>
<s:Application xmlns:fx=»http://ns.adobe.com/mxml/2009»
xmlns:s=»library://ns.adobe.com/flex/spark«
xmlns:mx=»library://ns.adobe.com/flex/mx«
xmlns=»http://ns.adobe.com/air/application/4.6«
xmlns:esri=»http://www.esri.com/2008/ags«>
<s:layout>
<s:VerticalLayout gap=»10«
horizontalAlign=»center«
paddingBottom=»20«
paddingLeft=»25«
paddingRight=»25«
paddingTop=»20«/>
</s:layout>
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
private function doQuery():void
{
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = nullvoid
{
// No code needed in this simple sample, since the
// graphics layer is bound to the query result using
// graphicProvider=»{queryTask.executeLastResult.features}»
}
function onFault(info:Object, token:Object = nullvoid
{
Alert.show(info.toString(), «Query Problem»);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!— Layer with US States —>
<esri:QueryTask id=»queryTask«
showBusyCursor=»true«
url=»http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5«
useAMF=»false«/>
<esri:Query id=»query«
outSpatialReference=»{myMap.spatialReference}«
returnGeometry=»true«
text=»{qText.text}«>
<esri:outFields>
<fx:String>MED_AGE</fx:String>
<fx:String>POP2007</fx:String>
</esri:outFields>
</esri:Query>
</fx:Declarations>
<s:Panel height=»60»
backgroundColor=»0xB2BFC6«
title=»Query a layer (search for a state)«>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:TextInput id=»qText«
width=»100%«
enter=»doQuery()»
text=»California«/>
<s:Button click=»doQuery()» label=»Do Query«/>
</s:Panel>
<esri:Map id=»myMap«>
<esri:extent>
<esri:Extent xmin=»-14298000» ymin=»2748000» xmax=»-6815000» ymax=»7117000«>
<esri:SpatialReference wkid=»102100«/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer
url=»http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer«/>
</esri:Map>
</s:Application>
_______________________________________________________________
Skip to content
Problem:
Something is receiving the wrong data type and it cannot be converted. For example, a function is expecting a string and we pass it an Array.
This also occurred in when I was passing an Array to a function that expected another data type.
The error detail is “cannot convert []@e1f73f9 mx.core.IUIComponent.”
NOTICE – The value I am passing to the “target” property is an Array because the value is enclosed in brackets “[myvalue]”. This would work if the property was “targets”. The property “target” expects an object.
// INCORRECT // CORRECT - Notice I removed the Array brackets
In this next example, an XMLList cannot be converted into an Array, which is what this component needs.
The error details is “cannot convert XMLList@37ace21 to Class.”
public function tabBarHandler(event:ItemClickEvent):void { var menuitems:XML = event.item.menuitems as XML; // this converts an xml list into a array collection but the tab bar cannot accept an xmllist data type // you *CAN* use this method if your data provider can accept an ArrayCollection //var menuDP:ArrayCollection = new ArrayCollection(new XMLListCollection(event.item.menuitems.submenu as XMLList).toArray()); // in our case since we *CANNOT* we manually convert it to an array and then add it to the tabbar for each (var menuitem:XML in menuitems.submenu) { // create a new object and assign the properties to it from the xml node var newItem:Object = new Object(); newItem.label = menuitem.@label; newItem.link = menuitem.@link; // optionally create a reference to the original xmlnode newItem.menuitem = menuitem; // add item to the array collection menuDP.addItem(newItem); trace(menuitem.@label); } // add new menuDP array collection to our tab bar subMenuBar.dataProvider = menuDP; }
Please reply in the comments below if this helped you or not. You can also use the Error Lookup Tool to look up Flex compiler or runtime errors. more info…
If a parent SWF loads two child SWFs that do AMF deserialization, and the child SWFs are deserializing a class that isn’t present in the parent SWF, one of the children will receive a Type Coercion error.
Steps to reproduce:
1. Load the attached projects into Flash Builder.
2. Run the Parent application, which loads two instances of the Child application.
Actual Results:
A Type Coercion error will occur.
Expected Results:
Deserialization should be successful. If you uncomment the registerClassAlias call in Child.mxml, there will be no error. Currently, [RemoteClass] generates code like this:
try {
if (flash.net.getClassByAlias(«flex.messaging.io.ArrayCollection») == null)
{
flash.net.registerClassAlias(«flex.messaging.io.ArrayCollection», mx.collections.ArrayCollection);}
} catch (e:Error) {
flash.net.registerClassAlias(«flex.messaging.io.ArrayCollection», mx.collections.ArrayCollection); }
In Flash Player 10.1, the test will fail in the second Child loaded and registerClassAlias will not be called as it should be. The simplest code change to achieve the correct effect would be to change the condition just slightly:
try {
if (flash.net.getClassByAlias(«flex.messaging.io.ArrayCollection») != mx.collections.ArrayCollection){ flash.net.registerClassAlias(«flex.messaging.io.ArrayCollection», mx.collections.ArrayCollection);}
} catch (e:Error)
{
flash.net.registerClassAlias(«flex.messaging.io.ArrayCollection», mx.collections.ArrayCollection); }
Note the change in the initial condition. Simply doing
flash.net.registerClassAlias(«flex.messaging.io.ArrayCollection», mx.collections.ArrayCollection);
achieves the same net result in notably less code.
Workaround (if any):
Manually calling registerClassAlias on all classes that have [RemoteClass] metadata is our current workaround. It is very error-prone, however, because the Flex SDK and other libraries have classes with [RemoteClass] and we have to manually register all of them too.