• beyond tellerrand – play. Register Now!
Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 26-02-2010, 21:49   #1 (permalink)
Neuer User
 
Registriert seit: Feb 2010
Beiträge: 1
SWFObject und ExternalInterface

Hallo Leute,

ich bin ein ziemlicher Flash Neuling und habe Probleme extern, also per Javascript, auf Flash Funktionen zuzugreifen...

er sagt mir immer... diese Funktion existiert nicht...

Vielleicht kann mir jemand nen tip geben.
HTML:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
	http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/b431519b9785ab4d
		<title>SWFObject 2 dynamic publishing example page</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<script type="text/javascript" src="./libs/js/swfobject.js"></script>
		<script type="text/javascript">
		
		  var params = { allowScriptAccess: "always", bgcolor: "#000", wmode:"transparent" , allowFullScreen:"true", scale: "noScale"};
                    // this sets the id of the object or embed tag to myytplayer.
                    // You then use this id to access the swf and make calls to theplayer's API
          var atts = { id: "myPlayer" };
          swfobject.embedSWF("./libs/flash/meins-1.swf", "ytapiplayer", "468", "351", "9", null, null,params, atts);
		 function init() {
			var player = document.getElementById('myPlayer');
			
			//Das funktioniert nicht...
			alert(player.getPlayerState());
		 }
		 
		 window.onload = init;

		   
		</script>
	</head>
	<body>
		<div id="ytapiplayer">
			<h1>Alternative content</h1>
			<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
		</div>
	</body>
</html>
Flash Datei
Code:
// Sample code for a actionscript 2.0 wrapper for the youtube chromeless player
// Written by Benjamin Lowenstein | Colingo Labs LLC 2008

import flash.external.ExternalInterface;

// Set the stage :)
Stage.width = 468;
Stage.height = 351;
Stage.align = "TL";

// create a MovieClip to load the player into
ytplayer = createEmptyMovieClip("ytplayer", 1);

// create a listener object for the MovieClipLoader to use
ytPlayerLoaderListener = {};
var loadInterval:Number;

// When the player clip first loads, we start an interval to check for when the
// player is ready
ytPlayerLoaderListener.onLoadInit = function() {
    loadInterval = setInterval(checkPlayerLoaded, 250);

}

function checkPlayerLoaded():Void {
    // once the player is ready, we can subscribe to events, or in the case of
    // the chromeless player, we could load videos
    if (ytplayer.isPlayerLoaded()) {
                                ytplayer.setSize(Stage.width, Stage.height);
        ytplayer.addEventListener("onStateChange",onPlayerStateChange);
        ytplayer.addEventListener("onError", onPlayerError);
        // when the player is clicked or escape is pressed, go fullscreen
        ytplayer.onRelease= function(){ fullScreen(); }
        loadIndicator._visible = false;
        clearInterval(loadInterval);
    }

}

function fullScreen(){
    if (Stage["displayState"] == "normal") {
        Stage["displayState"] = "fullScreen";
    }else{
        Stage["displayState"] = "normal";
    }
    // set the player to the proper height
    ytplayer.setSize(Stage.width, Stage.height);

}


Stage.addListener( fsListener );

function onPlayerStateChange(newState:Number) {
    trace("New player state: " + newState);

}

function onPlayerError(errorCode:Number) {
    trace("An error occurred: "+ errorCode);

}

// create a MovieClipLoader to handle the loading of the player
ytPlayerLoader = new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);

// load the player
ytPlayerLoader.loadClip("http://www.youtube.com/apiplayer", ytplayer);

/*
 * The ymPlayer API
 */

function playVideo() {
        ytplayer.playVideo();

}

function pauseVideo() {
        ytplayer.pauseVideo();

}

function clearVideo() {
        ytplayer.clearVideo();

}

function stopVideo() {
        ytplayer.stopVideo();

}

function loadVideoById(videoID) {
        ytplayer.loadVideoById(videoID);

}

function cueVideoById(videoID) {
        ytplayer.cueVideoById(videoID);

}

function setVolume(vol) {
        ytplayer.setVolume(vol);

}

function seekTo(time, allowSeekAhead) {
        ytplayer.seekTo(time, allowSeekAhead);

}

function getPlayerState(){
        var state = ytplayer.getPlayerState();
        return state;

}

function getCurrentTime(){
        var time = ytplayer.getCurrentTime();
        return time;

}

function getVolume(){
        var vol = ytplayer.getVolume();
        return vol;

}

// expose methods to javascript
ExternalInterface.addCallback( "playVideo", this, playVideo );
ExternalInterface.addCallback( "pauseVideo", this, pauseVideo );
ExternalInterface.addCallback( "clearVideo", this, stopVideo );
ExternalInterface.addCallback( "stopVideo", this, clearVideo );
ExternalInterface.addCallback( "loadVideoById", this,
loadVideoById );
ExternalInterface.addCallback( "cueVideoById", this, cueVideoById );
ExternalInterface.addCallback( "setVolume", this, setVolume );
ExternalInterface.addCallback( "seekTo", this, seekTo );
ExternalInterface.addCallback( "getPlayerState", this,
getPlayerState );
ExternalInterface.addCallback( "getCurrentTime", this,
getCurrentTime );
ExternalInterface.addCallback( "getVolume", this, getVolume );
danke schonmal

lg
Akrillo
Akrillo ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Stichworte
externalinterface, swfobject

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
ExternalInterface iXtends ActionScript 3 5 26-03-2009 18:04
ExternalInterface RhettButler ActionScript 2 1 13-01-2009 14:40
ExternalInterface feivelmaus Flash Einsteiger 1 20-05-2008 13:46
ExternalInterface danwip Flash 8 7 24-09-2005 05:07


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:54 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele