I can show a swf into flash simply with this code
var request:URLRequest = new URLRequest("myswf.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
But with import > import to stage there is no any swf when ctrl+enter.
There is only 5-6 empty frame in timeline. How can I solve this problem??
Another question, how can I do this with as 2.0 (im not familiar with as 2.0). This code not working :
loadMovie("myswf.swf");
Thanks in advance
Loader() and addChild() are both AS3, so won't work in AS2.
loadMovie() is a movieClip method, so it needs a movieClip instance to operate on:
myMovieClip.loadMovie("myswf.swf");
To load your swf into the main timeline, try:
this.loadMovie("myswf.swf");
Related
I'm trying to understand how to make Cocos Studio exported scenes run inside cocos2d js project. seems like there is no documentation at all.
I tried to instantiate scene object in different ways
var scene = ccs.csLoader.createNode("res/MainScene.json");
// or
var scene = cc.load("res/MainScene.json");
//res/MainScene.json is declared in resources 100%
but scene variable always contains empty objects (node and action).
I debugged load and createNode methods with step into feature and found that there is no proper parsers for scene.
I've stuck and don't know where to go next.
Does anyone know for sure if Cocos Studio is compatible with Cocos 2d JS?
UPDATE
here is the code I'm using to initialise the project
cc.game.onStart = function(){
cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS ? true : false);
cc.view.adjustViewPort(true);
cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL);
resolution size
cc.view.resizeWithBrowserSize(true);
cc.LoaderScene.preload(g_resources, function () {
var scene = ccs.load("res/MainScene.json");
cc.director.runScene(scene.node);
}, this);
};
cc.game.run();
it's autogenerated by setup.py script, I just replaced Scene creation code with load from json.
after var scene = line of code scene object is null or undefined
I have a dart-polymer component mediator-form that I would like to add programmatically to another component. That I have done successfully. However, mediator-form is used several times. For my purpose I would like to pass #published data in the form
<mediator-form mediator='Medication'>
where the published mediator data is used.
My problem is I don't know how to set the mediator='Medication' programmatically.
My attempt is shown below
.html
<link rel='import' href='mediator_form.html'>
.dart
var newElem = new Element.tag('mediator-form')
..attributes['mediator'] = 'Medication';
does not work. newElement does not have a setProperty() method so it does not seem possible.
Any help is appreciated. Thanks.
This should work
var newElem = new Element.tag('mediator-form')
..attributes['mediator'] = 'Medication';
maybe it only works after you added it to the DOM (haven't tried myself this way).
This should also work:
var newElem = (new Element.tag('mediator-form') as MediatorForm)
..mediator = 'Medication';
If it doesn't you probably haven't imported the element.
You can set value directly on dart object, but to have that object you have to wait at least one cycle of event loop to give polymer a chance to instantiate your object in a DOM:
document.body.append(new Element.tag("mediator-form"));
// Delaying the following after element is instantiated
Timer.run((){
MediatorForm form = document.body.querySelector('mediator-form');
form.mediator = "Medication";
});
I want to operate with googleapis package. I want simply to hide a YouTube video after it ends. I have the following code:
import 'dart:html';
import 'package:googleapis/youtube/v3.dart';
import 'package:googleapis_auth/auth_io.dart';
final _credentials = new ServiceAccountCredentials.fromJson(r'''
{
"private_key_id": ...,
"private_key": ...,
"client_email": ...,
"client_id": ...,
"type": "service_account"
}
''');
const _SCOPES = const [StorageApi.DevstorageReadOnlyScope];
main(){
// insert stylesheet for video (width, height, border, etc.) - works well
LinkElement styles=new LinkElement();
styles..href='iframe.css'
..rel='stylesheet'
..type='text/css';
document.head.append(styles);
//add iframe element - works also well
IFrameElement video=new IFrameElement();
video.attributes={'allowfullscreen':'','seamless':'','src':'http://www.youtube.com/embed/ORsFFjt1x6Q?autoplay=1&enablejsapi=1'};
document.body.insertAdjacentElement('afterBegin',video);
//check if the video has ended - probably doesn't work
if(video.contentDocument.onLoad){
if(video.getPlayerState==0){
video.remove();
}
}
}
What am I doing wrong?
Your video variable is type of IFrameElement and you can't run callMethod of JsObject on it.
You need to use Youtube API of Dart which is in Beta from Google and is deprecated in Dart document.
Dart has an onEnded event method for IFrameElement, Element and MediaElement which is in experimental yet but may work for you.
I suggest to use YouTube iframe JavaScript API in your Dart code!
these sources explain what you need:
https://www.dartlang.org/articles/js-dart-interop/
https://developers.google.com/youtube/iframe_api_reference
if you need more information tell me what you want to know.
I'm starting learning dart, I've installed the Dart Editor normally on a Linux system, but the problem comes up when I start to code a simple snippet of code for instance this:
import 'dart:html';
void main() {
querySelector('#status').innerHtml = "Hola mundo";
var button = new ButtonElement();
button.text = "Haz click";
button.on.click.add( (e){
var div = new Element.html("<div>puto</div>");
document.body.elements.add(div);
});
document.body.elements.add(button);
}
I get three warnings with the same messages: "There is no such getter 'function' in..." in three different parts of the code:
I got this code in a book, so the code is correct, How do I resolve this problem? thanks
edit: I cannot run this code with these warnings as you could expect.
The book is probably out of date from the current library APIs.
Try changing elements to children, e.g. document.body.children.add(elem2); is an example in the DOM section of Dart: Up and Running.
See the api
https://api.dartlang.org/apidocs/channels/stable/#dart-dom-html.Element#id_onClick
ElementStream<MouseEvent> get onClick
Stream of click events handled by this Element.
This syntax is outdated
// button.on.click.add( (e){
button.onClick.listen(callback);
// or button.on['my-custom-event'].litsen();
I am developing an application for blackberry playbook using flex hero and html contents are displayed using QNXStageWebView.But the problem is when i add this webview to stage its coming on top of all other display objects.I am not able to control it.I need to solve it then only i can continue my work. can anyone help me to solve this issue???
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import qnx.media.QNXStageWebView;
public var webview:QNXStageWebView = new QNXStageWebView();
protected function view1_creationCompleteHandler(event:FlexEvent):void
{
var rect:Rectangle = new Rectangle(0,0,200,400);
webview.stage = stage;
webview.viewPort = rect;
webview.zOrder = 1;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button id="buttn" x="0" y="0"/>
when i run this code am not able to see that button. i need to display it on top of webview.
Have you tried removing the zOrder? It's like the z-order-property of html to arrange children in certain layers.
AFAIK, currently it just can't do that, all QNXStageWebView always placed on top of other object, we better wait for adobe / RIM to improve the implementation.